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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_common.dart

Issue 2668423003: Fix for resynthesizing with multiply defined names. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « pkg/analyzer/test/src/dart/analysis/driver_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/resynthesize_common.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index fe240388518e0cc566f4fca89cc2f02a4f466ccc..213577ac7d858e1a802b4d16a7ec8fcb2724da8a 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -43,6 +43,11 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
Set<String> variablesWithNotConstInitializers = new Set<String>();
/**
+ * Names that cannot be resolved, e.g. because of duplicate declaration.
+ */
+ Set<String> namesThatCannotBeResolved = new Set<String>();
+
+ /**
* Tests may set this to `true` to indicate that a missing file at the time of
* summary resynthesis shouldn't trigger an error.
*/
@@ -381,7 +386,11 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
compareConstAsts(r, o.expression, desc);
} else if (o is SimpleIdentifier && r is SimpleIdentifier) {
expect(r.name, o.name, reason: desc);
- compareElements(r.staticElement, o.staticElement, desc);
+ if (namesThatCannotBeResolved.contains(r.name)) {
+ expect(r.staticElement, isNull);
+ } else {
+ compareElements(r.staticElement, o.staticElement, desc);
+ }
} else if (o is PrefixedIdentifier && r is SimpleIdentifier) {
// We don't resynthesize prefixed identifiers when the prefix refers to
// a PrefixElement or a ClassElement. We use simple identifiers with
@@ -3900,6 +3909,42 @@ class C {
''');
}
+ test_invalid_nameConflict_imported() {
+ namesThatCannotBeResolved.add('V');
+ addLibrarySource('/a.dart', 'V() {}');
+ addLibrarySource('/b.dart', 'V() {}');
+ checkLibrary('''
+import 'a.dart';
+import 'b.dart';
+foo([p = V]) {}
+''');
+ }
+
+ test_invalid_nameConflict_imported_exported() {
+ namesThatCannotBeResolved.add('V');
+ addLibrarySource('/a.dart', 'V() {}');
+ addLibrarySource('/b.dart', 'V() {}');
+ addLibrarySource(
+ '/c.dart',
+ r'''
+export 'a.dart';
+export 'b.dart';
+''');
+ checkLibrary('''
+import 'c.dart';
+foo([p = V]) {}
+''');
+ }
+
+ test_invalid_nameConflict_local() {
+ namesThatCannotBeResolved.add('V');
+ checkLibrary('''
+foo([p = V]) {}
+V() {}
+var V;
+''');
+ }
+
test_invalid_setterParameter_fieldFormalParameter() {
checkLibrary('''
class C {
« no previous file with comments | « pkg/analyzer/test/src/dart/analysis/driver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698