@@ -1071,5 +1071,61 @@ abstract class SubtypeTest<T, E> {
1071
1071
isSubtype ("ExtendedClass" , "Extension" );
1072
1072
isSubtype ("ExtendedGenericClass<num>" , "GenericExtension<num>" );
1073
1073
isSubtype ("ExtendedSubclass" , "Extension" );
1074
+
1075
+ // Records.
1076
+ isSubtype ("Never" , "(int, String)" );
1077
+ isSubtype ("(int, String)" , "Object" );
1078
+ isSubtype ("(int, String)" , "(Object, Object)" );
1079
+ isSubtype ("(Never, Never)" , "(int, String)" );
1080
+ isSubtype ("(int, String)" , "(num, Object)" );
1081
+ isSubtype ("Never" , "(int, {String foo})" );
1082
+ isSubtype ("(int, {String foo})" , "Object" );
1083
+ isSubtype ("(int, {String foo})" , "(Object, {Object foo})" );
1084
+ isSubtype ("(Never, {Never foo})" , "(int, {String foo})" );
1085
+ isSubtype ("(int, {String foo})" , "(num, {Object foo})" );
1086
+ isObliviousSubtype ("Null" , "(int, String)" );
1087
+ isNotSubtype ("(int, String)" , "Null" );
1088
+ isNotSubtype ("(int, String, bool)" , "(int, String)" );
1089
+ isNotSubtype ("(int, String)" , "(int, String, bool)" );
1090
+ isNotSubtype ("(int, {String foo})" , "(int, {String foo, bool bar})" );
1091
+ isNotSubtype ("(int, {String foo, bool bar})" , "(int, {String foo})" );
1092
+ isNotSubtype ("(int, Never)" , "Never" );
1093
+ isSubtype ("((int, String), bool)" , "((num, Object), Object)" );
1094
+ isNotSubtype ("((int, String), bool)" , "(num, (Object, Object))" );
1095
+ isSubtype ("(int, String)" , "Record" );
1096
+ isSubtype ("(int, {String foo})" , "Record" );
1097
+ isSubtype ("({int foo, String bar})" , "Record" );
1098
+ isNotSubtype ("Record" , "(int, String)" );
1099
+ isSubtype ("Record" , "Object" );
1100
+ isSubtype ("Never" , "Record" );
1101
+ isObliviousSubtype ("Null" , "Record" );
1102
+ isNotSubtype ("(int, String)" , "Function" );
1103
+ isNotSubtype ("Function" , "(int, String)" );
1104
+ isNotSubtype ("(int, String)" , "(int, String) -> void" );
1105
+ isNotSubtype ("(int, String) -> void" , "(int, String)" );
1106
+ isNotSubtype ("(int, String)" , "int" );
1107
+ isNotSubtype ("int" , "(int, String)" );
1108
+ isSubtype ("(int, String)" , "FutureOr<(int, String)>" );
1109
+ isNotSubtype ("FutureOr<(int, String)>" , "(int, String)" );
1110
+ isSubtype ("T" , "(int, String)" , typeParameters: "T extends (int, String)" );
1111
+ isNotSubtype ("(int, String)" , "T" ,
1112
+ typeParameters: "T extends (int, String)" );
1113
+ isSubtype ("T & (int, String)" , "(int, String)" ,
1114
+ typeParameters: "T extends Record" );
1115
+ isSubtype ("T & (int, String)" , "(int, String)" ,
1116
+ typeParameters: "T extends Object?" );
1117
+ isSubtype ("T & (int, double)" , "(num, num)" ,
1118
+ typeParameters: "T extends Record" );
1119
+ isSubtype ("T & (int, double)" , "(num, num)" ,
1120
+ typeParameters: "T extends Object?" );
1121
+ isNotSubtype ("(int, String)" , "T & (int, String)" ,
1122
+ typeParameters: "T extends Record" );
1123
+ isNotSubtype ("(int, String)" , "T & (int, String)" ,
1124
+ typeParameters: "T extends Object?" );
1125
+ isSubtype ("(int, String)" , "(int, String)?" );
1126
+ isObliviousSubtype ("(int, String)?" , "(int, String)" );
1127
+ isSubtype ("Null" , "(int, String)?" );
1128
+ isObliviousSubtype ("Null" , "(int, String)" );
1129
+ isObliviousSubtype ("(int, String)?" , "Record" );
1074
1130
}
1075
1131
}
0 commit comments