Version 2.14.0-269.0.dev

Merge commit '5dcd5aba46499ad8d3663d80a192c5b3eca834a9' into 'dev'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85e4d97..f742e9b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -103,8 +103,19 @@
 
 #### Linter
 
-Updated the Linter to `1.6.1`, which includes changes that
+Updated the Linter to `1.7.0`, which includes changes that
 
+- fix case-sensitive false positive in `use_full_hex_values_for_flutter_colors`.
+- improve try-block and switch statement flow analysis for 
+  `use_build_context_synchronously`.
+- update `use_setters_to_change_properties` to only highlight a method name,
+  not the entire body and doc comment.
+- update `unnecessary_getters_setters` to allow otherwise "unnecessary" getters
+  and setters with annotations.
+- update `missing_whitespace_between_adjacent_strings` to allow String
+  interpolations at the beginning and end of String literals.
+- update `unnecessary_getters_setters` to allow for setters with non-basic
+  assignments (for example, `??=` or `+=`).
 - relax `non_constant_identifier_names` to allow for a trailing
   underscore.
 - fix false negative in `prefer_final_parameters` where first parameter
diff --git a/DEPS b/DEPS
index 97f5438..47bfafb 100644
--- a/DEPS
+++ b/DEPS
@@ -124,7 +124,7 @@
   "intl_tag": "0.17.0-nullsafety",
   "jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
   "json_rpc_2_rev": "7e00f893440a72de0637970325e4ea44bd1e8c8e",
-  "linter_tag": "1.6.1",
+  "linter_tag": "422981ffb2fbd4010aa52381676cf745e2844dd9",
   "lints_tag": "f9670df2a66e0ec12eb51554e70c1cbf56c8f5d0",
   "logging_rev": "e2f633b543ef89c54688554b15ca3d7e425b86a2",
   "markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
diff --git a/pkg/analysis_server/lib/src/lsp/client_capabilities.dart b/pkg/analysis_server/lib/src/lsp/client_capabilities.dart
index 2d7bc42..c6898f3 100644
--- a/pkg/analysis_server/lib/src/lsp/client_capabilities.dart
+++ b/pkg/analysis_server/lib/src/lsp/client_capabilities.dart
@@ -68,6 +68,7 @@
   final bool insertReplaceCompletionRanges;
   final bool definitionLocationLink;
   final bool hierarchicalSymbols;
+  final bool diagnosticCodeDescription;
   final Set<CodeActionKind> codeActionKinds;
   final Set<CompletionItemTag> completionItemTags;
   final Set<DiagnosticTag> diagnosticTags;
@@ -115,6 +116,9 @@
         hierarchicalSymbols = raw.textDocument?.documentSymbol
                 ?.hierarchicalDocumentSymbolSupport ??
             false,
+        diagnosticCodeDescription =
+            raw.textDocument?.publishDiagnostics?.codeDescriptionSupport ??
+                false,
         hoverContentFormats = _hoverContentFormats(raw),
         insertReplaceCompletionRanges = raw.textDocument?.completion
                 ?.completionItem?.insertReplaceSupport ??
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
index b428985..2485b8b 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
@@ -321,6 +321,8 @@
             unit,
             error,
             supportedTags: supportedDiagnosticTags,
+            clientSupportsCodeDescription:
+                server.clientCapabilities?.diagnosticCodeDescription ?? false,
           );
           codeActions.addAll(
             fixes.map((fix) => _createFixAction(fix, diagnostic)),
diff --git a/pkg/analysis_server/lib/src/lsp/mapping.dart b/pkg/analysis_server/lib/src/lsp/mapping.dart
index 84a8767..175033d 100644
--- a/pkg/analysis_server/lib/src/lsp/mapping.dart
+++ b/pkg/analysis_server/lib/src/lsp/mapping.dart
@@ -707,6 +707,7 @@
   server.LineInfo Function(String) getLineInfo,
   plugin.AnalysisError error, {
   required Set<lsp.DiagnosticTag>? supportedTags,
+  required bool clientSupportsCodeDescription,
 }) {
   List<lsp.DiagnosticRelatedInformation>? relatedInformation;
   final contextMessages = error.contextMessages;
@@ -724,6 +725,7 @@
   }
 
   var lineInfo = getLineInfo(error.location.file);
+  var documentationUrl = error.url;
   return lsp.Diagnostic(
     range: toRange(lineInfo, error.location.offset, error.location.length),
     severity: pluginToDiagnosticSeverity(error.severity),
@@ -732,6 +734,11 @@
     message: message,
     tags: getDiagnosticTags(supportedTags, error),
     relatedInformation: relatedInformation,
+    // Only include codeDescription if the client explicitly supports it
+    // (a minor optimization to avoid unnecessary payload/(de)serialisation).
+    codeDescription: clientSupportsCodeDescription && documentationUrl != null
+        ? CodeDescription(href: documentationUrl)
+        : null,
   );
 }
 
@@ -1006,10 +1013,15 @@
   server.ResolvedUnitResult result,
   server.AnalysisError error, {
   required Set<lsp.DiagnosticTag> supportedTags,
-}) =>
-    pluginToDiagnostic((_) => result.lineInfo,
-        server.newAnalysisError_fromEngine(result, error),
-        supportedTags: supportedTags);
+  required bool clientSupportsCodeDescription,
+}) {
+  return pluginToDiagnostic(
+    (_) => result.lineInfo,
+    server.newAnalysisError_fromEngine(result, error),
+    supportedTags: supportedTags,
+    clientSupportsCodeDescription: clientSupportsCodeDescription,
+  );
+}
 
 lsp.Element toElement(server.LineInfo lineInfo, server.Element element) {
   final location = element.location;
diff --git a/pkg/analysis_server/lib/src/lsp/notification_manager.dart b/pkg/analysis_server/lib/src/lsp/notification_manager.dart
index 6afaeec..8f38df1 100644
--- a/pkg/analysis_server/lib/src/lsp/notification_manager.dart
+++ b/pkg/analysis_server/lib/src/lsp/notification_manager.dart
@@ -35,6 +35,8 @@
               (path) => server.getLineInfo(path)!,
               error,
               supportedTags: server.clientCapabilities?.diagnosticTags,
+              clientSupportsCodeDescription:
+                  server.clientCapabilities?.diagnosticCodeDescription ?? false,
             ))
         .toList();
 
diff --git a/pkg/analysis_server/test/lsp/diagnostic_test.dart b/pkg/analysis_server/test/lsp/diagnostic_test.dart
index 73b227a..0f7ecf1 100644
--- a/pkg/analysis_server/test/lsp/diagnostic_test.dart
+++ b/pkg/analysis_server/test/lsp/diagnostic_test.dart
@@ -223,6 +223,41 @@
     expect(diagnostic.tags, contains(DiagnosticTag.Unnecessary));
   }
 
+  Future<void> test_documentationUrl() async {
+    newFile(mainFilePath, content: '''
+    // ignore: unused_import
+    import 'dart:async' as import; // produces BUILT_IN_IDENTIFIER_IN_DECLARATION
+    ''');
+
+    final diagnosticsUpdate = waitForDiagnostics(mainFileUri);
+    await initialize(
+        textDocumentCapabilities: withDiagnosticCodeDescriptionSupport(
+            emptyTextDocumentClientCapabilities));
+    final diagnostics = await diagnosticsUpdate;
+    expect(diagnostics, hasLength(1));
+    final diagnostic = diagnostics!.first;
+    expect(diagnostic.code, equals('built_in_identifier_in_declaration'));
+    expect(
+      diagnostic.codeDescription!.href,
+      equals('https://dart.dev/diagnostics/built_in_identifier_in_declaration'),
+    );
+  }
+
+  Future<void> test_documentationUrl_notSupported() async {
+    newFile(mainFilePath, content: '''
+    // ignore: unused_import
+    import 'dart:async' as import; // produces BUILT_IN_IDENTIFIER_IN_DECLARATION
+    ''');
+
+    final diagnosticsUpdate = waitForDiagnostics(mainFileUri);
+    await initialize();
+    final diagnostics = await diagnosticsUpdate;
+    expect(diagnostics, hasLength(1));
+    final diagnostic = diagnostics!.first;
+    expect(diagnostic.code, equals('built_in_identifier_in_declaration'));
+    expect(diagnostic.codeDescription, isNull);
+  }
+
   Future<void> test_dotFilesExcluded() async {
     var dotFolderFilePath =
         join(projectFolderPath, '.dart_tool', 'tool_file.dart');
diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart
index 721ab0f..15895e2 100644
--- a/pkg/analysis_server/test/lsp/server_abstract.dart
+++ b/pkg/analysis_server/test/lsp/server_abstract.dart
@@ -371,6 +371,16 @@
     return extendWorkspaceCapabilities(source, {'configuration': true});
   }
 
+  TextDocumentClientCapabilities withDiagnosticCodeDescriptionSupport(
+    TextDocumentClientCapabilities source,
+  ) {
+    return extendTextDocumentCapabilities(source, {
+      'publishDiagnostics': {
+        'codeDescriptionSupport': true,
+      }
+    });
+  }
+
   TextDocumentClientCapabilities withDiagnosticTagSupport(
     TextDocumentClientCapabilities source,
     List<DiagnosticTag> tags,
diff --git a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
index 0de0c57..b05ab3d 100644
--- a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
+++ b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
@@ -175,6 +175,7 @@
 
     // Check the inferred types against all of the constraints.
     var knownTypes = <TypeParameterElement, DartType>{};
+    var hasErrorReported = false;
     for (int i = 0; i < typeFormals.length; i++) {
       TypeParameterElement parameter = typeFormals[i];
       var constraints = _constraints[parameter]!;
@@ -204,6 +205,7 @@
 
       if (!success) {
         if (failAtError) return null;
+        hasErrorReported = true;
         errorReporter?.reportErrorForNode(
             CompileTimeErrorCode.COULD_NOT_INFER,
             errorNode!,
@@ -220,6 +222,7 @@
           !genericMetadataIsEnabled &&
           errorReporter != null) {
         if (failAtError) return null;
+        hasErrorReported = true;
         var typeFormals = inferred.typeFormals;
         var typeFormalsStr = typeFormals.map(_elementStr).join(', ');
         errorReporter.reportErrorForNode(
@@ -255,6 +258,7 @@
     for (int i = 0; i < hasError.length; i++) {
       if (hasError[i]) {
         if (failAtError) return null;
+        hasErrorReported = true;
         TypeParameterElement typeParam = typeFormals[i];
         var typeParamBound = Substitution.fromPairs(typeFormals, inferredTypes)
             .substituteType(typeParam.bound ?? typeProvider.objectType);
@@ -269,6 +273,15 @@
       }
     }
 
+    if (!hasErrorReported) {
+      _checkArgumentsNotMatchingBounds(
+        errorNode: errorNode,
+        errorReporter: errorReporter,
+        typeParameters: typeFormals,
+        typeArguments: result,
+      );
+    }
+
     _nonNullifyTypes(result);
     return result;
   }
@@ -305,6 +318,41 @@
     return success;
   }
 
+  /// Check that inferred [typeArguments] satisfy the [typeParameters] bounds.
+  void _checkArgumentsNotMatchingBounds({
+    required AstNode? errorNode,
+    required ErrorReporter? errorReporter,
+    required List<TypeParameterElement> typeParameters,
+    required List<DartType> typeArguments,
+  }) {
+    for (int i = 0; i < typeParameters.length; i++) {
+      var parameter = typeParameters[i];
+      var argument = typeArguments[i];
+
+      var rawBound = parameter.bound;
+      if (rawBound == null) {
+        continue;
+      }
+      rawBound = _typeSystem.toLegacyTypeIfOptOut(rawBound);
+
+      var substitution = Substitution.fromPairs(typeParameters, typeArguments);
+      var bound = substitution.substituteType(rawBound);
+      if (!_typeSystem.isSubtypeOf(argument, bound)) {
+        errorReporter?.reportErrorForNode(
+          CompileTimeErrorCode.COULD_NOT_INFER,
+          errorNode!,
+          [
+            parameter.name,
+            "\n'${_typeStr(argument)}' doesn't conform to "
+                "the bound '${_typeStr(bound)}'"
+                ", instantiated from '${_typeStr(rawBound)}'"
+                " using type arguments ${typeArguments.map(_typeStr).toList()}.",
+          ],
+        );
+      }
+    }
+  }
+
   /// Choose the bound that was implied by the return type, if any.
   ///
   /// Which bound this is depends on what positions the type parameter
diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart
index 6e82d71..a299c7d 100644
--- a/pkg/analyzer/lib/src/dart/element/type_system.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_system.dart
@@ -1473,6 +1473,15 @@
     return NullabilityEliminator.perform(typeProvider, type);
   }
 
+  /// If a legacy library, return the legacy version of the [type].
+  /// Otherwise, return the original type.
+  DartType toLegacyTypeIfOptOut(DartType type) {
+    if (isNonNullableByDefault) {
+      return type;
+    }
+    return NullabilityEliminator.perform(typeProvider, type);
+  }
+
   /// Merges two types into a single type.
   /// Compute the canonical representation of [T].
   ///
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index 304d7be..4c0a264 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -1201,6 +1201,7 @@
       CompileTimeErrorCode('BUILT_IN_IDENTIFIER_IN_DECLARATION',
           "The built-in identifier '{0}' can't be used as a prefix name.",
           correction: "Try choosing a different name for the prefix.",
+          hasPublishedDocs: true,
           uniqueName: 'BUILT_IN_IDENTIFIER_AS_PREFIX_NAME');
 
   /**
@@ -1242,6 +1243,7 @@
       CompileTimeErrorCode('BUILT_IN_IDENTIFIER_IN_DECLARATION',
           "The built-in identifier '{0}' can't be used as a type name.",
           correction: "Try choosing a different name for the type.",
+          hasPublishedDocs: true,
           uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPE_NAME');
 
   /**
@@ -1254,6 +1256,7 @@
           "The built-in identifier '{0}' can't be used as a type parameter "
               "name.",
           correction: "Try choosing a different name for the type parameter.",
+          hasPublishedDocs: true,
           uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME');
 
   /**
@@ -1264,6 +1267,7 @@
       CompileTimeErrorCode('BUILT_IN_IDENTIFIER_IN_DECLARATION',
           "The built-in identifier '{0}' can't be used as a typedef name.",
           correction: "Try choosing a different name for the typedef.",
+          hasPublishedDocs: true,
           uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME');
 
   /**
diff --git a/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart b/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart
index 611cdb6..40b9bce 100644
--- a/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart
@@ -114,6 +114,20 @@
 ''');
   }
 
+  test_functionType_instantiatedToBounds() async {
+    await assertErrorsInCode(r'''
+class A<X extends A<X>> {}
+
+void foo<X extends Y, Y extends A<X>>() {}
+
+void f() {
+  foo();
+}
+''', [
+      error(CompileTimeErrorCode.COULD_NOT_INFER, 85, 3),
+    ]);
+  }
+
   test_functionType_parameterIsBound_returnIsBound() async {
     await assertNoErrorsInCode(r'''
 external T f<T extends num>(T a, T b);
diff --git a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
index c7e325a..be9a558 100644
--- a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
@@ -239,9 +239,32 @@
     return null;
   }
 
-  // TODO(johnniwinther): Store [origin] on the built type.
+  @override
   DartType build(LibraryBuilder library,
       [TypedefType origin, bool notInstanceContext]) {
+    return buildInternal(library, origin, notInstanceContext, false);
+  }
+
+  @override
+  DartType buildTypeLiteralType(LibraryBuilder library,
+      [TypedefType origin, bool notInstanceContext]) {
+    return buildInternal(library, origin, notInstanceContext, true);
+  }
+
+  DartType declarationBuildType(
+      LibraryBuilder library, bool notInstanceContext, bool forTypeLiteral) {
+    if (forTypeLiteral) {
+      return declaration.buildTypeLiteralType(
+          library, nullabilityBuilder, arguments, notInstanceContext);
+    } else {
+      return declaration.buildType(
+          library, nullabilityBuilder, arguments, notInstanceContext);
+    }
+  }
+
+  // TODO(johnniwinther): Store [origin] on the built type.
+  DartType buildInternal(LibraryBuilder library,
+      [TypedefType origin, bool notInstanceContext, bool forTypeLiteral]) {
     assert(declaration != null, "Declaration has not been resolved on $this.");
     if (notInstanceContext == true && declaration.isTypeVariable) {
       TypeVariableBuilder typeParameterBuilder = declaration;
@@ -258,8 +281,8 @@
 
     if (library is SourceLibraryBuilder) {
       int uncheckedTypedefTypeCount = library.uncheckedTypedefTypes.length;
-      DartType builtType = declaration.buildType(
-          library, nullabilityBuilder, arguments, notInstanceContext);
+      DartType builtType =
+          declarationBuildType(library, notInstanceContext, forTypeLiteral);
       // Set locations for new unchecked TypedefTypes for error reporting.
       for (int i = uncheckedTypedefTypeCount;
           i < library.uncheckedTypedefTypes.length;
@@ -270,8 +293,7 @@
       }
       return builtType;
     } else {
-      return declaration.buildType(
-          library, nullabilityBuilder, arguments, notInstanceContext);
+      return declarationBuildType(library, notInstanceContext, forTypeLiteral);
     }
   }
 
diff --git a/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart
index 871917c..c5bf0a1 100644
--- a/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/type_alias_builder.dart
@@ -8,9 +8,9 @@
 
 import 'package:kernel/ast.dart';
 import 'package:kernel/core_types.dart';
+import 'package:kernel/src/legacy_erasure.dart';
 
 import 'package:kernel/type_algebra.dart' show substitute, uniteNullabilities;
-import 'package:kernel/src/legacy_erasure.dart';
 
 import '../fasta_codes.dart'
     show
@@ -158,6 +158,21 @@
   DartType buildType(LibraryBuilder library,
       NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
       [bool notInstanceContext]) {
+    return buildTypeInternal(
+        library, nullabilityBuilder, arguments, notInstanceContext, true);
+  }
+
+  @override
+  DartType buildTypeLiteralType(LibraryBuilder library,
+      NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
+      [bool notInstanceContext]) {
+    return buildTypeInternal(
+        library, nullabilityBuilder, arguments, notInstanceContext, false);
+  }
+
+  DartType buildTypeInternal(LibraryBuilder library,
+      NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
+      [bool notInstanceContext, bool performLegacyErasure]) {
     DartType thisType = buildThisType();
     if (thisType is InvalidType) return thisType;
 
@@ -184,7 +199,7 @@
       result = buildTypesWithBuiltArguments(
           library, nullability, buildTypeArguments(library, arguments));
     }
-    if (!library.isNonNullableByDefault) {
+    if (performLegacyErasure && !library.isNonNullableByDefault) {
       result = legacyErasure(result);
     }
     return result;
diff --git a/pkg/front_end/lib/src/fasta/builder/type_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_builder.dart
index 57fbc8e..38ca1a7 100644
--- a/pkg/front_end/lib/src/fasta/builder/type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/type_builder.dart
@@ -72,6 +72,11 @@
   DartType build(LibraryBuilder library,
       [TypedefType origin, bool notInstanceContext]);
 
+  DartType buildTypeLiteralType(LibraryBuilder library,
+      [TypedefType origin, bool notInstanceContext]) {
+    return build(library, origin, notInstanceContext);
+  }
+
   Supertype buildSupertype(LibraryBuilder library, int charOffset, Uri fileUri);
 
   Supertype buildMixedInType(
diff --git a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
index cdfac5c..6490a73 100644
--- a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart
@@ -28,6 +28,10 @@
       NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
       [bool notInstanceContext]);
 
+  DartType buildTypeLiteralType(LibraryBuilder library,
+      NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
+      [bool notInstanceContext]);
+
   /// [arguments] have already been built.
   DartType buildTypesWithBuiltArguments(LibraryBuilder library,
       Nullability nullability, List<DartType> arguments);
@@ -61,4 +65,12 @@
 
   @override
   int get typeVariablesCount => 0;
+
+  @override
+  DartType buildTypeLiteralType(LibraryBuilder library,
+      NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments,
+      [bool notInstanceContext]) {
+    return buildType(
+        library, nullabilityBuilder, arguments, notInstanceContext);
+  }
 }
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 2336024..716581a 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -6581,6 +6581,18 @@
   }
 
   @override
+  DartType buildTypeLiteralDartType(UnresolvedType unresolvedType,
+      {bool nonInstanceAccessIsError: false,
+      bool allowPotentiallyConstantType: false}) {
+    if (unresolvedType == null) return null;
+    return validateTypeUse(unresolvedType,
+            nonInstanceAccessIsError: nonInstanceAccessIsError,
+            allowPotentiallyConstantType: allowPotentiallyConstantType)
+        .builder
+        ?.buildTypeLiteralType(libraryBuilder);
+  }
+
+  @override
   List<DartType> buildDartTypeArguments(List<UnresolvedType> unresolvedTypes) {
     if (unresolvedTypes == null) return <DartType>[];
     List<DartType> types =
diff --git a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
index 1efc687..e931ccc 100644
--- a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
@@ -3043,7 +3043,7 @@
       } else {
         super.expression = _forest.createTypeLiteral(
             offsetForToken(token),
-            _helper.buildDartType(
+            _helper.buildTypeLiteralDartType(
                 new UnresolvedType(
                     buildTypeWithResolvedArguments(
                         _helper.libraryBuilder.nonNullableBuilder,
diff --git a/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart b/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart
index 2faf2ed..b333c17 100644
--- a/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart
@@ -154,6 +154,9 @@
   DartType buildDartType(UnresolvedType unresolvedType,
       {bool nonInstanceAccessIsError});
 
+  DartType buildTypeLiteralDartType(UnresolvedType unresolvedType,
+      {bool nonInstanceAccessIsError});
+
   List<DartType> buildDartTypeArguments(List<UnresolvedType> unresolvedTypes);
 
   void reportDuplicatedDeclaration(
diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
index d8265a8..cb1d27c 100644
--- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
@@ -575,10 +575,8 @@
       ConstructorInvocation node, DartType typeContext) {
     inferrer.inferConstructorParameterTypes(node.target);
     bool hadExplicitTypeArguments = hasExplicitTypeArguments(node.arguments);
-    FunctionType functionType = replaceReturnType(
-        node.target.function
-            .computeThisFunctionType(inferrer.library.nonNullable),
-        computeConstructorReturnType(node.target, inferrer.coreTypes));
+    FunctionType functionType = node.target.function
+        .computeThisFunctionType(inferrer.library.nonNullable);
     InvocationInferenceResult result = inferrer.inferInvocation(
         typeContext, node.fileOffset, functionType, node.arguments,
         isConst: node.isConst, staticTarget: node.target);
@@ -864,10 +862,8 @@
       FactoryConstructorInvocationJudgment node, DartType typeContext) {
     bool hadExplicitTypeArguments = hasExplicitTypeArguments(node.arguments);
 
-    FunctionType functionType = replaceReturnType(
-        node.target.function
-            .computeThisFunctionType(inferrer.library.nonNullable),
-        computeConstructorReturnType(node.target, inferrer.coreTypes));
+    FunctionType functionType = node.target.function
+        .computeThisFunctionType(inferrer.library.nonNullable);
 
     InvocationInferenceResult result = inferrer.inferInvocation(
         typeContext, node.fileOffset, functionType, node.arguments,
diff --git a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
index 46afae9..55b2d8d 100644
--- a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
@@ -21,7 +21,6 @@
 /// with the same kind of root node.
 
 import 'package:kernel/ast.dart';
-import 'package:kernel/core_types.dart';
 import 'package:kernel/src/printer.dart';
 import 'package:kernel/text/ast_to_text.dart' show Precedence, Printer;
 import 'package:kernel/type_environment.dart';
@@ -44,17 +43,6 @@
 
 import 'inference_visitor.dart';
 
-/// Computes the return type of a (possibly factory) constructor.
-InterfaceType computeConstructorReturnType(
-    Member constructor, CoreTypes coreTypes) {
-  if (constructor is Constructor) {
-    return coreTypes.thisInterfaceType(
-        constructor.enclosingClass, constructor.enclosingLibrary.nonNullable);
-  } else {
-    return constructor.function.returnType;
-  }
-}
-
 int getExtensionTypeParameterCount(Arguments arguments) {
   if (arguments is ArgumentsImpl) {
     return arguments._extensionTypeParameterCount;
diff --git a/pkg/front_end/testcases/nnbd_mixed/issue46518.dart b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart
new file mode 100644
index 0000000..8e1bf6a
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// @dart=2.8
+
+import "./issue46518_lib.dart";
+
+void main() {
+  checkOptedIn(NullableIntF);
+}
diff --git a/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.textual_outline.expect b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.textual_outline.expect
new file mode 100644
index 0000000..f0067cd
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.textual_outline.expect
@@ -0,0 +1,4 @@
+// @dart = 2.8
+import "./issue46518_lib.dart";
+
+void main() {}
diff --git a/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..f0067cd
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.textual_outline_modelled.expect
@@ -0,0 +1,4 @@
+// @dart = 2.8
+import "./issue46518_lib.dart";
+
+void main() {}
diff --git a/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.expect b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.expect
new file mode 100644
index 0000000..c718f8d
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.expect
@@ -0,0 +1,27 @@
+library;
+import self as self;
+import "issue46518_lib.dart" as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue46518_lib.dart";
+
+static method main() → void {
+  iss::checkOptedIn(#C1);
+}
+
+library /*isNonNullableByDefault*/;
+import self as iss;
+import "dart:core" as core;
+
+typedef NullableIntF = () → core::int?;
+static method _check(core::Type t1, core::Type t2) → void {
+  core::print("Opted in: identical(${t1}, ${t2}) == ${core::identical(t1, t2)}");
+  core::print("Opted in: (${t1} == ${t2}) == ${t1 =={core::Type::==}{(core::Object) → core::bool} t2}");
+}
+static method checkOptedIn(core::Type t) → void {
+  iss::_check(t, #C1);
+}
+
+constants  {
+  #C1 = TypeLiteralConstant(() →* core::int?)
+}
diff --git a/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.outline.expect b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.outline.expect
new file mode 100644
index 0000000..688aa25
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.outline.expect
@@ -0,0 +1,17 @@
+library;
+import self as self;
+
+import "org-dartlang-testcase:///issue46518_lib.dart";
+
+static method main() → void
+  ;
+
+library /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:core" as core;
+
+typedef NullableIntF = () → core::int?;
+static method _check(core::Type t1, core::Type t2) → void
+  ;
+static method checkOptedIn(core::Type t) → void
+  ;
diff --git a/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.transformed.expect b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.transformed.expect
new file mode 100644
index 0000000..c718f8d
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd_mixed/issue46518.dart.weak.transformed.expect
@@ -0,0 +1,27 @@
+library;
+import self as self;
+import "issue46518_lib.dart" as iss;
+import "dart:core" as core;
+
+import "org-dartlang-testcase:///issue46518_lib.dart";
+
+static method main() → void {
+  iss::checkOptedIn(#C1);
+}
+
+library /*isNonNullableByDefault*/;
+import self as iss;
+import "dart:core" as core;
+
+typedef NullableIntF = () → core::int?;
+static method _check(core::Type t1, core::Type t2) → void {
+  core::print("Opted in: identical(${t1}, ${t2}) == ${core::identical(t1, t2)}");
+  core::print("Opted in: (${t1} == ${t2}) == ${t1 =={core::Type::==}{(core::Object) → core::bool} t2}");
+}
+static method checkOptedIn(core::Type t) → void {
+  iss::_check(t, #C1);
+}
+
+constants  {
+  #C1 = TypeLiteralConstant(() →* core::int?)
+}
diff --git a/pkg/front_end/testcases/nnbd_mixed/issue46518_lib.dart b/pkg/front_end/testcases/nnbd_mixed/issue46518_lib.dart
new file mode 100644
index 0000000..51a3a3d
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd_mixed/issue46518_lib.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+typedef NullableIntF = int? Function();
+
+void _check(Type t1, Type t2) {
+  print("Opted in: identical($t1, $t2) == ${identical(t1, t2)}");
+  print("Opted in: ($t1 == $t2) == ${t1 == t2}");
+}
+
+void checkOptedIn(Type t) {
+  _check(t, NullableIntF);
+}
diff --git a/tests/standalone/package/scenarios/invalid/invalid_package_name_test.dart b/tests/standalone/package/scenarios/invalid/invalid_package_name_test.dart
index 4c278c9..a2891b8 100644
--- a/tests/standalone/package/scenarios/invalid/invalid_package_name_test.dart
+++ b/tests/standalone/package/scenarios/invalid/invalid_package_name_test.dart
@@ -7,6 +7,8 @@
 library invalid_package_name_test;
 
 import 'package:foo/foo.dart' as foo;
+//     ^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.URI_DOES_NOT_EXIST
 
 main() {
   if (foo.foo != 'foo') {
diff --git a/tests/standalone/package/scenarios/invalid/same_package_twice_test.dart b/tests/standalone/package/scenarios/invalid/same_package_twice_test.dart
index acedb40..2add511 100644
--- a/tests/standalone/package/scenarios/invalid/same_package_twice_test.dart
+++ b/tests/standalone/package/scenarios/invalid/same_package_twice_test.dart
@@ -7,5 +7,7 @@
 library same_package_twice_test;
 
 import 'package:foo/foo.dart' as foo;
+//     ^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.URI_DOES_NOT_EXIST
 
 main() {}
diff --git a/tests/standalone_2/package/scenarios/invalid/invalid_package_name_test.dart b/tests/standalone_2/package/scenarios/invalid/invalid_package_name_test.dart
index 36945794..cf9da8a 100644
--- a/tests/standalone_2/package/scenarios/invalid/invalid_package_name_test.dart
+++ b/tests/standalone_2/package/scenarios/invalid/invalid_package_name_test.dart
@@ -9,6 +9,8 @@
 library invalid_package_name_test;
 
 import 'package:foo/foo.dart' as foo;
+//     ^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.URI_DOES_NOT_EXIST
 
 main() {
   if (foo.foo != 'foo') {
diff --git a/tests/standalone_2/package/scenarios/invalid/same_package_twice_test.dart b/tests/standalone_2/package/scenarios/invalid/same_package_twice_test.dart
index 5d9a24e..75d93d9 100644
--- a/tests/standalone_2/package/scenarios/invalid/same_package_twice_test.dart
+++ b/tests/standalone_2/package/scenarios/invalid/same_package_twice_test.dart
@@ -9,5 +9,8 @@
 library same_package_twice_test;
 
 import 'package:foo/foo.dart' as foo;
+//     ^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.URI_DOES_NOT_EXIST
+// [cfe] unspecified
 
 main() {}
diff --git a/tools/VERSION b/tools/VERSION
index 1867946..b8b0fea 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 14
 PATCH 0
-PRERELEASE 268
+PRERELEASE 269
 PRERELEASE_PATCH 0
\ No newline at end of file