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

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

Issue 2295853002: fix #26992, inference failures are now an error (Closed)
Patch Set: fix comment Created 4 years, 3 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/task/strong/checker_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 f4a6c9d163664fc49e15aa3915884757f976899c..0490b74423930601e3a8eda715d1380745ba21ed 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -625,9 +625,8 @@ class C<T> {
var x = /*info:INFERRED_TYPE_ALLOCATION*/new C(42);
-// Don't infer if we had a context type.
num y;
-C<int> c_int = /*info:INFERRED_TYPE_ALLOCATION*/new C(/*info:DOWN_CAST_IMPLICIT*/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);
@@ -1225,10 +1224,10 @@ void main() {
A<int, String> a5 = /*error:STATIC_TYPE_ERROR*/new A<dynamic, dynamic>.named(3, "hello");
}
{
- A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new A(
+ A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/A(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello",
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
- A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new A.named(
+ A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/A.named(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello",
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
}
@@ -1241,10 +1240,10 @@ void main() {
A<int, String> a5 = /*error:INVALID_ASSIGNMENT*/new B<dynamic, dynamic>.named("hello", 3);
}
{
- A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new B(
+ A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/B(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3,
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
- A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new B.named(
+ A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/B.named(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3,
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
}
@@ -1257,9 +1256,9 @@ void main() {
A<int, int> a5 = /*error:INVALID_ASSIGNMENT*/new C<dynamic>.named(3);
}
{
- A<int, int> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new C(
+ A<int, int> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER*/C(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
- A<int, int> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new C.named(
+ A<int, int> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER*/C.named(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
}
{
@@ -1271,9 +1270,9 @@ void main() {
A<int, String> a5 = /*error:INVALID_ASSIGNMENT*/new D<dynamic, dynamic>.named("hello");
}
{
- A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new D(
+ A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER*/D(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
- A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new D.named(
+ A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER*/D.named(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
}
{
@@ -1288,9 +1287,9 @@ void main() {
b: /*info:INFERRED_TYPE_LITERAL*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/3]);
A<int, String> a2 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello", 3, "hello");
A<int, String> a3 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello");
- A<int, String> a4 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello",
+ A<int, String> a4 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/F.named(3, "hello",
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
- A<int, String> a5 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello",
+ A<int, String> a5 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER*/F.named(3, "hello",
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
}
}
@@ -1706,7 +1705,7 @@ class MyFuture<T> implements Future<T> {
$declared f;
// Instantiates Future<int>
$downwards<int> t1 = f.then((_) =>
- ${allocInfo}new $upwards.value(
+ ${allocInfo}new /*error:COULD_NOT_INFER*/$upwards.value(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/'hi'));
// Instantiates List<int>
@@ -1774,7 +1773,7 @@ main() {
var c = new Foo().method("str");
s = c;
- new Foo<String>().method(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/42);
+ new Foo<String>()./*error:COULD_NOT_INFER*/method(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/42);
}
''');
}
@@ -1800,14 +1799,14 @@ main() {
printInt(myMax(1, 2) as int);
// Mixing int and double means return type is num.
- printInt(/*info:DOWN_CAST_IMPLICIT*/max(1, 2.0));
- printInt(/*info:DOWN_CAST_IMPLICIT*/min(1, 2.0));
- printDouble(/*info:DOWN_CAST_IMPLICIT*/max(1, 2.0));
- printDouble(/*info:DOWN_CAST_IMPLICIT*/min(1, 2.0));
+ printInt(/*error:COULD_NOT_INFER*/max(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/2.0));
+ printInt(/*error:COULD_NOT_INFER*/min(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/2.0));
+ printDouble(/*error:COULD_NOT_INFER*/max(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/1, 2.0));
+ printDouble(/*error:COULD_NOT_INFER*/min(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/1, 2.0));
// Types other than int and double are not accepted.
printInt(
- /*info:DOWN_CAST_IMPLICIT*/min(
+ /*error:COULD_NOT_INFER*/min(
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hi",
/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"there"));
}
@@ -1877,6 +1876,15 @@ main() {
''');
}
+ void test_genericMethods_inferenceError() {
+ checkFile(r'''
+main() {
+ List<String> y;
+ Iterable<String> x = y./*error:COULD_NOT_INFER*/map(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(String z) => 1.0);
+}
+ ''');
+ }
+
void test_genericMethods_inferGenericFunctionParameterType() {
var mainUnit = checkFile('''
class C<T> extends D<T> {
« no previous file with comments | « pkg/analyzer/test/src/task/strong/checker_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698