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

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

Issue 2357513004: Test summary resynthesis of unresolved annotations. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | 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 bb75baf54e5a853899a8ea0e12b8505b766827da..ba8bb27484cb473ec79e6a76f77fdaa84a33af54 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -522,7 +522,9 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
expect(o.atSign.lexeme, r.atSign.lexeme, reason: desc);
Identifier rName = r.name;
Identifier oName = o.name;
- if (oName is PrefixedIdentifier && o.constructorName != null) {
+ if (oName 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);
@@ -541,7 +543,9 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
compareConstAstLists(
r.arguments?.arguments, o.arguments?.arguments, desc);
Element expectedElement = o.element;
- if (oName is PrefixedIdentifier && o.constructorName != null) {
+ if (oName is PrefixedIdentifier &&
+ o.constructorName != null &&
+ o.element != null) {
// Due to dartbug.com/25706, [o.element] incorrectly points to the
// class rather than the named constructor. Hack around this.
// TODO(paulberry): when dartbug.com/25706 is fixed, remove this.
@@ -639,10 +643,14 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest {
void compareElementAnnotations(ElementAnnotationImpl resynthesized,
ElementAnnotationImpl original, String desc) {
- expect(resynthesized.element, isNotNull, reason: desc);
- expect(resynthesized.element.kind, original.element.kind, reason: desc);
- expect(resynthesized.element.location, original.element.location,
- reason: desc);
+ if (original.element == null) {
+ expect(resynthesized.element, isNull);
+ } else {
+ expect(resynthesized.element, isNotNull, reason: desc);
+ expect(resynthesized.element.kind, original.element.kind, reason: desc);
+ expect(resynthesized.element.location, original.element.location,
+ reason: desc);
+ }
expect(resynthesized.compilationUnit, isNotNull, reason: desc);
expect(resynthesized.compilationUnit.location,
original.compilationUnit.location,
@@ -4456,6 +4464,51 @@ typedef F();''');
checkLibrary('f() {} g() {}');
}
+ test_unresolved_annotation_namedConstructorCall_noClass() {
+ checkLibrary('@foo.bar() class C {}');
+ }
+
+ test_unresolved_annotation_namedConstructorCall_noConstructor() {
+ checkLibrary('@String.foo() class C {}');
+ }
+
+ test_unresolved_annotation_prefixedIdentifier_badPrefix() {
+ checkLibrary('@foo.bar class C {}');
+ }
+
+ test_unresolved_annotation_prefixedIdentifier_noDeclaration() {
+ checkLibrary('import "dart:async" as foo; @foo.bar class C {}');
+ }
+
+ test_unresolved_annotation_prefixedNamedConstructorCall_badPrefix() {
+ checkLibrary('@foo.bar.baz() class C {}');
+ }
+
+ test_unresolved_annotation_prefixedNamedConstructorCall_noClass() {
+ checkLibrary('import "dart:async" as foo; @foo.bar.baz() class C {}');
+ }
+
+ @failingTest // See dartbug.com/25706
+ test_unresolved_annotation_prefixedNamedConstructorCall_noConstructor() {
+ checkLibrary('import "dart:async" as foo; @foo.Future.bar() class C {}');
+ }
+
+ test_unresolved_annotation_prefixedUnnamedConstructorCall_badPrefix() {
+ checkLibrary('@foo.bar() class C {}');
+ }
+
+ test_unresolved_annotation_prefixedUnnamedConstructorCall_noClass() {
+ checkLibrary('import "dart:async" as foo; @foo.bar() class C {}');
+ }
+
+ test_unresolved_annotation_simpleIdentifier() {
+ checkLibrary('@foo class C {}');
+ }
+
+ test_unresolved_annotation_unnamedConstructorCall_noClass() {
+ checkLibrary('@foo() class C {}');
+ }
+
test_unresolved_export() {
allowMissingFiles = true;
checkLibrary("export 'foo.dart';", allowErrors: true);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698