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

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

Issue 2859703004: Re-remove ad hoc Future.then inference. (Closed)
Patch Set: rebase Created 3 years, 8 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/lib/src/generated/static_type_analyzer.dart ('k') | pkg/front_end/test/fasta/compile.status » ('j') | 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 8c3c2734e2cbaa255db9f4470b0371eafd01a9fd..7169cf9068e2a9fecb5ac9159c2f179c40540ce0 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -1677,82 +1677,6 @@ void main() {
build(declared: "Future", downwards: "Future", upwards: "Future"));
}
- test_futureThen_conditional_deprecated() async {
- // Tests the deprecated ad hoc future inference for classes which implement
- // Future but haven't been updated to use FutureOr
- String build({String declared, String downwards, String upwards}) => '''
-import 'dart:async';
-class MyFuture<T> implements Future<T> {
- MyFuture() {}
- MyFuture.value(T x) {}
- dynamic noSuchMethod(invocation);
- MyFuture<S> then<S>(dynamic f(T x), {Function onError}) => null;
-}
-
-void main() {
- $declared<bool> f;
- $downwards<int> t1 = f.then(/*info:INFERRED_TYPE_CLOSURE*/
- (x) async => x ? 2 : await new $upwards<int>.value(3));
- $downwards<int> t2 = f.then(/*info:INFERRED_TYPE_CLOSURE,info:INFERRED_TYPE_CLOSURE*/(x) async { // TODO(leafp): Why the duplicate here?
- return /*info:DOWN_CAST_COMPOSITE*/await x ? 2 : new $upwards<int>.value(3);});
- $downwards<int> t5 = f.then(/*info:INFERRED_TYPE_CLOSURE*/
- (x) => x ? 2 : new $upwards<int>.value(3));
- $downwards<int> t6 = f.then(/*info:INFERRED_TYPE_CLOSURE,info:INFERRED_TYPE_CLOSURE*/
- (x) {return /*info:DOWN_CAST_COMPOSITE*/x ? 2 : new $upwards<int>.value(3);});
-}
-''';
- await checkFileElement(
- build(declared: "MyFuture", downwards: "Future", upwards: "Future"));
- await checkFileElement(
- build(declared: "MyFuture", downwards: "Future", upwards: "MyFuture"));
- await checkFileElement(
- build(declared: "MyFuture", downwards: "MyFuture", upwards: "Future"));
- await checkFileElement(build(
- declared: "MyFuture", downwards: "MyFuture", upwards: "MyFuture"));
- }
-
- test_futureThen_deprecated() async {
-// Tests the deprecated ad hoc future inference for classes which implement
-// Future but haven't been updated to use FutureOr
- String build({String declared, String downwards, String upwards}) => '''
-import 'dart:async';
-class MyFuture<T> implements Future<T> {
- MyFuture() {}
- MyFuture.value(T x) {}
- dynamic noSuchMethod(invocation);
- MyFuture<S> then<S>(dynamic f(T x), {Function onError}) => null;
-}
-
-void main() {
- $declared f;
- $downwards<int> t1 = f.then((_) async => await new $upwards<int>.value(3));
- $downwards<int> t2 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(_) async {
- return await new $upwards<int>.value(3);});
- $downwards<int> t3 = f.then((_) async => 3);
- $downwards<int> t4 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(_) async {
- return 3;});
- $downwards<int> t5 = f.then((_) => new $upwards<int>.value(3));
- $downwards<int> t6 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(_) {return new $upwards<int>.value(3);});
- $downwards<int> t7 = f.then((_) async => new $upwards<int>.value(3));
- $downwards<int> t8 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(_) async {
- return new $upwards<int>.value(3);});
-}
-''';
-
- await checkFileElement(
- build(declared: "MyFuture", downwards: "Future", upwards: "Future"));
- await checkFileElement(
- build(declared: "MyFuture", downwards: "Future", upwards: "MyFuture"));
- await checkFileElement(
- build(declared: "MyFuture", downwards: "MyFuture", upwards: "Future"));
- await checkFileElement(build(
- declared: "MyFuture", downwards: "MyFuture", upwards: "MyFuture"));
- await checkFileElement(
- build(declared: "Future", downwards: "Future", upwards: "MyFuture"));
- await checkFileElement(
- build(declared: "Future", downwards: "Future", upwards: "Future"));
- }
-
test_futureThen_downwardsMethodTarget() async {
// Not working yet, see: https://github.com/dart-lang/sdk/issues/27114
await checkFileElement(r'''
@@ -1774,7 +1698,7 @@ m1() {
Future<int> f;
var x = f.then<Future<List<int>>>(/*info:INFERRED_TYPE_CLOSURE,
error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/
- (x) => /*info:INFERRED_TYPE_LITERAL*/[]);
+ (x) => []);
Future<List<int>> y = x;
}
m2() {
@@ -1815,38 +1739,6 @@ $declared foo() => new $declared<int>.value(1);
build(declared: "Future", downwards: "Future", upwards: "Future"));
}
- test_futureThen_upwards_deprecated() async {
- // Tests the deprecated ad hoc future inference for classes which implement
- // Future but haven't been updated to use FutureOr
- // Regression test for https://github.com/dart-lang/sdk/issues/27088.
- String build({String declared, String downwards, String upwards}) => '''
-import 'dart:async';
-class MyFuture<T> implements Future<T> {
- MyFuture() {}
- MyFuture.value(T x) {}
- dynamic noSuchMethod(invocation);
- MyFuture<S> then<S>(dynamic f(T x), {Function onError}) => null;
-}
-
-void main() {
- var f = foo().then((_) => 2.3);
- $downwards<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.
- $downwards<num> f3 = /*info:UNNECESSARY_CAST*/foo().then(
- (_) => 2.3) as $upwards<double>;
-}
-$declared foo() => new $declared<int>.value(1);
- ''';
- await checkFileElement(
- build(declared: "MyFuture", downwards: "Future", upwards: "Future"));
- await checkFileElement(build(
- declared: "MyFuture", downwards: "MyFuture", upwards: "MyFuture"));
- await checkFileElement(
- build(declared: "Future", downwards: "Future", upwards: "Future"));
- }
-
test_futureThen_upwardsFromBlock() async {
// Regression test for https://github.com/dart-lang/sdk/issues/27113.
await checkFileElement(r'''
@@ -1884,31 +1776,6 @@ $downwards<int> g3(bool x) async {
await checkFileElement(build(downwards: "Future", upwards: "MyFuture"));
}
- test_futureUnion_asyncConditional_deprecated() async {
- // Tests the deprecated ad hoc future inference for classes which implement
- // Future but haven't been updated to use FutureOr
- String build({String declared, String downwards, String upwards}) => '''
-import 'dart:async';
-class MyFuture<T> implements Future<T> {
- MyFuture() {}
- MyFuture.value(x) {}
- dynamic noSuchMethod(invocation);
- MyFuture<S> then<S>(dynamic f(T x), {Function onError}) => null;
-}
-
-$downwards<int> g1(bool x) async {
- return /*info:DOWN_CAST_COMPOSITE*/x ? 42 : /*info:INFERRED_TYPE_ALLOCATION*/new $upwards.value(42); }
-$downwards<int> g2(bool x) async =>
- /*info:DOWN_CAST_COMPOSITE*/x ? 42 : /*info:INFERRED_TYPE_ALLOCATION*/new $upwards.value(42);
-$downwards<int> g3(bool x) async {
- var y = x ? 42 : new $upwards.value(42);
- return /*info:DOWN_CAST_COMPOSITE*/y;
-}
- ''';
- await checkFileElement(build(downwards: "Future", upwards: "Future"));
- await checkFileElement(build(downwards: "Future", upwards: "MyFuture"));
- }
-
test_futureUnion_downwards() async {
String build({String declared, String downwards, String upwards}) {
return '''
@@ -1944,43 +1811,6 @@ $downwards<List<int>> g3() async {
build(declared: "Future", downwards: "Future", upwards: "MyFuture"));
}
- test_futureUnion_downwards_deprecated() async {
- // Tests the deprecated ad hoc future inference for classes which implement
- // Future but haven't been updated to use FutureOr
- String build({String declared, String downwards, String upwards}) {
- return '''
-import 'dart:async';
-class MyFuture<T> implements Future<T> {
- MyFuture() {}
- MyFuture.value([x]) {}
- dynamic noSuchMethod(invocation);
- MyFuture<S> then<S>(dynamic f(T x), {Function onError}) => null;
-}
-
-$declared f;
-// Instantiates Future<int>
-$downwards<int> t1 = f.then((_) =>
- /*info:INFERRED_TYPE_ALLOCATION*/new $upwards.value('hi'));
-
-// Instantiates List<int>
-$downwards<List<int>> t2 = f.then((_) => /*info:INFERRED_TYPE_LITERAL*/[3]);
-$downwards<List<int>> g2() async { return /*info:INFERRED_TYPE_LITERAL*/[3]; }
-$downwards<List<int>> g3() async {
- return /*info:INFERRED_TYPE_ALLOCATION*/new $upwards.value(
- /*info:INFERRED_TYPE_LITERAL*/[3]); }
-''';
- }
-
- await checkFileElement(
- build(declared: "MyFuture", downwards: "Future", upwards: "Future"));
- await checkFileElement(
- build(declared: "MyFuture", downwards: "Future", upwards: "MyFuture"));
- await checkFileElement(
- build(declared: "Future", downwards: "Future", upwards: "Future"));
- await checkFileElement(
- build(declared: "Future", downwards: "Future", upwards: "MyFuture"));
- }
-
test_futureUnion_downwardsGenericMethodWithFutureReturn() async {
// Regression test for https://github.com/dart-lang/sdk/issues/27134
//
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | pkg/front_end/test/fasta/compile.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698