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

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

Issue 1681513003: Resynthesize invalid constants as unresolved identifiers. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/resynthesize.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_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index e0cd68727f0100553a4cfbabbc8bcef5a5ec3a90..68668230f6d7b85a14b07745ef518664bbc56906 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -35,6 +35,7 @@ main() {
@reflectiveTest
class ResynthTest extends ResolverTestCase {
Set<Source> otherLibrarySources = new Set<Source>();
+ bool constantInitializersAreInvalid = false;
/**
* Determine the analysis options that should be used for this test.
@@ -746,8 +747,14 @@ class ResynthTest extends ResolverTestCase {
compareElements(resynthesized, original, desc);
compareTypes(resynthesized.type, original.type, desc);
if (original is ConstVariableElement) {
- compareConstantAsts(resynthesized.constantInitializer,
- original.constantInitializer, desc);
+ Expression initializer = resynthesized.constantInitializer;
+ if (constantInitializersAreInvalid) {
+ expect(initializer, new isInstanceOf<SimpleIdentifier>(), reason: desc);
+ SimpleIdentifier identifier = initializer;
+ expect(identifier.staticElement, isNull, reason: desc);
+ } else {
+ compareConstantAsts(initializer, original.constantInitializer, desc);
+ }
}
}
@@ -1163,6 +1170,40 @@ class E {}''');
checkLibrary('class C {} class D {}');
}
+ test_const_invalid_field_const() {
+ constantInitializersAreInvalid = true;
+ checkLibrary(
+ r'''
+class C {
+ static const f = 1 + foo();
+}
+int foo() => 42;
+''',
+ allowErrors: true);
+ }
+
+ test_const_invalid_field_final() {
+ constantInitializersAreInvalid = true;
+ checkLibrary(
+ r'''
+class C {
+ final f = 1 + foo();
+}
+int foo() => 42;
+''',
+ allowErrors: true);
+ }
+
+ test_const_invalid_topLevel() {
+ constantInitializersAreInvalid = true;
+ checkLibrary(
+ r'''
+const v = 1 + foo();
+int foo() => 42;
+''',
+ allowErrors: true);
+ }
+
test_const_invokeConstructor_generic_named() {
checkLibrary(r'''
class C<K, V> {
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698