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

Unified Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1319703003: Handle cycles when infering static variables (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« pkg/analyzer/lib/src/task/dart.dart ('K') | « pkg/analyzer/lib/src/task/dart.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/task/dart_test.dart
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
index f2184611aa7391ae1f7d6e6448fee7e7daabb6eb..83304f7a0ebb81ee3adb176e63c97476ed5bc0b3 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -2129,6 +2129,41 @@ class C {
expect(topLevel.type, stringType);
expect(field.type, stringType);
}
+
+ void test_perform_cycle() {
+ AnalysisTarget source = newSource(
+ '/test.dart',
+ '''
+var piFirst = true;
+var pi = piFirst ? 3.14 : tau / 2;
+var tau = piFirst ? pi * 2 : 6.28;
+''');
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT5);
+ CompilationUnit unit = outputs[RESOLVED_UNIT5];
+ VariableElement piFirst =
+ getTopLevelVariable(unit, 'piFirst').name.staticElement;
+ VariableElement pi = getTopLevelVariable(unit, 'pi').name.staticElement;
+ VariableElement tau = getTopLevelVariable(unit, 'tau').name.staticElement;
+
+ computeResult(piFirst, INFERRED_STATIC_VARIABLE);
+ expect(piFirst.type, context.typeProvider.boolType);
+ expect(pi.type.isDynamic, isTrue);
+ expect(tau.type.isDynamic, isTrue);
+ }
+
+ void test_perform_null() {
+ AnalysisTarget source = newSource(
+ '/test.dart',
+ '''
+var a = null;
+''');
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT5);
+ CompilationUnit unit = outputs[RESOLVED_UNIT5];
+ VariableElement a = getTopLevelVariable(unit, 'a').name.staticElement;
+
+ computeResult(a, INFERRED_STATIC_VARIABLE);
+ expect(a.type.isDynamic, isTrue);
+ }
}
@reflectiveTest
« pkg/analyzer/lib/src/task/dart.dart ('K') | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698