Skip to content

Commit 721ff35

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Extract TYPE_ARGUMENT_NOT_MATCHING_BOUNDS tests.
[email protected] Change-Id: Icea3c1d158d54a5d5d08e8727618f3558760615c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112752 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent baebba0 commit 721ff35

File tree

4 files changed

+308
-288
lines changed

4 files changed

+308
-288
lines changed

pkg/analyzer/test/generated/compile_time_error_code.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,19 +4881,6 @@ typedef A<T extends A<int>>();
48814881
]);
48824882
}
48834883

4884-
test_typeArgumentNotMatchingBounds_const() async {
4885-
await assertErrorsInCode(r'''
4886-
class A {}
4887-
class B {}
4888-
class G<E extends A> {
4889-
const G();
4890-
}
4891-
f() { return const G<B>(); }
4892-
''', [
4893-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 81, 1),
4894-
]);
4895-
}
4896-
48974884
test_typedef_infiniteParameterBoundCycle() async {
48984885
await assertErrorsInCode(r'''
48994886
typedef F<X extends F> = F Function();

pkg/analyzer/test/generated/static_type_warning_code_test.dart

Lines changed: 0 additions & 275 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,281 +1063,6 @@ void main() { }
10631063
]);
10641064
}
10651065

1066-
test_typeArgumentNotMatchingBounds_classTypeAlias() async {
1067-
await assertErrorsInCode(r'''
1068-
class A {}
1069-
class B {}
1070-
class C {}
1071-
class G<E extends A> {}
1072-
class D = G<B> with C;
1073-
''', [
1074-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 69, 1),
1075-
]);
1076-
}
1077-
1078-
test_typeArgumentNotMatchingBounds_extends() async {
1079-
await assertErrorsInCode(r'''
1080-
class A {}
1081-
class B {}
1082-
class G<E extends A> {}
1083-
class C extends G<B>{}
1084-
''', [
1085-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 64, 1),
1086-
]);
1087-
}
1088-
1089-
test_typeArgumentNotMatchingBounds_extends_regressionInIssue18468Fix() async {
1090-
// https://code.google.com/p/dart/issues/detail?id=18628
1091-
await assertErrorsInCode(r'''
1092-
class X<T extends Type> {}
1093-
class Y<U> extends X<U> {}
1094-
''', [
1095-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 48, 1),
1096-
]);
1097-
}
1098-
1099-
test_typeArgumentNotMatchingBounds_fieldFormalParameter() async {
1100-
await assertErrorsInCode(r'''
1101-
class A {}
1102-
class B {}
1103-
class G<E extends A> {}
1104-
class C {
1105-
var f;
1106-
C(G<B> this.f) {}
1107-
}
1108-
''', [
1109-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 71, 1),
1110-
]);
1111-
}
1112-
1113-
test_typeArgumentNotMatchingBounds_functionReturnType() async {
1114-
await assertErrorsInCode(r'''
1115-
class A {}
1116-
class B {}
1117-
class G<E extends A> {}
1118-
G<B> f() { return null; }
1119-
''', [
1120-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 48, 1),
1121-
]);
1122-
}
1123-
1124-
test_typeArgumentNotMatchingBounds_functionTypeAlias() async {
1125-
await assertErrorsInCode(r'''
1126-
class A {}
1127-
class B {}
1128-
class G<E extends A> {}
1129-
typedef G<B> f();
1130-
''', [
1131-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 56, 1),
1132-
]);
1133-
}
1134-
1135-
test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() async {
1136-
await assertErrorsInCode(r'''
1137-
class A {}
1138-
class B {}
1139-
class G<E extends A> {}
1140-
f(G<B> h()) {}
1141-
''', [
1142-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 50, 1),
1143-
]);
1144-
}
1145-
1146-
test_typeArgumentNotMatchingBounds_implements() async {
1147-
await assertErrorsInCode(r'''
1148-
class A {}
1149-
class B {}
1150-
class G<E extends A> {}
1151-
class C implements G<B>{}
1152-
''', [
1153-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 67, 1),
1154-
]);
1155-
}
1156-
1157-
test_typeArgumentNotMatchingBounds_is() async {
1158-
await assertErrorsInCode(r'''
1159-
class A {}
1160-
class B {}
1161-
class G<E extends A> {}
1162-
var b = 1 is G<B>;
1163-
''', [
1164-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 61, 1),
1165-
]);
1166-
}
1167-
1168-
test_typeArgumentNotMatchingBounds_methodInvocation_localFunction() async {
1169-
await assertErrorsInCode(r'''
1170-
class Point<T extends num> {
1171-
Point(T x, T y);
1172-
}
1173-
1174-
main() {
1175-
Point<T> f<T extends num>(T x, T y) {
1176-
return new Point<T>(x, y);
1177-
}
1178-
print(f<String>('hello', 'world'));
1179-
}
1180-
''', [
1181-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 145, 6),
1182-
]);
1183-
}
1184-
1185-
test_typeArgumentNotMatchingBounds_methodInvocation_method() async {
1186-
await assertErrorsInCode(r'''
1187-
class Point<T extends num> {
1188-
Point(T x, T y);
1189-
}
1190-
1191-
class PointFactory {
1192-
Point<T> point<T extends num>(T x, T y) {
1193-
return new Point<T>(x, y);
1194-
}
1195-
}
1196-
1197-
f(PointFactory factory) {
1198-
print(factory.point<String>('hello', 'world'));
1199-
}
1200-
''', [
1201-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 202, 6),
1202-
]);
1203-
}
1204-
1205-
test_typeArgumentNotMatchingBounds_methodInvocation_topLevelFunction() async {
1206-
await assertErrorsInCode(r'''
1207-
class Point<T extends num> {
1208-
Point(T x, T y);
1209-
}
1210-
1211-
Point<T> f<T extends num>(T x, T y) {
1212-
return new Point<T>(x, y);
1213-
}
1214-
1215-
main() {
1216-
print(f<String>('hello', 'world'));
1217-
}
1218-
''', [
1219-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 140, 6),
1220-
]);
1221-
}
1222-
1223-
test_typeArgumentNotMatchingBounds_methodReturnType() async {
1224-
await assertErrorsInCode(r'''
1225-
class A {}
1226-
class B {}
1227-
class G<E extends A> {}
1228-
class C {
1229-
G<B> m() { return null; }
1230-
}
1231-
''', [
1232-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 60, 1),
1233-
]);
1234-
}
1235-
1236-
test_typeArgumentNotMatchingBounds_new() async {
1237-
await assertErrorsInCode(r'''
1238-
class A {}
1239-
class B {}
1240-
class G<E extends A> {}
1241-
f() { return new G<B>(); }
1242-
''', [
1243-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 65, 1),
1244-
]);
1245-
}
1246-
1247-
test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() async {
1248-
await assertErrorsInCode(r'''
1249-
class A {}
1250-
class B extends A {}
1251-
class C extends B {}
1252-
class G<E extends B> {}
1253-
f() { return new G<A>(); }
1254-
''', [
1255-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 96, 1),
1256-
]);
1257-
}
1258-
1259-
test_typeArgumentNotMatchingBounds_ofFunctionTypeAlias() async {
1260-
await assertErrorsInCode(r'''
1261-
class A {}
1262-
class B {}
1263-
typedef F<T extends A>();
1264-
F<B> fff;
1265-
''', [
1266-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 50, 1),
1267-
]);
1268-
}
1269-
1270-
test_typeArgumentNotMatchingBounds_parameter() async {
1271-
await assertErrorsInCode(r'''
1272-
class A {}
1273-
class B {}
1274-
class G<E extends A> {}
1275-
f(G<B> g) {}
1276-
''', [
1277-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 50, 1),
1278-
]);
1279-
}
1280-
1281-
test_typeArgumentNotMatchingBounds_redirectingConstructor() async {
1282-
await assertErrorsInCode(r'''
1283-
class A {}
1284-
class B {}
1285-
class X<T extends A> {
1286-
X(int x, int y) {}
1287-
factory X.name(int x, int y) = X<B>;
1288-
}
1289-
''', [
1290-
error(StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE, 99, 4),
1291-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 101, 1),
1292-
]);
1293-
}
1294-
1295-
test_typeArgumentNotMatchingBounds_typeArgumentList() async {
1296-
await assertErrorsInCode(r'''
1297-
class A {}
1298-
class B {}
1299-
class C<E> {}
1300-
class D<E extends A> {}
1301-
C<D<B>> Var;
1302-
''', [
1303-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 64, 1),
1304-
]);
1305-
}
1306-
1307-
test_typeArgumentNotMatchingBounds_typeParameter() async {
1308-
await assertErrorsInCode(r'''
1309-
class A {}
1310-
class B {}
1311-
class C {}
1312-
class G<E extends A> {}
1313-
class D<F extends G<B>> {}
1314-
''', [
1315-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 77, 1),
1316-
]);
1317-
}
1318-
1319-
test_typeArgumentNotMatchingBounds_variableDeclaration() async {
1320-
await assertErrorsInCode(r'''
1321-
class A {}
1322-
class B {}
1323-
class G<E extends A> {}
1324-
G<B> g;
1325-
''', [
1326-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 48, 1),
1327-
]);
1328-
}
1329-
1330-
test_typeArgumentNotMatchingBounds_with() async {
1331-
await assertErrorsInCode(r'''
1332-
class A {}
1333-
class B {}
1334-
class G<E extends A> {}
1335-
class C extends Object with G<B>{}
1336-
''', [
1337-
error(CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, 76, 1),
1338-
]);
1339-
}
1340-
13411066
test_typeParameterSupertypeOfItsBound() async {
13421067
await assertErrorsInCode(r'''
13431068
class A<T extends T> {

pkg/analyzer/test/src/diagnostics/test_all.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ import 'subtype_of_sealed_class_test.dart' as subtype_of_sealed_class;
253253
import 'super_in_extension_test.dart' as super_in_extension;
254254
import 'top_level_instance_getter_test.dart' as top_level_instance_getter;
255255
import 'top_level_instance_method_test.dart' as top_level_instance_method;
256+
import 'type_argument_not_matching_bounds_test.dart'
257+
as type_argument_not_matching_bounds;
256258
import 'type_check_is_not_null_test.dart' as type_check_is_not_null;
257259
import 'type_check_is_null_test.dart' as type_check_is_null;
258260
import 'unchecked_use_of_nullable_value_test.dart'
@@ -464,6 +466,7 @@ main() {
464466
super_in_extension.main();
465467
top_level_instance_getter.main();
466468
top_level_instance_method.main();
469+
type_argument_not_matching_bounds.main();
467470
type_check_is_not_null.main();
468471
type_check_is_null.main();
469472
unchecked_use_of_nullable_value.main();

0 commit comments

Comments
 (0)