Version 2.15.0-40.0.dev

Merge commit '86c660faaa21302d8bf4a0c36428cd19c0e50c9d' into 'dev'
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 3ad6c31..1e652a3 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -2809,8 +2809,12 @@
     var lateKeyword = variableList.lateKeyword;
     if (lateKeyword == null) return;
 
-    var hasConstConstructor =
-        _enclosingClass!.constructors.any((c) => c.isConst);
+    var enclosingClass = _enclosingClass;
+    if (enclosingClass == null) {
+      // The field is in an extension and should handled elsewhere.
+      return;
+    }
+    var hasConstConstructor = enclosingClass.constructors.any((c) => c.isConst);
     if (!hasConstConstructor) return;
 
     errorReporter.reportErrorForToken(
diff --git a/pkg/analyzer/test/src/diagnostics/late_final_field_with_const_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/late_final_field_with_const_constructor_test.dart
index 4b0b9ba..17cf219 100644
--- a/pkg/analyzer/test/src/diagnostics/late_final_field_with_const_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/late_final_field_with_const_constructor_test.dart
@@ -2,6 +2,7 @@
 // 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.
 
+import 'package:analyzer/src/dart/error/syntactic_errors.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -69,4 +70,18 @@
 }
 ''');
   }
+
+  test_inExtension() async {
+    // https://github.com/dart-lang/sdk/issues/46952
+    // This test is here because the code that tests for
+    // LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR is where the referenced issue was
+    // caused.
+    await assertErrorsInCode('''
+extension E on int {
+  late final int i;
+}
+''', [
+      error(ParserErrorCode.EXTENSION_DECLARES_INSTANCE_FIELD, 38, 1),
+    ]);
+  }
 }
diff --git a/tools/VERSION b/tools/VERSION
index 66d255d..b004d65 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 15
 PATCH 0
-PRERELEASE 39
+PRERELEASE 40
 PRERELEASE_PATCH 0
\ No newline at end of file