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

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.dart

Issue 2015833004: Fix circularity detection for AST-based type inference in the presence of closures. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/test/src/summary/resynthesize_ast_test.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/strong/inferred_type_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index a6867401c46e215cccf90efd503112723a0e5bcb..45e0ada2bb86505783aa9b49f400845c1c2493d0 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -479,6 +479,32 @@ test1() {
''');
}
+ void test_circularReference_viaClosures() {
+ var mainUnit = checkFile('''
+var x = () => y;
+var y = () => x;
+''');
+ var x = mainUnit.topLevelVariables[0];
+ var y = mainUnit.topLevelVariables[1];
+ expect(x.name, 'x');
+ expect(y.name, 'y');
+ expect(x.type.toString(), 'dynamic');
+ expect(y.type.toString(), 'dynamic');
+ }
+
+ void test_circularReference_viaClosures_initializerTypes() {
+ var mainUnit = checkFile('''
+var x = () => y;
+var y = () => x;
+''');
+ var x = mainUnit.topLevelVariables[0];
+ var y = mainUnit.topLevelVariables[1];
+ expect(x.name, 'x');
+ expect(y.name, 'y');
+ expect(x.initializer.returnType.toString(), '() → dynamic');
+ expect(y.initializer.returnType.toString(), '() → dynamic');
+ }
+
void test_conflictsCanHappen() {
checkFile('''
class I1 {
@@ -2551,25 +2577,24 @@ final x = <String, F<int>>{};
expect(x.type.toString(), 'Map<String, () → int>');
}
- void test_inferredType_opAssignToProperty_prefixedIdentifier() {
+ void test_inferredType_opAssignToProperty() {
var mainUnit = checkFile('''
class C {
num n;
}
-C c;
-var x = (c.n *= null);
+C f() => null;
+var x = (f().n *= null);
''');
- var x = mainUnit.topLevelVariables[1];
+ var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
expect(x.type.toString(), 'num');
}
- void test_inferredType_opAssignToProperty_prefixedIdentifier_viaInterface() {
+ void test_inferredType_opAssignToProperty_prefixedIdentifier() {
var mainUnit = checkFile('''
-class I {
+class C {
num n;
}
-abstract class C implements I {}
C c;
var x = (c.n *= null);
''');
@@ -2578,15 +2603,16 @@ var x = (c.n *= null);
expect(x.type.toString(), 'num');
}
- void test_inferredType_opAssignToProperty() {
+ void test_inferredType_opAssignToProperty_prefixedIdentifier_viaInterface() {
var mainUnit = checkFile('''
-class C {
+class I {
num n;
}
-C f() => null;
-var x = (f().n *= null);
+abstract class C implements I {}
+C c;
+var x = (c.n *= null);
''');
- var x = mainUnit.topLevelVariables[0];
+ var x = mainUnit.topLevelVariables[1];
expect(x.name, 'x');
expect(x.type.toString(), 'num');
}
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_ast_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698