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

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

Issue 2456803004: fixes #27586, prefer context type in generic inference (Closed)
Patch Set: more tweaks Created 4 years, 1 month 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 79798808ad6ae847a1a0e2906bf8fb5c657e042d..89b22434cab6c7aadc59445d394553071c13ab1f 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -630,9 +630,9 @@ num y;
C<int> c_int = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER*/C(/*info:DOWN_CAST_IMPLICIT*/y);
// These hints are not reported because we resolve with a null error listener.
-C<num> c_num = /*pass should be info:INFERRED_TYPE_ALLOCATION*/new C(123);
-C<num> c_num2 = (/*pass should be info:INFERRED_TYPE_ALLOCATION*/new C(456))
- ..t = /*error:INVALID_ASSIGNMENT*/1.0;
+C<num> c_num = /*info:INFERRED_TYPE_ALLOCATION*/new C(123);
+C<num> c_num2 = (/*info:INFERRED_TYPE_ALLOCATION*/new C(456))
+ ..t = 1.0;
// Down't infer from explicit dynamic.
var c_dynamic = new C<dynamic>(42);
@@ -1153,13 +1153,13 @@ void main() {
new F4<int>(a: /*info:INFERRED_TYPE_LITERAL*/[/*info:INFERRED_TYPE_LITERAL,error:COULD_NOT_INFER*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/"hello"],
/*info:INFERRED_TYPE_LITERAL*/[3]]);
- new F3(/*info:INFERRED_TYPE_LITERAL*/[]);
+ /*info:INFERRED_TYPE_ALLOCATION*/new F3(/*info:INFERRED_TYPE_LITERAL*/[]);
/*info:INFERRED_TYPE_ALLOCATION*/new F3(/*info:INFERRED_TYPE_LITERAL*/[/*info:INFERRED_TYPE_LITERAL*/[3]]);
/*info:INFERRED_TYPE_ALLOCATION*/new F3(/*info:INFERRED_TYPE_LITERAL*/[/*info:INFERRED_TYPE_LITERAL*/["hello"]]);
/*info:INFERRED_TYPE_ALLOCATION*/new F3(/*info:INFERRED_TYPE_LITERAL*/[/*info:INFERRED_TYPE_LITERAL*/["hello"],
/*info:INFERRED_TYPE_LITERAL*/[3]]);
- new F4(a: /*info:INFERRED_TYPE_LITERAL*/[]);
+ /*info:INFERRED_TYPE_ALLOCATION*/new F4(a: /*info:INFERRED_TYPE_LITERAL*/[]);
/*info:INFERRED_TYPE_ALLOCATION*/new F4(a: /*info:INFERRED_TYPE_LITERAL*/[/*info:INFERRED_TYPE_LITERAL*/[3]]);
/*info:INFERRED_TYPE_ALLOCATION*/new F4(a: /*info:INFERRED_TYPE_LITERAL*/[/*info:INFERRED_TYPE_LITERAL*/["hello"]]);
/*info:INFERRED_TYPE_ALLOCATION*/new F4(a: /*info:INFERRED_TYPE_LITERAL*/[/*info:INFERRED_TYPE_LITERAL*/["hello"],
@@ -2114,13 +2114,13 @@ class Foo<T extends Pattern> {
}
main() {
String s;
- var a = new Foo().method<String>("str");
+ var a = /*info:INFERRED_TYPE_ALLOCATION*/new Foo().method<String>("str");
s = a;
- new Foo();
+ /*info:INFERRED_TYPE_ALLOCATION*/new Foo();
var b = new Foo<String>().method("str");
s = b;
- var c = new Foo().method("str");
+ var c = /*info:INFERRED_TYPE_ALLOCATION*/new Foo().method("str");
s = c;
new Foo<String>()./*error:COULD_NOT_INFER*/method(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/42);
@@ -2136,13 +2136,13 @@ class Foo<T extends Pattern> {
}
main() {
String s;
- var a = new Foo().method/*<String>*/("str");
+ var a = /*info:INFERRED_TYPE_ALLOCATION*/new Foo().method/*<String>*/("str");
s = a;
- new Foo();
+ /*info:INFERRED_TYPE_ALLOCATION*/new Foo();
var b = new Foo<String>().method("str");
s = b;
- var c = new Foo().method("str");
+ var c = /*info:INFERRED_TYPE_ALLOCATION*/new Foo().method("str");
s = c;
new Foo<String>()./*error:COULD_NOT_INFER*/method(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/42);
@@ -4091,8 +4091,8 @@ class B<E> extends A<E> implements M {
}
foo () {
- int y = /*error:INVALID_ASSIGNMENT*/new B().m(null, null);
- String z = new B().m(null, null);
+ int y = /*error:INVALID_ASSIGNMENT,info:INFERRED_TYPE_ALLOCATION*/new B().m(null, null);
+ String z = /*info:INFERRED_TYPE_ALLOCATION*/new B().m(null, null);
}
''');
}
@@ -4339,7 +4339,7 @@ A v = null;
void test_instantiateToBounds_invokeConstructor_noBound() {
var unit = checkFile('''
class C<T> {}
-var x = new C();
+var x = /*info:INFERRED_TYPE_ALLOCATION*/new C();
''');
expect(unit.topLevelVariables[0].type.toString(), 'C<dynamic>');
}

Powered by Google App Engine
This is Rietveld 408576698