Version 2.13.0-110.0.dev

Merge commit '3f5694c8277ad181fca994e660bf0c7a7169571a' into 'dev'
diff --git a/pkg/analysis_server/lib/src/computer/computer_signature.dart b/pkg/analysis_server/lib/src/computer/computer_signature.dart
index c1e5764..bb26c6a 100644
--- a/pkg/analysis_server/lib/src/computer/computer_signature.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_signature.dart
@@ -49,17 +49,17 @@
     final args = argsNode;
     String name;
     ExecutableElement execElement;
-    if (args.parent is MethodInvocation) {
-      MethodInvocation method = args.parent;
-      name = method.methodName.name;
-      execElement = ElementLocator.locate(method) as ExecutableElement;
-    } else if (args.parent is InstanceCreationExpression) {
-      InstanceCreationExpression constructor = args.parent;
-      name = constructor.constructorName.type.name.name;
-      if (constructor.constructorName.name != null) {
-        name += '.${constructor.constructorName.name.name}';
+    final parent = args.parent;
+    if (parent is MethodInvocation) {
+      name = parent.methodName.name;
+      var element = ElementLocator.locate(parent);
+      execElement = element is ExecutableElement ? element : null;
+    } else if (parent is InstanceCreationExpression) {
+      name = parent.constructorName.type.name.name;
+      if (parent.constructorName.name != null) {
+        name += '.${parent.constructorName.name.name}';
       }
-      execElement = ElementLocator.locate(constructor) as ExecutableElement;
+      execElement = ElementLocator.locate(parent) as ExecutableElement;
     }
 
     if (execElement == null) {
diff --git a/pkg/analysis_server/lib/src/status/element_writer.dart b/pkg/analysis_server/lib/src/status/element_writer.dart
index ca4d836..20e2720 100644
--- a/pkg/analysis_server/lib/src/status/element_writer.dart
+++ b/pkg/analysis_server/lib/src/status/element_writer.dart
@@ -53,7 +53,6 @@
       properties['isStatic'] = element.isStatic;
     }
     if (element is CompilationUnitElement) {
-      properties['hasLoadLibraryFunction'] = element.hasLoadLibraryFunction;
       properties['source'] = element.source;
     }
     if (element is ConstFieldElementImpl) {
@@ -109,7 +108,6 @@
       properties['definingCompilationUnit'] = element.definingCompilationUnit;
       properties['entryPoint'] = element.entryPoint;
       properties['hasExtUri'] = element.hasExtUri;
-      properties['hasLoadLibraryFunction'] = element.hasLoadLibraryFunction;
       properties['isBrowserApplication'] = element.isBrowserApplication;
       properties['isDartAsync'] = element.isDartAsync;
       properties['isDartCore'] = element.isDartCore;
diff --git a/pkg/analysis_server/test/lsp/signature_help_test.dart b/pkg/analysis_server/test/lsp/signature_help_test.dart
index 2e6094e..9bee6e4 100644
--- a/pkg/analysis_server/test/lsp/signature_help_test.dart
+++ b/pkg/analysis_server/test/lsp/signature_help_test.dart
@@ -84,6 +84,31 @@
     );
   }
 
+  Future<void> test_error_methodInvocation_importPrefix() async {
+    final content = '''
+import 'dart:async' as prefix;
+
+void f() {
+  prefix(^);
+}
+''';
+
+    await initialize(
+      textDocumentCapabilities: withSignatureHelpContentFormat(
+        emptyTextDocumentClientCapabilities,
+        [MarkupKind.Markdown],
+      ),
+    );
+    await openFile(mainFileUri, withoutMarkers(content));
+
+    // Expect no result.
+    final res = await getSignatureHelp(
+      mainFileUri,
+      positionFromMarker(content),
+    );
+    expect(res, isNull);
+  }
+
   Future<void> test_formats_markdown() async {
     final content = '''
     /// Does foo.
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index fb8ce6f..85778f6 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -408,6 +408,7 @@
 
   /// Return `true` if this compilation unit defines a top-level function named
   /// `loadLibrary`.
+  @Deprecated('Not useful for clients')
   bool get hasLoadLibraryFunction;
 
   /// Return the [LineInfo] for the [source], or `null` if not computed yet.
@@ -1328,6 +1329,7 @@
 
   /// Return `true` if this library defines a top-level function named
   /// `loadLibrary`.
+  @Deprecated('Not useful for clients')
   bool get hasLoadLibraryFunction;
 
   /// Return an identifier that uniquely identifies this element among the
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 30e8681..45df3f4 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1338,6 +1338,7 @@
   @override
   int get hashCode => source.hashCode;
 
+  @Deprecated('Not useful for clients')
   @override
   bool get hasLoadLibraryFunction {
     List<FunctionElement> functions = this.functions;
@@ -5029,6 +5030,7 @@
     setModifier(Modifier.HAS_EXT_URI, hasExtUri);
   }
 
+  @Deprecated('Not useful for clients')
   @override
   bool get hasLoadLibraryFunction {
     for (int i = 0; i < units.length; i++) {
diff --git a/pkg/analyzer/lib/src/error/best_practices_verifier.dart b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
index 9b54f4e..e68cf25 100644
--- a/pkg/analyzer/lib/src/error/best_practices_verifier.dart
+++ b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
@@ -1130,11 +1130,15 @@
   /// See [CompileTimeErrorCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION].
   bool _checkForLoadLibraryFunction(
       ImportDirective node, ImportElement importElement) {
-    LibraryElement? importedLibrary = importElement.importedLibrary;
-    if (importedLibrary == null) {
+    var importedLibrary = importElement.importedLibrary;
+    var prefix = importElement.prefix;
+    if (importedLibrary == null || prefix == null) {
       return false;
     }
-    if (importedLibrary.hasLoadLibraryFunction) {
+    var importNamespace = importElement.namespace;
+    var loadLibraryElement = importNamespace.getPrefixed(
+        prefix.name, FunctionElement.LOAD_LIBRARY_NAME);
+    if (loadLibraryElement != null) {
       _errorReporter.reportErrorForNode(
           HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
           node,
diff --git a/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart b/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart
index 040fe91..5befb60 100644
--- a/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart
@@ -5,7 +5,6 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
-import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -18,59 +17,90 @@
 class ImportDeferredLibraryWithLoadFunctionTest
     extends PubPackageResolutionTest {
   test_deferredImport_withLoadLibraryFunction() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
-library lib1;
-loadLibrary() {}
-f() {}''');
+    newFile('$testPackageLibPath/a.dart', content: r'''
+void loadLibrary() {}
+void f() {}
+''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
-library root;
-import 'lib1.dart' deferred as lib1;
-main() { lib1.f(); }''');
-
-    await _resolveFile('$testPackageLibPath/lib1.dart');
-    await _resolveFile('$testPackageLibPath/lib2.dart', [
-      error(HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, 14, 36),
+    await assertErrorsInCode(r'''
+import 'a.dart' deferred as p;
+void main() {
+  p.f();
+}
+''', [
+      error(HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, 0, 30),
     ]);
   }
 
+  test_deferredImport_withLoadLibraryFunction_hide() async {
+    newFile('$testPackageLibPath/a.dart', content: r'''
+void loadLibrary() {}
+void f() {}
+''');
+
+    await assertNoErrorsInCode(r'''
+import 'a.dart' deferred as p hide loadLibrary;
+void main() {
+  p.f();
+}
+''');
+  }
+
+  test_deferredImport_withLoadLibraryFunction_hide2() async {
+    newFile('$testPackageLibPath/a.dart', content: r'''
+void loadLibrary() {}
+void f() {}
+void f2() {}
+''');
+
+    await assertErrorsInCode(r'''
+import 'a.dart' deferred as p hide f2;
+void main() {
+  p.f();
+}
+''', [
+      error(HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, 0, 38),
+    ]);
+  }
+
+  test_deferredImport_withLoadLibraryFunction_show() async {
+    newFile('$testPackageLibPath/a.dart', content: r'''
+void loadLibrary() {}
+void f() {}
+''');
+
+    await assertNoErrorsInCode(r'''
+import 'a.dart' deferred as p show f;
+void main() {
+  p.f();
+}
+''');
+  }
+
   test_deferredImport_withoutLoadLibraryFunction() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
-library lib1;
-f() {}''');
+    newFile('$testPackageLibPath/a.dart', content: r'''
+void f() {}
+''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
-library root;
-import 'lib1.dart' deferred as lib1;
-main() { lib1.f(); }''');
-
-    await _resolveFile('$testPackageLibPath/lib1.dart');
-    await _resolveFile('$testPackageLibPath/lib2.dart');
+    await assertNoErrorsInCode(r'''
+import 'a.dart' deferred as p;
+void main() {
+  p.f();
+}
+''');
   }
 
   test_nonDeferredImport_withLoadLibraryFunction() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
-library lib1;
-loadLibrary() {}
-f() {}''');
+    newFile('$testPackageLibPath/a.dart', content: r'''
+void loadLibrary() {}
+void f() {}
+''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
-library root;
-import 'lib1.dart' as lib1;
-main() { lib1.f(); }''');
-
-    await _resolveFile('$testPackageLibPath/lib1.dart');
-    await _resolveFile('$testPackageLibPath/lib2.dart');
-  }
-
-  /// Resolve the file with the given [path].
-  ///
-  /// Similar to ResolutionTest.resolveTestFile, but a custom path is supported.
-  Future<void> _resolveFile(
-    String path, [
-    List<ExpectedError> expectedErrors = const [],
-  ]) async {
-    result = await resolveFile(convertPath(path));
-    assertErrorsInResolvedUnit(result, expectedErrors);
+    await assertNoErrorsInCode(r'''
+import 'a.dart' as p;
+void main() {
+  p.f();
+}
+''');
   }
 }
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 0781a1b..1cb8896 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -1716,6 +1716,7 @@
 #if !defined(DART_PRECOMPILED_RUNTIME)
       native_callback_trampolines_(),
 #endif
+      isolate_flags_(0),
 #if !defined(PRODUCT)
       last_resume_timestamp_(OS::GetCurrentTimeMillis()),
       vm_tag_counters_(),
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index c8217eb..d146eac 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -1099,9 +1099,9 @@
   MessageHandler* message_handler() const { return message_handler_; }
   void set_message_handler(MessageHandler* value) { message_handler_ = value; }
 
-  bool is_runnable() const { return IsRunnableBit::decode(isolate_flags_); }
+  bool is_runnable() const { return LoadIsolateFlagsBit<IsRunnableBit>(); }
   void set_is_runnable(bool value) {
-    isolate_flags_ = IsRunnableBit::update(value, isolate_flags_);
+    UpdateIsolateFlagsBit<IsRunnableBit>(value);
 #if !defined(PRODUCT)
     if (is_runnable()) {
       set_last_resume_timestamp();
@@ -1120,12 +1120,10 @@
     return OFFSET_OF(Isolate, single_step_);
   }
 
-  bool ResumeRequest() const {
-    return ResumeRequestBit::decode(isolate_flags_);
-  }
+  bool ResumeRequest() const { return LoadIsolateFlagsBit<ResumeRequestBit>(); }
   // Lets the embedder know that a service message resulted in a resume request.
   void SetResumeRequest() {
-    isolate_flags_ = ResumeRequestBit::update(true, isolate_flags_);
+    UpdateIsolateFlagsBit<ResumeRequestBit>(true);
     set_last_resume_timestamp();
   }
 
@@ -1138,9 +1136,7 @@
   // Returns whether the vm service has requested that the debugger
   // resume execution.
   bool GetAndClearResumeRequest() {
-    bool resume_request = ResumeRequestBit::decode(isolate_flags_);
-    isolate_flags_ = ResumeRequestBit::update(false, isolate_flags_);
-    return resume_request;
+    return UpdateIsolateFlagsBit<ResumeRequestBit>(false);
   }
 #endif
 
@@ -1162,9 +1158,9 @@
   void RemoveErrorListener(const SendPort& listener);
   bool NotifyErrorListeners(const char* msg, const char* stacktrace);
 
-  bool ErrorsFatal() const { return ErrorsFatalBit::decode(isolate_flags_); }
-  void SetErrorsFatal(bool val) {
-    isolate_flags_ = ErrorsFatalBit::update(val, isolate_flags_);
+  bool ErrorsFatal() const { return LoadIsolateFlagsBit<ErrorsFatalBit>(); }
+  void SetErrorsFatal(bool value) {
+    UpdateIsolateFlagsBit<ErrorsFatalBit>(value);
   }
 
   Random* random() { return &random_; }
@@ -1254,11 +1250,10 @@
 
 #if !defined(PRODUCT)
   bool should_pause_post_service_request() const {
-    return ShouldPausePostServiceRequestBit::decode(isolate_flags_);
+    return LoadIsolateFlagsBit<ShouldPausePostServiceRequestBit>();
   }
   void set_should_pause_post_service_request(bool value) {
-    isolate_flags_ =
-        ShouldPausePostServiceRequestBit::update(value, isolate_flags_);
+    UpdateIsolateFlagsBit<ShouldPausePostServiceRequestBit>(value);
   }
 #endif  // !defined(PRODUCT)
 
@@ -1320,17 +1315,17 @@
 #endif
 
   bool is_service_isolate() const {
-    return IsServiceIsolateBit::decode(isolate_flags_);
+    return LoadIsolateFlagsBit<IsServiceIsolateBit>();
   }
   void set_is_service_isolate(bool value) {
-    isolate_flags_ = IsServiceIsolateBit::update(value, isolate_flags_);
+    UpdateIsolateFlagsBit<IsServiceIsolateBit>(value);
   }
 
   bool is_kernel_isolate() const {
-    return IsKernelIsolateBit::decode(isolate_flags_);
+    return LoadIsolateFlagsBit<IsKernelIsolateBit>();
   }
   void set_is_kernel_isolate(bool value) {
-    isolate_flags_ = IsKernelIsolateBit::update(value, isolate_flags_);
+    UpdateIsolateFlagsBit<IsKernelIsolateBit>(value);
   }
 
   // Whether it's possible for unoptimized code to optimize immediately on entry
@@ -1365,7 +1360,7 @@
 
 #define DECLARE_GETTER(when, name, bitname, isolate_flag_name, flag_name)      \
   bool name() const {                                                          \
-    return FLAG_FOR_##when(bitname##Bit::decode(isolate_flags_), flag_name);   \
+    return FLAG_FOR_##when(LoadIsolateFlagsBit<bitname##Bit>(), flag_name);    \
   }
   BOOL_ISOLATE_FLAG_LIST_DEFAULT_GETTER(DECLARE_GETTER)
 #undef FLAG_FOR_NONPRODUCT
@@ -1374,10 +1369,10 @@
 #undef DECLARE_GETTER
 
   bool has_attempted_stepping() const {
-    return HasAttemptedSteppingBit::decode(isolate_flags_);
+    return LoadIsolateFlagsBit<HasAttemptedSteppingBit>();
   }
   void set_has_attempted_stepping(bool value) {
-    isolate_flags_ = HasAttemptedSteppingBit::update(value, isolate_flags_);
+    UpdateIsolateFlagsBit<HasAttemptedSteppingBit>(value);
   }
 
   static void KillAllIsolates(LibMsgId msg_id);
@@ -1546,7 +1541,18 @@
   ISOLATE_FLAG_BITS(DECLARE_BITFIELD)
 #undef DECLARE_BITFIELD
 
-  uint32_t isolate_flags_ = 0;
+  template <class T>
+  bool UpdateIsolateFlagsBit(bool value) {
+    return T::decode(value ? isolate_flags_.fetch_or(T::encode(true),
+                                                     std::memory_order_relaxed)
+                           : isolate_flags_.fetch_and(
+                                 ~T::encode(true), std::memory_order_relaxed));
+  }
+  template <class T>
+  bool LoadIsolateFlagsBit() const {
+    return T::decode(isolate_flags_.load(std::memory_order_relaxed));
+  }
+  std::atomic<uint32_t> isolate_flags_;
 
 // Fields that aren't needed in a product build go here with boolean flags at
 // the top.
diff --git a/tools/VERSION b/tools/VERSION
index 0cee519..283b038 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 109
+PRERELEASE 110
 PRERELEASE_PATCH 0
\ No newline at end of file