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

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

Issue 2253923002: fix #27088, future then upwards inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
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 c8f2e0150117050e0ff667dcebc4013f784ff56a..b52167d28d818ef9a22405cb09def6aa3dbbe5de 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -1545,6 +1545,22 @@ Future<int> t6 = f.then((x) {return x ? 2 : new Future<int>.value(3);});
''');
}
+ void test_futureThen_upwards() {
+ // Regression test for https://github.com/dart-lang/sdk/issues/27088.
+ checkFile(r'''
+import 'dart:async';
+main() {
+ var f = foo().then((_) => 2.3);
+ Future<int> f2 = /*error:INVALID_ASSIGNMENT*/f;
+
+ // The unnecessary cast is to illustrate that we inferred <double> for
+ // the generic type args, even though we had a return type context.
+ Future<num> f3 = /*info:UNNECESSARY_CAST*/foo().then((_) => 2.3) as Future<double>;
+}
+Future foo() async => 1;
+ ''');
+ }
+
void test_futureUnion_asyncConditional() {
checkFile('''
import 'dart:async';
@@ -1693,7 +1709,7 @@ class D extends C {
/*=T*/ g/*<T>*/(/*=T*/ x) => x;
}
main() {
- int y = /*info:DYNAMIC_CAST*/(new D() as C).m(42);
+ int y = /*info:DYNAMIC_CAST*/(/*info:UNNECESSARY_CAST*/new D() as C).m(42);
print(y);
}
''');
@@ -2327,7 +2343,7 @@ var f = 2 + 3; // binary expressions are OK if the left operand
var g = -3;
var h = new A() + 3;
var i = /*error:UNDEFINED_OPERATOR,info:DYNAMIC_INVOKE*/- new A();
-var j = null as B;
+var j = /*info:UNNECESSARY_CAST*/null as B;
test1() {
a = /*error:INVALID_ASSIGNMENT*/"hi";
« no previous file with comments | « pkg/analyzer/test/src/task/strong/checker_test.dart ('k') | pkg/analyzer/test/src/task/strong/strong_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698