Skip to content

Commit 818b2a0

Browse files
johnniwintherCommit Queue
authored andcommitted
[test] Remove noisy expectStaticType
This removes the use of expectStaticType on calls that are already reported as erroneous because the type arguments couldn't inferred. Given that it is already an erroneous case, we cannot really expect a certain inference result. Change-Id: I3f6831d161a7463633ba371921a822218ee8d621 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447181 Reviewed-by: Erik Ernst <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent 872a518 commit 818b2a0

File tree

1 file changed

+12
-53
lines changed

1 file changed

+12
-53
lines changed

tests/language/inference_using_bounds/pre_experiment/restricting_choices_using_bounds_legacy_error_test.dart

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
// @dart=3.5
66

7-
import '../../static_type_helper.dart';
8-
97
// For the motivational issue, see
108
// https://github.com/dart-lang/language/issues/1194
119

@@ -20,101 +18,62 @@ extension type EA(A? it) {}
2018
class B<X> {}
2119

2220
T foo1<T extends Object>(T? t, dynamic r) => r as T;
23-
bar1(FutureOr<Object?> x) => foo1(x, "")..expectStaticType<Exactly<Object>>();
21+
bar1(FutureOr<Object?> x) => foo1(x, "");
2422
// ^^^^
2523
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
2624
// [cfe] Inferred type argument 'FutureOr<Object?>' doesn't conform to the bound 'Object' of the type variable 'T' on 'foo1'.
27-
// ^
28-
// [cfe] Type argument 'Object Function(Object)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
29-
// ^^^^^^^^^^^^^^^
30-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
3125

3226
T foo2<T extends num>(T? t, dynamic r) => r as T;
33-
bar2(Null x) => foo2(x, 0)..expectStaticType<Exactly<num>>();
27+
bar2(Null x) => foo2(x, 0);
3428
// ^^^^
3529
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
3630
// [cfe] Inferred type argument 'Null' doesn't conform to the bound 'num' of the type variable 'T' on 'foo2'.
37-
// ^
38-
// [cfe] Type argument 'num Function(num)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
39-
// ^^^^^^^^^^^^
40-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
4131

4232
T foo3<T extends Object>(T? t, dynamic r) => r as T;
43-
bar3(EA x) => foo3(x, false)..expectStaticType<Exactly<Object>>();
33+
bar3(EA x) => foo3(x, false);
4434
// ^^^^
4535
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
4636
// [cfe] Inferred type argument 'EA' doesn't conform to the bound 'Object' of the type variable 'T' on 'foo3'.
47-
// ^
48-
// [cfe] Type argument 'Object Function(Object)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
49-
// ^^^^^^^^^^^^^^^
50-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
5137

5238
T foo4<T extends A>(T? t, dynamic r) => r as T;
53-
bar4<S extends A?>(S x) => foo4(x, A())..expectStaticType<Exactly<A>>();
39+
bar4<S extends A?>(S x) => foo4(x, A());
5440
// ^^^^
5541
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
5642
// [cfe] Inferred type argument 'S' doesn't conform to the bound 'A' of the type variable 'T' on 'foo4'.
57-
// ^
58-
// [cfe] Type argument 'A Function(A)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
59-
// ^^^^^^^^^^
60-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
6143

6244
T foo5<T extends B<S>, S>(T? t, dynamic r) => r as T;
63-
bar5<U extends B<U>?>(U x) =>
64-
foo5(x, B<Never>())..expectStaticType<Exactly<B<U>>>();
65-
// ^^^^
45+
bar5<U extends B<U>?>(U x) => foo5(x, B<Never>());
46+
// ^^^^
6647
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
6748
// [cfe] Inferred type argument 'U' doesn't conform to the bound 'B<S>' of the type variable 'T' on 'foo5'.
68-
// ^
69-
// [cfe] Type argument 'B<U> Function(B<U>)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
70-
// ^^^^^^^^^^^^^
71-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
7249

7350
// The following test case checks that the implementations use `Object?` as the
7451
// covariant replacement in the greatest closure of a type.
7552
T foo6<T extends B<S>, S>(T? t, dynamic r) => r as T;
76-
bar6(Null x) => foo6(x, B<Never>())..expectStaticType<Exactly<B<Object?>>>();
53+
bar6(Null x) => foo6(x, B<Never>());
7754
// ^^^^
7855
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
7956
// [cfe] Inferred type argument 'Null' doesn't conform to the bound 'B<S>' of the type variable 'T' on 'foo6'.
80-
// ^
81-
// [cfe] Type argument 'B<Object?> Function(B<Object?>)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
82-
// ^^^^^^^^^^^^^^^^^^^
83-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
8457

8558
T foo7<T extends B<Function(S)>, S>(T? t, dynamic r) => r as T;
86-
bar7<U extends B<Function(U)>?>(U x) =>
87-
foo7(x, B<Never>())..expectStaticType<Exactly<B<Function(U)>>>();
88-
// ^^^^
59+
bar7<U extends B<Function(U)>?>(U x) => foo7(x, B<Never>());
60+
// ^^^^
8961
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
9062
// [cfe] Inferred type argument 'U' doesn't conform to the bound 'B<dynamic Function(S)>' of the type variable 'T' on 'foo7'.
91-
// ^
92-
// [cfe] Type argument 'B<dynamic Function(U)> Function(B<dynamic Function(U)>)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
93-
// ^^^^^^^^^^^^^^^^^^^^^^^
94-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
9563

9664
// The following test case checks that the implementations use `Never` as the
9765
// covariant replacement in the greatest closure of a type.p
9866
T foo8<T extends B<Function(S)>, S extends A2>(T? t, dynamic r) => r as T;
99-
bar8<U extends B<Function(A)>?>(U? x) =>
100-
foo8(x, B<Never>())..expectStaticType<Exactly<B<Function(A)>>>();
101-
// ^^^^
67+
bar8<U extends B<Function(A)>?>(U? x) => foo8(x, B<Never>());
68+
// ^^^^
10269
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
10370
// [cfe] Inferred type argument 'U' doesn't conform to the bound 'B<dynamic Function(S)>' of the type variable 'T' on 'foo8'.
104-
// ^
105-
// [cfe] Type argument 'B<dynamic Function(A)> Function(B<dynamic Function(A)>)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
106-
// ^^^^^^^^^^^^^^^^^^^^^^^
107-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
10871

10972
T foo9<T extends Object>(T? t, dynamic r) => r as T;
110-
bar9<S extends num?>(S? x) => foo9(x, 0)..expectStaticType<Exactly<num>>();
73+
bar9<S extends num?>(S? x) => foo9(x, 0);
11174
// ^^^^
11275
// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
11376
// [cfe] Inferred type argument 'S' doesn't conform to the bound 'Object' of the type variable 'T' on 'foo9'.
114-
// ^
115-
// [cfe] Type argument 'num Function(num)' doesn't conform to the bound 'T Function(T)' of the type variable 'R' on 'expectStaticType'.
116-
// ^^^^^^^^^^^^
117-
// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
11877

11978
// The following checks that the trivial case of the absent bound of the
12079
// variable being inferred isn't affected.

0 commit comments

Comments
 (0)