Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 2189783002: Record names of classes which unnamed constructor are used in SuperConstructorInvocation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index 029f11c3d31a45e2725dcee8b50cb6eb7a93be11..0d3981fc0ac5644d66a19b8116525163e7186209 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -2656,6 +2656,15 @@ class DartDelta extends Delta {
}
}
}
+ for (String name in references.extendedUsedUnnamedConstructorNames) {
+ for (ClassElementDelta classDelta in changedClasses.values) {
+ if (classDelta.name == name && classDelta.hasUnnamedConstructorChange) {
+ _log(() =>
+ '$refLibrary is affected by the default constructor of $name');
+ return true;
+ }
+ }
+ }
return false;
}
@@ -4788,6 +4797,13 @@ class ReferencedNames {
final Map<String, Set<String>> superToSubs = <String, Set<String>>{};
/**
+ * The names of extended classes for which the unnamed constructor is
+ * invoked. Because we cannot use the name of the constructor to identify
+ * whether the unit is affected, we need to use the class name.
+ */
+ final Set<String> extendedUsedUnnamedConstructorNames = new Set<String>();
+
+ /**
* The names of instantiated classes.
*
* If one of these classes changes its set of members, it might change
@@ -4823,6 +4839,7 @@ class ReferencedNamesBuilder extends GeneralizingAstVisitor {
final Set<String> importPrefixNames = new Set<String>();
final ReferencedNames names;
+ String enclosingSuperClassName;
ReferencedNamesScope scope = new ReferencedNamesScope(null);
int localLevel = 0;
@@ -4852,6 +4869,8 @@ class ReferencedNamesBuilder extends GeneralizingAstVisitor {
try {
scope = new ReferencedNamesScope.forClass(scope, node);
dependsOn = new Set<String>();
+ enclosingSuperClassName =
+ _getSimpleName(node.extendsClause?.superclass?.name);
super.visitClassDeclaration(node);
String className = node.name.name;
names.userToDependsOn[className] = dependsOn;
@@ -4859,11 +4878,22 @@ class ReferencedNamesBuilder extends GeneralizingAstVisitor {
_addSuperNames(className, node.withClause?.mixinTypes);
_addSuperNames(className, node.implementsClause?.interfaces);
} finally {
+ enclosingSuperClassName = null;
dependsOn = null;
scope = outerScope;
}
}
+ static String _getSimpleName(Identifier identifier) {
+ if (identifier is SimpleIdentifier) {
+ return identifier.name;
+ }
+ if (identifier is PrefixedIdentifier) {
+ return identifier.identifier.name;
+ }
+ return null;
+ }
+
@override
visitClassTypeAlias(ClassTypeAlias node) {
ReferencedNamesScope outerScope = scope;
@@ -4893,6 +4923,14 @@ class ReferencedNamesBuilder extends GeneralizingAstVisitor {
}
@override
+ visitSuperConstructorInvocation(SuperConstructorInvocation node) {
+ if (node.constructorName == null && enclosingSuperClassName != null) {
+ names.extendedUsedUnnamedConstructorNames.add(enclosingSuperClassName);
+ }
+ super.visitSuperConstructorInvocation(node);
+ }
+
+ @override
visitConstructorName(ConstructorName node) {
if (node.parent is! ConstructorDeclaration) {
super.visitConstructorName(node);
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/context_test.dart » ('j') | pkg/analyzer/test/src/context/context_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698