Version 2.17.0-57.0.dev
Merge commit 'e3a2e59f18d667978c1ed65be6ad3f70e938a369' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart
index d814bb5..8bbff4f 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart
@@ -92,7 +92,7 @@
}
extensionContributor.addExtensions(
- exportElements.whereType<ExtensionElement>().toList(),
+ _extensions(exportElements),
);
builder.isNotImportedLibrary = false;
@@ -109,4 +109,17 @@
}
}
}
+
+ /// This function intentionally does not use `whereType` for performance.
+ ///
+ /// https://github.com/dart-lang/sdk/issues/47680
+ static List<ExtensionElement> _extensions(List<Element> elements) {
+ var extensions = <ExtensionElement>[];
+ for (var element in elements) {
+ if (element is ExtensionElement) {
+ extensions.add(element);
+ }
+ }
+ return extensions;
+ }
}
diff --git a/pkg/analyzer/lib/src/dart/ast/extensions.dart b/pkg/analyzer/lib/src/dart/ast/extensions.dart
index 7788785..3df6b5d 100644
--- a/pkg/analyzer/lib/src/dart/ast/extensions.dart
+++ b/pkg/analyzer/lib/src/dart/ast/extensions.dart
@@ -76,6 +76,21 @@
return null;
}
+extension AstNodeNullableExtension on AstNode? {
+ List<ClassMember> get classMembers {
+ final self = this;
+ if (self is ClassOrMixinDeclaration) {
+ return self.members;
+ } else if (self is EnumDeclaration) {
+ return self.members;
+ } else if (self is ExtensionDeclaration) {
+ return self.members;
+ } else {
+ throw UnimplementedError('(${self.runtimeType}) $self');
+ }
+ }
+}
+
extension ConstructorDeclarationExtension on ConstructorDeclaration {
bool get isNonRedirectingGenerative {
// Must be generative.
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index bcbe8fa..9af29c4 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -103,8 +103,7 @@
if (constKeyword != null) {
_validateConstructorInitializers(node);
if (node.factoryKeyword == null) {
- _validateFieldInitializers(
- node.parent as ClassOrMixinDeclaration, constKeyword);
+ _validateFieldInitializers(node.parent.classMembers, constKeyword);
}
}
_validateDefaultValues(node.parameters);
@@ -545,12 +544,11 @@
}
/// Validates that the expressions of any field initializers in
- /// [classDeclaration] are all compile-time constants. Since this is only
+ /// [members] are all compile-time constants. Since this is only
/// required if the class has a constant constructor, the error is reported at
/// [constKeyword], the const keyword on such a constant constructor.
void _validateFieldInitializers(
- ClassOrMixinDeclaration classDeclaration, Token constKeyword) {
- NodeList<ClassMember> members = classDeclaration.members;
+ List<ClassMember> members, Token constKeyword) {
for (ClassMember member in members) {
if (member is FieldDeclaration && !member.isStatic) {
for (VariableDeclaration variableDeclaration
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 56a90a4..9176c6e 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -202,11 +202,7 @@
/// The class containing the AST nodes being visited, or `null` if we are not
/// in the scope of a class.
- ClassElementImpl? _enclosingClass;
-
- /// The enum containing the AST nodes being visited, or `null` if we are not
- /// in the scope of an enum.
- ClassElement? _enclosingEnum;
+ ClassElement? _enclosingClass;
/// The element of the extension being visited, or `null` if we are not
/// in the scope of an extension.
@@ -281,11 +277,8 @@
/// should not be modified in the middle of visiting a tree and requires an
/// analyzer-provided Impl instance to work.
set enclosingClass(ClassElement? classElement) {
- assert(classElement is ClassElementImpl);
assert(_enclosingClass == null);
- assert(_enclosingEnum == null);
assert(_enclosingExecutable.element == null);
- _enclosingClass = classElement as ClassElementImpl;
}
/// The language team is thinking about adding abstract fields, or external
@@ -563,13 +556,13 @@
@override
void visitEnumDeclaration(EnumDeclaration node) {
- var outerEnum = _enclosingEnum;
+ var outerClass = _enclosingClass;
try {
- _enclosingEnum = node.declaredElement;
+ _enclosingClass = node.declaredElement;
_duplicateDefinitionVerifier.checkEnum(node);
super.visitEnumDeclaration(node);
} finally {
- _enclosingEnum = outerEnum;
+ _enclosingClass = outerClass;
}
}
@@ -4408,9 +4401,6 @@
if (identical(enclosingElement, _enclosingClass)) {
return;
}
- if (identical(enclosingElement, _enclosingEnum)) {
- return;
- }
if (enclosingElement is! ClassElement) {
return;
}
diff --git a/tools/VERSION b/tools/VERSION
index 5d43e34..9c19b90 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 56
+PRERELEASE 57
PRERELEASE_PATCH 0
\ No newline at end of file