Version 2.18.0-235.0.dev

Merge commit '68fc59b2a18ee88903985bfd927ee44bac755103' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index c582c27..c436ab7 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -633,7 +633,10 @@
 
     var unit = parse();
     return _fsState._logger.run('Create unlinked for $path', () {
-      var unlinkedUnit = serializeAstUnlinked2(unit);
+      var unlinkedUnit = serializeAstUnlinked2(
+        unit,
+        isDartCore: uriStr == 'dart:core',
+      );
       var definedNames = computeDefinedNames(unit);
       var referencedNames = computeReferencedNames(unit);
       var subtypedNames = computeSubtypedNames(unit);
@@ -837,7 +840,10 @@
     ];
   }
 
-  static UnlinkedUnit serializeAstUnlinked2(CompilationUnit unit) {
+  static UnlinkedUnit serializeAstUnlinked2(
+    CompilationUnit unit, {
+    required bool isDartCore,
+  }) {
     UnlinkedLibraryDirective? libraryDirective;
     UnlinkedLibraryAugmentationDirective? libraryAugmentationDirective;
     UnlinkedPartOfNameDirective? partOfNameDirective;
@@ -932,7 +938,7 @@
         }
       }
     }
-    if (!hasDartCoreImport) {
+    if (!isDartCore && !hasDartCoreImport) {
       imports.add(
         UnlinkedNamespaceDirective(
           configurations: [],
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index 2d8b725..b121f74 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -1451,6 +1451,19 @@
 ''');
   }
 
+  test_newFile_library_dartCore() async {
+    final core = fsStateFor(testFile).getFileForUri(
+      Uri.parse('dart:core'),
+    );
+
+    final coreKind = core.t1!.kind as LibraryFileStateKind;
+    for (final import in coreKind.imports) {
+      if (import.isSyntheticDartCoreImport) {
+        fail('dart:core should not import itself');
+      }
+    }
+  }
+
   test_newFile_library_exports_augmentation() async {
     newFile('$testPackageLibPath/b.dart', r'''
 library augment 'a.dart';
@@ -2680,7 +2693,6 @@
 ''');
   }
 
-  /// TODO(scheglov) Test discovery of a sibling library
   test_newFile_partOfName() async {
     final a = newFile('$testPackageLibPath/nested/a.dart', r'''
 library my.lib;
@@ -2820,6 +2832,53 @@
 ''');
   }
 
+  test_newFile_partOfName_discoverSiblingLibrary() async {
+    final a = newFile('$testPackageLibPath/a.dart', r'''
+library my.lib;
+part 'b.dart';
+''');
+
+    final b = newFile('$testPackageLibPath/b.dart', r'''
+part of my.lib;
+''');
+
+    final bState = fileStateFor(b);
+
+    // The library is discovered by looking at sibling files.
+    final bKind = bState.kind as PartOfNameFileStateKind;
+    expect(bKind.library?.file.resource, a);
+
+    assertDriverStateString(testFile, r'''
+files
+  /home/test/lib/a.dart
+    uri: package:test/a.dart
+    current
+      id: file_0
+      kind: library_0
+        name: my.lib
+        imports
+          library_2 dart:core synthetic
+        parts
+          partOfName_1
+        cycle_0
+          dependencies: dart:core
+          libraries: library_0
+          apiSignature_0
+      unlinkedKey: k00
+  /home/test/lib/b.dart
+    uri: package:test/b.dart
+    current
+      id: file_1
+      kind: partOfName_1
+        libraries: library_0
+        library: library_0
+      referencingFiles: file_0
+      unlinkedKey: k01
+libraryCycles
+elementFactory
+''');
+  }
+
   test_newFile_partOfName_twoLibraries() async {
     final a = newFile('$testPackageLibPath/a.dart', r'''
 library my.lib;
diff --git a/pkg/analyzer/test/src/dart/resolution/node_text_expectations.dart b/pkg/analyzer/test/src/dart/resolution/node_text_expectations.dart
index 38fa50e..8891963 100644
--- a/pkg/analyzer/test/src/dart/resolution/node_text_expectations.dart
+++ b/pkg/analyzer/test/src/dart/resolution/node_text_expectations.dart
@@ -9,7 +9,7 @@
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 class NodeTextExpectationsCollector {
-  static const updatingIsEnabled = true;
+  static const updatingIsEnabled = false;
 
   static const assertMethods = {
     'ContextResolutionTest.assertDriverStateString',
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index a654ce3..8459ff0 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -9,6 +9,7 @@
 import 'dart:convert'
     show ChunkedConversionSink, JsonEncoder, StringConversionSink;
 
+import 'package:compiler/src/js_model/elements.dart';
 import 'package:dart2js_info/info.dart';
 import 'package:dart2js_info/json_info_codec.dart';
 import 'package:dart2js_info/binary_serialization.dart' as dump_info;
@@ -434,9 +435,7 @@
     if (libname == null || libname.isEmpty) {
       libname = '${lib.importUri}';
     }
-
     LibraryInfo info = LibraryInfo(libname, lib.importUri, null, null);
-    state.entityToInfo[libEntity] = info;
 
     lib.members.forEach((ir.Member member) {
       final memberEntity =
@@ -485,7 +484,6 @@
       type: field.type.toStringInternal(),
       isConst: field.isConst,
     );
-    state.entityToInfo[fieldEntity] = info;
 
     if (compiler.options.experimentCallInstrumentation) {
       // We use field.hashCode because it is globally unique and it is
@@ -510,27 +508,27 @@
     // Omit class if it is not needed.
     ClassInfo classInfo = ClassInfo(
         name: clazz.name, isAbstract: clazz.isAbstract, outputUnit: null);
-    state.entityToInfo[classEntity] = classInfo;
 
     clazz.members.forEach((ir.Member member) {
+      final isSetter = member is ir.Procedure && member.isSetter;
       // clazz.members includes constructors
-      MemberEntity memberEntity =
-          environment.lookupLocalClassMember(classEntity, member.name.text) ??
-              environment.lookupConstructor(classEntity, member.name.text);
+      MemberEntity memberEntity = environment.lookupLocalClassMember(
+              classEntity, member.name.text,
+              setter: isSetter) ??
+          environment.lookupConstructor(classEntity, member.name.text);
       if (memberEntity == null) return;
-      // Multiple kernel members can map to single JWorld member
-      // (e.g., when one of a getter/field pair are tree-shaken),
-      // so avoid duplicating the downstream info object.
-      if (state.entityToInfo.containsKey(memberEntity)) {
-        return;
-      }
 
       if (member.function != null) {
-        FunctionInfo functionInfo =
-            visitFunction(member.function, functionEntity: memberEntity);
-        if (functionInfo != null) {
-          classInfo.functions.add(functionInfo);
-          functionInfo.parent = classInfo;
+        // Multiple kernel members can map to single JWorld member
+        // (e.g., when one of a getter/field pair are tree-shaken),
+        // so avoid duplicating the downstream info object.
+        if (memberEntity is FunctionEntity) {
+          FunctionInfo functionInfo =
+              visitFunction(member.function, functionEntity: memberEntity);
+          if (functionInfo != null) {
+            classInfo.functions.add(functionInfo);
+            functionInfo.parent = classInfo;
+          }
         }
       } else {
         FieldInfo fieldInfo = visitField(member, fieldEntity: memberEntity);
@@ -605,7 +603,6 @@
         modifiers: modifiers,
         returnType: function.returnType.toStringInternal(),
         type: functionType.toStringInternal());
-    state.entityToInfo[functionEntity] = info;
 
     if (function.parent is ir.Member)
       _addClosureInfo(info, function.parent,
@@ -643,13 +640,11 @@
       });
       final closureClassEntity = closureEntity.enclosingClass;
       final closureInfo = ClosureInfo.fromKernel(name: value.disambiguatedName);
-      state.entityToInfo[closureClassEntity] = closureInfo;
 
       FunctionEntity callMethod = closedWorld.elementEnvironment
           .lookupClassMember(closureClassEntity, Identifiers.call);
       final functionInfo = visitFunction(key.function,
           functionEntity: callMethod, localFunctionInfo: value);
-      state.entityToInfo[closureEntity] = functionInfo;
 
       closureInfo.function = functionInfo;
       functionInfo.parent = closureInfo;
@@ -737,6 +732,7 @@
         'Ambiguous library resolution. '
         'Expected singleton, found $kLibraryInfos');
     var kLibraryInfo = kLibraryInfos.first;
+    kernelInfo.state.entityToInfo[lib] = kLibraryInfo;
 
     String libname = environment.getLibraryName(lib);
     if (libname.isEmpty) {
@@ -799,6 +795,7 @@
         'Ambiguous field resolution. '
         'Expected singleton, found $kFieldInfos');
     final kFieldInfo = kFieldInfos.first;
+    kernelInfo.state.entityToInfo[field] = kFieldInfo;
 
     int size = dumpInfoTask.sizeOf(field);
     List<CodeSpan> code = dumpInfoTask.codeOf(field);
@@ -860,10 +857,15 @@
         'Ambiguous class resolution. '
         'Expected singleton, found $kClassInfos');
     final kClassInfo = kClassInfos.first;
+    kernelInfo.state.entityToInfo[clazz] = kClassInfo;
 
     int size = dumpInfoTask.sizeOf(clazz);
     final disambiguatedMemberName = '$parentName/${clazz.name}';
     environment.forEachLocalClassMember(clazz, (member) {
+      // Skip certain incongruent locals that during method alias installation.
+      if (member is JMethod && member.enclosingClass.name != clazz.name) {
+        return;
+      }
       if (member.isFunction || member.isGetter || member.isSetter) {
         FunctionInfo functionInfo =
             visitFunction(member, disambiguatedMemberName);
@@ -916,6 +918,7 @@
         'Ambiguous closure resolution. '
         'Expected singleton, found $kClosureInfos');
     final kClosureInfo = kClosureInfos.first;
+    kernelInfo.state.entityToInfo[element] = kClosureInfo;
 
     kClosureInfo.outputUnit = _unitInfoForClass(element);
     kClosureInfo.size = dumpInfoTask.sizeOf(element);
@@ -961,6 +964,7 @@
         'Expected single or none, found $kFunctionInfos');
     if (kFunctionInfos.length == 0) return null;
     final kFunctionInfo = kFunctionInfos.first;
+    kernelInfo.state.entityToInfo[function] = kFunctionInfo;
 
     List<CodeSpan> code = dumpInfoTask.codeOf(function);
     List<ParameterInfo> parameters = <ParameterInfo>[];
diff --git a/tools/VERSION b/tools/VERSION
index 0184f27..4f0a8bd 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 18
 PATCH 0
-PRERELEASE 234
+PRERELEASE 235
 PRERELEASE_PATCH 0
\ No newline at end of file