Chromium Code Reviews| 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(''); |
| } |