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

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

Issue 2658483002: Fix summary handling of invalid annotations of the form `@a.b.c`. (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/generated/non_error_resolver_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 5eaf53a257ea2ff2192313d1401f94702966346a..3690098b1c5b37b7cc86d8aacfa255dd4e922633 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -532,18 +532,17 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
Identifier rName = r.name;
Identifier oName = o.name;
if (oName is PrefixedIdentifier &&
+ rName is PrefixedIdentifier &&
o.constructorName != null &&
- o.element != null) {
- // E.g. `@prefix.cls.ctor`. This gets resynthesized as `@cls.ctor`,
- // with `cls.ctor` represented as a PrefixedIdentifier.
- expect(rName, new isInstanceOf<PrefixedIdentifier>(), reason: desc);
- if (rName is PrefixedIdentifier) {
- compareConstAsts(rName.prefix, oName.identifier, desc);
- expect(rName.period.lexeme, '.', reason: desc);
- compareConstAsts(rName.identifier, o.constructorName, desc);
- expect(r.period, isNull, reason: desc);
- expect(r.constructorName, isNull, reason: desc);
- }
+ o.element != null &&
+ r.constructorName == null) {
+ // E.g. `@prefix.cls.ctor`. This sometimes gets resynthesized as
+ // `@cls.ctor`, with `cls.ctor` represented as a PrefixedIdentifier.
+ compareConstAsts(rName.prefix, oName.identifier, desc);
+ expect(rName.period.lexeme, '.', reason: desc);
+ compareConstAsts(rName.identifier, o.constructorName, desc);
+ expect(r.period, isNull, reason: desc);
+ expect(r.constructorName, isNull, reason: desc);
} else {
compareConstAsts(r.name, o.name, desc);
expect(r.period?.lexeme, o.period?.lexeme, reason: desc);
@@ -3767,6 +3766,36 @@ C c;
''');
}
+ test_invalid_annotation_prefixed_constructor() {
scheglov 2017/01/24 20:10:18 Can we also add tests for using static const field
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {
+ const C.named();
+}
+''');
+ checkLibrary('''
+import "a.dart" as a;
+@a.C.named
+class D {}
+''');
+ }
+
+ test_invalid_annotation_unprefixed_constructor() {
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {
+ const C.named();
+}
+''');
+ checkLibrary('''
+import "a.dart";
+@C.named
+class D {}
+''');
+ }
+
test_library() {
checkLibrary('');
}
« no previous file with comments | « pkg/analyzer/test/generated/non_error_resolver_driver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698