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

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

Issue 1921333002: Fix summarization of unresolved annotations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/lib/src/summary/summarize_elements.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/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index a44ce9a1f6a596b16cd99e13115f68b04f28d2c4..bdbfe7e7ee6ed678986ad40fd15dbcfa7039a318 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -7806,6 +7806,89 @@ D d;''');
]);
}
+ test_metadata_constructor_call_named_prefixed_unresolved_class() {
+ addNamedSource('/foo.dart', '');
+ UnlinkedClass cls = serializeClassText(
+ 'import "foo.dart" as foo; @foo.A.named() class C {}',
+ allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'named',
+ expectedKind: ReferenceKind.unresolved,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.unresolved, 'A'),
+ new _PrefixExpectation(ReferenceKind.prefix, 'foo')
+ ],
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
+ test_metadata_constructor_call_named_prefixed_unresolved_constructor() {
+ addNamedSource('/foo.dart', 'class A {}');
+ UnlinkedClass cls = serializeClassText(
+ 'import "foo.dart" as foo; @foo.A.named() class C {}',
+ allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'named',
+ expectedKind: ReferenceKind.unresolved,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'A',
+ absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'),
+ new _PrefixExpectation(ReferenceKind.prefix, 'foo')
+ ],
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
+ test_metadata_constructor_call_named_unresolved_class() {
+ UnlinkedClass cls =
+ serializeClassText('@A.named() class C {}', allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'named',
+ expectedKind: ReferenceKind.unresolved,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.unresolved, 'A')
+ ],
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
+ test_metadata_constructor_call_named_unresolved_constructor() {
+ UnlinkedClass cls = serializeClassText('class A {} @A.named() class C {}',
+ allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'named',
+ expectedKind: ReferenceKind.unresolved,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'A')
+ ],
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
test_metadata_constructor_call_unnamed() {
UnlinkedClass cls =
serializeClassText('class A { const A(); } @A() class C {}');
@@ -7837,6 +7920,41 @@ D d;''');
]);
}
+ test_metadata_constructor_call_unnamed_prefixed_unresolved() {
+ addNamedSource('/foo.dart', '');
+ UnlinkedClass cls = serializeClassText(
+ 'import "foo.dart" as foo; @foo.A() class C {}',
+ allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'A',
+ expectedKind: ReferenceKind.unresolved,
+ expectedPrefix: 'foo',
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
+ test_metadata_constructor_call_unnamed_unresolved() {
+ UnlinkedClass cls =
+ serializeClassText('@A() class C {}', allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.invokeConstructor,
+ ], ints: [
+ 0,
+ 0
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'A',
+ expectedKind: ReferenceKind.unresolved,
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
test_metadata_constructor_call_with_args() {
UnlinkedClass cls =
serializeClassText('class A { const A(x); } @A(null) class C {}');
@@ -8005,6 +8123,22 @@ D d;''');
]);
}
+ test_metadata_prefixed_variable_unresolved() {
+ addNamedSource('/a.dart', '');
+ UnlinkedClass cls = serializeClassText(
+ 'import "a.dart" as a; @a.b class C {}',
+ allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'b',
+ expectedKind: ReferenceKind.unresolved,
+ expectedPrefix: 'a',
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
test_metadata_simpleFormalParameter() {
checkAnnotationA(serializeExecutableText('const a = null; f(@a x) {}')
.parameters[0]
@@ -8049,6 +8183,18 @@ D d;''');
.annotations);
}
+ test_metadata_variable_unresolved() {
+ UnlinkedClass cls = serializeClassText('@a class C {}', allowErrors: true);
+ expect(cls.annotations, hasLength(1));
+ _assertUnlinkedConst(cls.annotations[0], operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'a',
+ expectedKind: ReferenceKind.unresolved,
+ checkAstDerivedDataOverride: true)
+ ]);
+ }
+
test_method_documented() {
String text = '''
class C {
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698