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

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

Issue 2754423002: Fail inference when an instance field is referenced. (Closed)
Patch Set: Created 3 years, 9 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
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 de02780bbba226ee62bcaca0b77a5cc55b90c708..1af3a816f252910df7252ac584374a52732f1e81 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -543,7 +543,7 @@ test1() {
int x = 0;
// inference in A now works.
x = A.a1;
- x = new A().a2;
+ x = /*info:DYNAMIC_CAST*/new A().a2;
}
''');
}
@@ -1665,7 +1665,7 @@ var h = f().hashCode;
expect(s.type.toString(), 'String');
var h = mainUnit.topLevelVariables[1];
expect(h.name, 'h');
- expect(h.type.toString(), 'int');
+ expect(h.type.toString(), 'dynamic');
}
test_dynamic_has_object_methods_viaPrefixedIdentifier() async {
@@ -1679,7 +1679,7 @@ var h = d.hashCode;
expect(s.type.toString(), 'String');
var h = mainUnit.topLevelVariables[2];
expect(h.name, 'h');
- expect(h.type.toString(), 'int');
+ expect(h.type.toString(), 'dynamic');
}
test_fieldRefersToStaticGetter() async {
@@ -3166,7 +3166,7 @@ test1() {
x = E.e3;
x = new E().e4;
x = /*info:DYNAMIC_CAST*/new E().e5;
- x = new E().e6;
+ x = /*info:DYNAMIC_CAST*/new E().e6;
x = F.f1;
x = new F().f2;
}
@@ -3429,7 +3429,7 @@ test1() {
A a;
B b;
a = t1;
- i = t2;
+ i = /*info:DYNAMIC_CAST*/t2;
b = t3;
i = /*info:DYNAMIC_CAST*/t4;
i = new B().y; // B.y was inferred though
@@ -3600,7 +3600,7 @@ class A {
var v = new A()..a = 1..b.add(2)..m();
''');
var v = mainUnit.topLevelVariables[0];
- expect(v.type.toString(), 'A');
+ expect(v.type.toString(), 'dynamic');
}
test_inferredType_customBinaryOp() async {
@@ -3721,7 +3721,7 @@ var x = f().b;
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
- expect(x.type.toString(), 'bool');
+ expect(x.type.toString(), 'dynamic');
}
test_inferredType_extractProperty_prefixedIdentifier() async {
@@ -3734,7 +3734,7 @@ var x = c.b;
''');
var x = mainUnit.topLevelVariables[1];
expect(x.name, 'x');
- expect(x.type.toString(), 'bool');
+ expect(x.type.toString(), 'dynamic');
}
test_inferredType_extractProperty_prefixedIdentifier_viaInterface() async {
@@ -3748,7 +3748,7 @@ var x = c.b;
''');
var x = mainUnit.topLevelVariables[1];
expect(x.name, 'x');
- expect(x.type.toString(), 'bool');
+ expect(x.type.toString(), 'dynamic');
}
test_inferredType_extractProperty_viaInterface() async {
@@ -3762,7 +3762,7 @@ var x = f().b;
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
- expect(x.type.toString(), 'bool');
+ expect(x.type.toString(), 'dynamic');
}
test_inferredType_fromTopLevelExecutableTearoff() async {
@@ -3846,7 +3846,7 @@ var x = (f().n *= null);
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
- expect(x.type.toString(), 'num');
+ expect(x.type.toString(), 'dynamic');
}
test_inferredType_opAssignToProperty_prefixedIdentifier() async {
@@ -3859,7 +3859,7 @@ var x = (c.n *= null);
''');
var x = mainUnit.topLevelVariables[1];
expect(x.name, 'x');
- expect(x.type.toString(), 'num');
+ expect(x.type.toString(), 'dynamic');
}
test_inferredType_opAssignToProperty_prefixedIdentifier_viaInterface() async {
@@ -3887,7 +3887,7 @@ var x = (f().n *= null);
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
- expect(x.type.toString(), 'num');
+ expect(x.type.toString(), 'dynamic');
}
test_inferredType_viaClosure_multipleLevelsOfNesting() async {
@@ -4356,69 +4356,6 @@ var x = /*info:USE_OF_VOID_RESULT*/f();
expect(x.type.toString(), 'void');
}
- test_instanceField_basedOnInstanceField_betweenCycles() async {
- // Verify that all instance fields in one library cycle are inferred before
- // an instance fields in a dependent library cycle.
- addFile(
- '''
-import 'b.dart';
-class A {
- var x = new B().y;
- var y = 0;
-}
-''',
- name: '/a.dart');
- addFile(
- '''
-class B {
- var x = new B().y;
- var y = 0;
-}
-''',
- name: '/b.dart');
- await checkFileElement('''
-import 'a.dart';
-import 'b.dart';
-main() {
- new A().x = /*error:INVALID_ASSIGNMENT*/'foo';
- new B().x = 'foo';
-}
-''');
- }
-
- test_instanceField_basedOnInstanceField_withinCycle() async {
- // Verify that all instance field inferences that occur within the same
- // library cycle happen as though they occurred "all at once", so no
- // instance field in the library cycle can inherit its type from another
- // instance field in the same library cycle.
- addFile(
- '''
-import 'b.dart';
-class A {
- var x = new B().y;
- var y = 0;
-}
-''',
- name: '/a.dart');
- addFile(
- '''
-import 'a.dart';
-class B {
- var x = new A().y;
- var y = 0;
-}
-''',
- name: '/b.dart');
- await checkFileElement('''
-import 'a.dart';
-import 'b.dart';
-main() {
- new A().x = 'foo';
- new B().x = 'foo';
-}
-''');
- }
-
test_instantiateToBounds_generic2_hasBound_definedAfter() async {
var unit = await checkFileElement(r'''
class B<T extends /*error:NOT_INSTANTIATED_BOUND*/A> {}
@@ -4868,7 +4805,7 @@ class D {
final x = C.d.i;
''');
var x = mainUnit.topLevelVariables[0];
- expect(x.type.toString(), 'int');
+ expect(x.type.toString(), 'dynamic');
}
test_referenceToFieldOfStaticGetter() async {
@@ -4882,7 +4819,7 @@ class D {
final x = C.d.i;
''');
var x = mainUnit.topLevelVariables[0];
- expect(x.type.toString(), 'int');
+ expect(x.type.toString(), 'dynamic');
}
test_referenceToTypedef() async {
@@ -4977,7 +4914,7 @@ class C {
await checkFileElement('''
import 'a.dart';
test() {
- x = /*error:INVALID_ASSIGNMENT*/"hi";
+ x = "hi";
}
''');
}

Powered by Google App Engine
This is Rietveld 408576698