| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library subtype_test; | 5 library subtype_test; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import "package:async_helper/async_helper.dart"; |
| 8 import 'type_test_helper.dart'; | 9 import 'type_test_helper.dart'; |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; | 10 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; |
| 10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t" | 11 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t" |
| 11 show Element, ClassElement; | 12 show Element, ClassElement; |
| 12 | 13 |
| 13 void main() { | 14 void main() { |
| 14 testInterfaceSubtype(); | 15 testInterfaceSubtype(); |
| 15 testCallableSubtype(); | 16 testCallableSubtype(); |
| 16 testFunctionSubtyping(); | 17 testFunctionSubtyping(); |
| 17 testTypedefSubtyping(); | 18 testTypedefSubtyping(); |
| 18 testFunctionSubtypingOptional(); | 19 testFunctionSubtypingOptional(); |
| 19 testTypedefSubtypingOptional(); | 20 testTypedefSubtypingOptional(); |
| 20 testFunctionSubtypingNamed(); | 21 testFunctionSubtypingNamed(); |
| 21 testTypedefSubtypingNamed(); | 22 testTypedefSubtypingNamed(); |
| 22 testTypeVariableSubtype(); | 23 testTypeVariableSubtype(); |
| 23 } | 24 } |
| 24 | 25 |
| 25 void testInterfaceSubtype() { | 26 void testInterfaceSubtype() { |
| 26 var env = new TypeEnvironment(r""" | 27 asyncTest(() => TypeEnvironment.create(r""" |
| 27 class A<T> {} | 28 class A<T> {} |
| 28 class B<T1, T2> extends A<T1> {} | 29 class B<T1, T2> extends A<T1> {} |
| 29 // TODO(johnniwinther): Inheritance with different type arguments is | 30 // TODO(johnniwinther): Inheritance with different type arguments is |
| 30 // currently not supported by the implementation. | 31 // currently not supported by the implementation. |
| 31 class C<T1, T2> extends B<T2, T1> /*implements A<A<T1>>*/ {} | 32 class C<T1, T2> extends B<T2, T1> /*implements A<A<T1>>*/ {} |
| 32 """); | 33 """).then((env) { |
| 33 | 34 |
| 34 void expect(bool value, DartType T, DartType S) { | 35 void expect(bool value, DartType T, DartType S) { |
| 35 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); | 36 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); |
| 36 } | 37 } |
| 37 | 38 |
| 38 ClassElement A = env.getElement('A'); | 39 ClassElement A = env.getElement('A'); |
| 39 ClassElement B = env.getElement('B'); | 40 ClassElement B = env.getElement('B'); |
| 40 ClassElement C = env.getElement('C'); | 41 ClassElement C = env.getElement('C'); |
| 41 DartType Object_ = env['Object']; | 42 DartType Object_ = env['Object']; |
| 42 DartType num_ = env['num']; | 43 DartType num_ = env['num']; |
| 43 DartType int_ = env['int']; | 44 DartType int_ = env['int']; |
| 44 DartType String_ = env['String']; | 45 DartType String_ = env['String']; |
| 45 DartType dynamic_ = env['dynamic']; | 46 DartType dynamic_ = env['dynamic']; |
| 46 | 47 |
| 47 expect(true, Object_, Object_); | 48 expect(true, Object_, Object_); |
| 48 expect(true, num_, Object_); | 49 expect(true, num_, Object_); |
| 49 expect(true, int_, Object_); | 50 expect(true, int_, Object_); |
| 50 expect(true, String_, Object_); | 51 expect(true, String_, Object_); |
| 51 expect(true, dynamic_, Object_); | 52 expect(true, dynamic_, Object_); |
| 52 | 53 |
| 53 expect(false, Object_, num_); | 54 expect(false, Object_, num_); |
| 54 expect(true, num_, num_); | 55 expect(true, num_, num_); |
| 55 expect(true, int_, num_); | 56 expect(true, int_, num_); |
| 56 expect(false, String_, num_); | 57 expect(false, String_, num_); |
| 57 expect(true, dynamic_, num_); | 58 expect(true, dynamic_, num_); |
| 58 | 59 |
| 59 expect(false, Object_, int_); | 60 expect(false, Object_, int_); |
| 60 expect(false, num_, int_); | 61 expect(false, num_, int_); |
| 61 expect(true, int_, int_); | 62 expect(true, int_, int_); |
| 62 expect(false, String_, int_); | 63 expect(false, String_, int_); |
| 63 expect(true, dynamic_, int_); | 64 expect(true, dynamic_, int_); |
| 64 | 65 |
| 65 expect(false, Object_, String_); | 66 expect(false, Object_, String_); |
| 66 expect(false, num_, String_); | 67 expect(false, num_, String_); |
| 67 expect(false, int_, String_); | 68 expect(false, int_, String_); |
| 68 expect(true, String_, String_); | 69 expect(true, String_, String_); |
| 69 expect(true, dynamic_, String_); | 70 expect(true, dynamic_, String_); |
| 70 | 71 |
| 71 expect(true, Object_, dynamic_); | 72 expect(true, Object_, dynamic_); |
| 72 expect(true, num_, dynamic_); | 73 expect(true, num_, dynamic_); |
| 73 expect(true, int_, dynamic_); | 74 expect(true, int_, dynamic_); |
| 74 expect(true, String_, dynamic_); | 75 expect(true, String_, dynamic_); |
| 75 expect(true, dynamic_, dynamic_); | 76 expect(true, dynamic_, dynamic_); |
| 76 | 77 |
| 77 DartType A_Object = instantiate(A, [Object_]); | 78 DartType A_Object = instantiate(A, [Object_]); |
| 78 DartType A_num = instantiate(A, [num_]); | 79 DartType A_num = instantiate(A, [num_]); |
| 79 DartType A_int = instantiate(A, [int_]); | 80 DartType A_int = instantiate(A, [int_]); |
| 80 DartType A_String = instantiate(A, [String_]); | 81 DartType A_String = instantiate(A, [String_]); |
| 81 DartType A_dynamic = instantiate(A, [dynamic_]); | 82 DartType A_dynamic = instantiate(A, [dynamic_]); |
| 82 | 83 |
| 83 expect(true, A_Object, Object_); | 84 expect(true, A_Object, Object_); |
| 84 expect(false, A_Object, num_); | 85 expect(false, A_Object, num_); |
| 85 expect(false, A_Object, int_); | 86 expect(false, A_Object, int_); |
| 86 expect(false, A_Object, String_); | 87 expect(false, A_Object, String_); |
| 87 expect(true, A_Object, dynamic_); | 88 expect(true, A_Object, dynamic_); |
| 88 | 89 |
| 89 expect(true, A_Object, A_Object); | 90 expect(true, A_Object, A_Object); |
| 90 expect(true, A_num, A_Object); | 91 expect(true, A_num, A_Object); |
| 91 expect(true, A_int, A_Object); | 92 expect(true, A_int, A_Object); |
| 92 expect(true, A_String, A_Object); | 93 expect(true, A_String, A_Object); |
| 93 expect(true, A_dynamic, A_Object); | 94 expect(true, A_dynamic, A_Object); |
| 94 | 95 |
| 95 expect(false, A_Object, A_num); | 96 expect(false, A_Object, A_num); |
| 96 expect(true, A_num, A_num); | 97 expect(true, A_num, A_num); |
| 97 expect(true, A_int, A_num); | 98 expect(true, A_int, A_num); |
| 98 expect(false, A_String, A_num); | 99 expect(false, A_String, A_num); |
| 99 expect(true, A_dynamic, A_num); | 100 expect(true, A_dynamic, A_num); |
| 100 | 101 |
| 101 expect(false, A_Object, A_int); | 102 expect(false, A_Object, A_int); |
| 102 expect(false, A_num, A_int); | 103 expect(false, A_num, A_int); |
| 103 expect(true, A_int, A_int); | 104 expect(true, A_int, A_int); |
| 104 expect(false, A_String, A_int); | 105 expect(false, A_String, A_int); |
| 105 expect(true, A_dynamic, A_int); | 106 expect(true, A_dynamic, A_int); |
| 106 | 107 |
| 107 expect(false, A_Object, A_String); | 108 expect(false, A_Object, A_String); |
| 108 expect(false, A_num, A_String); | 109 expect(false, A_num, A_String); |
| 109 expect(false, A_int, A_String); | 110 expect(false, A_int, A_String); |
| 110 expect(true, A_String, A_String); | 111 expect(true, A_String, A_String); |
| 111 expect(true, A_dynamic, A_String); | 112 expect(true, A_dynamic, A_String); |
| 112 | 113 |
| 113 expect(true, A_Object, A_dynamic); | 114 expect(true, A_Object, A_dynamic); |
| 114 expect(true, A_num, A_dynamic); | 115 expect(true, A_num, A_dynamic); |
| 115 expect(true, A_int, A_dynamic); | 116 expect(true, A_int, A_dynamic); |
| 116 expect(true, A_String, A_dynamic); | 117 expect(true, A_String, A_dynamic); |
| 117 expect(true, A_dynamic, A_dynamic); | 118 expect(true, A_dynamic, A_dynamic); |
| 118 | 119 |
| 119 DartType B_Object_Object = instantiate(B, [Object_, Object_]); | 120 DartType B_Object_Object = instantiate(B, [Object_, Object_]); |
| 120 DartType B_num_num = instantiate(B, [num_, num_]); | 121 DartType B_num_num = instantiate(B, [num_, num_]); |
| 121 DartType B_int_num = instantiate(B, [int_, num_]); | 122 DartType B_int_num = instantiate(B, [int_, num_]); |
| 122 DartType B_dynamic_dynamic = instantiate(B, [dynamic_, dynamic_]); | 123 DartType B_dynamic_dynamic = instantiate(B, [dynamic_, dynamic_]); |
| 123 DartType B_String_dynamic = instantiate(B, [String_, dynamic_]); | 124 DartType B_String_dynamic = instantiate(B, [String_, dynamic_]); |
| 124 | 125 |
| 125 expect(true, B_Object_Object, Object_); | 126 expect(true, B_Object_Object, Object_); |
| 126 expect(true, B_Object_Object, A_Object); | 127 expect(true, B_Object_Object, A_Object); |
| 127 expect(false, B_Object_Object, A_num); | 128 expect(false, B_Object_Object, A_num); |
| 128 expect(false, B_Object_Object, A_int); | 129 expect(false, B_Object_Object, A_int); |
| 129 expect(false, B_Object_Object, A_String); | 130 expect(false, B_Object_Object, A_String); |
| 130 expect(true, B_Object_Object, A_dynamic); | 131 expect(true, B_Object_Object, A_dynamic); |
| 131 | 132 |
| 132 expect(true, B_num_num, Object_); | 133 expect(true, B_num_num, Object_); |
| 133 expect(true, B_num_num, A_Object); | 134 expect(true, B_num_num, A_Object); |
| 134 expect(true, B_num_num, A_num); | 135 expect(true, B_num_num, A_num); |
| 135 expect(false, B_num_num, A_int); | 136 expect(false, B_num_num, A_int); |
| 136 expect(false, B_num_num, A_String); | 137 expect(false, B_num_num, A_String); |
| 137 expect(true, B_num_num, A_dynamic); | 138 expect(true, B_num_num, A_dynamic); |
| 138 | 139 |
| 139 expect(true, B_int_num, Object_); | 140 expect(true, B_int_num, Object_); |
| 140 expect(true, B_int_num, A_Object); | 141 expect(true, B_int_num, A_Object); |
| 141 expect(true, B_int_num, A_num); | 142 expect(true, B_int_num, A_num); |
| 142 expect(true, B_int_num, A_int); | 143 expect(true, B_int_num, A_int); |
| 143 expect(false, B_int_num, A_String); | 144 expect(false, B_int_num, A_String); |
| 144 expect(true, B_int_num, A_dynamic); | 145 expect(true, B_int_num, A_dynamic); |
| 145 | 146 |
| 146 expect(true, B_dynamic_dynamic, Object_); | 147 expect(true, B_dynamic_dynamic, Object_); |
| 147 expect(true, B_dynamic_dynamic, A_Object); | 148 expect(true, B_dynamic_dynamic, A_Object); |
| 148 expect(true, B_dynamic_dynamic, A_num); | 149 expect(true, B_dynamic_dynamic, A_num); |
| 149 expect(true, B_dynamic_dynamic, A_int); | 150 expect(true, B_dynamic_dynamic, A_int); |
| 150 expect(true, B_dynamic_dynamic, A_String); | 151 expect(true, B_dynamic_dynamic, A_String); |
| 151 expect(true, B_dynamic_dynamic, A_dynamic); | 152 expect(true, B_dynamic_dynamic, A_dynamic); |
| 152 | 153 |
| 153 expect(true, B_String_dynamic, Object_); | 154 expect(true, B_String_dynamic, Object_); |
| 154 expect(true, B_String_dynamic, A_Object); | 155 expect(true, B_String_dynamic, A_Object); |
| 155 expect(false, B_String_dynamic, A_num); | 156 expect(false, B_String_dynamic, A_num); |
| 156 expect(false, B_String_dynamic, A_int); | 157 expect(false, B_String_dynamic, A_int); |
| 157 expect(true, B_String_dynamic, A_String); | 158 expect(true, B_String_dynamic, A_String); |
| 158 expect(true, B_String_dynamic, A_dynamic); | 159 expect(true, B_String_dynamic, A_dynamic); |
| 159 | 160 |
| 160 expect(true, B_Object_Object, B_Object_Object); | 161 expect(true, B_Object_Object, B_Object_Object); |
| 161 expect(true, B_num_num, B_Object_Object); | 162 expect(true, B_num_num, B_Object_Object); |
| 162 expect(true, B_int_num, B_Object_Object); | 163 expect(true, B_int_num, B_Object_Object); |
| 163 expect(true, B_dynamic_dynamic, B_Object_Object); | 164 expect(true, B_dynamic_dynamic, B_Object_Object); |
| 164 expect(true, B_String_dynamic, B_Object_Object); | 165 expect(true, B_String_dynamic, B_Object_Object); |
| 165 | 166 |
| 166 expect(false, B_Object_Object, B_num_num); | 167 expect(false, B_Object_Object, B_num_num); |
| 167 expect(true, B_num_num, B_num_num); | 168 expect(true, B_num_num, B_num_num); |
| 168 expect(true, B_int_num, B_num_num); | 169 expect(true, B_int_num, B_num_num); |
| 169 expect(true, B_dynamic_dynamic, B_num_num); | 170 expect(true, B_dynamic_dynamic, B_num_num); |
| 170 expect(false, B_String_dynamic, B_num_num); | 171 expect(false, B_String_dynamic, B_num_num); |
| 171 | 172 |
| 172 expect(false, B_Object_Object, B_int_num); | 173 expect(false, B_Object_Object, B_int_num); |
| 173 expect(false, B_num_num, B_int_num); | 174 expect(false, B_num_num, B_int_num); |
| 174 expect(true, B_int_num, B_int_num); | 175 expect(true, B_int_num, B_int_num); |
| 175 expect(true, B_dynamic_dynamic, B_int_num); | 176 expect(true, B_dynamic_dynamic, B_int_num); |
| 176 expect(false, B_String_dynamic, B_int_num); | 177 expect(false, B_String_dynamic, B_int_num); |
| 177 | 178 |
| 178 expect(true, B_Object_Object, B_dynamic_dynamic); | 179 expect(true, B_Object_Object, B_dynamic_dynamic); |
| 179 expect(true, B_num_num, B_dynamic_dynamic); | 180 expect(true, B_num_num, B_dynamic_dynamic); |
| 180 expect(true, B_int_num, B_dynamic_dynamic); | 181 expect(true, B_int_num, B_dynamic_dynamic); |
| 181 expect(true, B_dynamic_dynamic, B_dynamic_dynamic); | 182 expect(true, B_dynamic_dynamic, B_dynamic_dynamic); |
| 182 expect(true, B_String_dynamic, B_dynamic_dynamic); | 183 expect(true, B_String_dynamic, B_dynamic_dynamic); |
| 183 | 184 |
| 184 expect(false, B_Object_Object, B_String_dynamic); | 185 expect(false, B_Object_Object, B_String_dynamic); |
| 185 expect(false, B_num_num, B_String_dynamic); | 186 expect(false, B_num_num, B_String_dynamic); |
| 186 expect(false, B_int_num, B_String_dynamic); | 187 expect(false, B_int_num, B_String_dynamic); |
| 187 expect(true, B_dynamic_dynamic, B_String_dynamic); | 188 expect(true, B_dynamic_dynamic, B_String_dynamic); |
| 188 expect(true, B_String_dynamic, B_String_dynamic); | 189 expect(true, B_String_dynamic, B_String_dynamic); |
| 189 | 190 |
| 190 DartType C_Object_Object = instantiate(C, [Object_, Object_]); | 191 DartType C_Object_Object = instantiate(C, [Object_, Object_]); |
| 191 DartType C_num_num = instantiate(C, [num_, num_]); | 192 DartType C_num_num = instantiate(C, [num_, num_]); |
| 192 DartType C_int_String = instantiate(C, [int_, String_]); | 193 DartType C_int_String = instantiate(C, [int_, String_]); |
| 193 DartType C_dynamic_dynamic = instantiate(C, [dynamic_, dynamic_]); | 194 DartType C_dynamic_dynamic = instantiate(C, [dynamic_, dynamic_]); |
| 194 | 195 |
| 195 expect(true, C_Object_Object, B_Object_Object); | 196 expect(true, C_Object_Object, B_Object_Object); |
| 196 expect(false, C_Object_Object, B_num_num); | 197 expect(false, C_Object_Object, B_num_num); |
| 197 expect(false, C_Object_Object, B_int_num); | 198 expect(false, C_Object_Object, B_int_num); |
| 198 expect(true, C_Object_Object, B_dynamic_dynamic); | 199 expect(true, C_Object_Object, B_dynamic_dynamic); |
| 199 expect(false, C_Object_Object, B_String_dynamic); | 200 expect(false, C_Object_Object, B_String_dynamic); |
| 200 | 201 |
| 201 expect(true, C_num_num, B_Object_Object); | 202 expect(true, C_num_num, B_Object_Object); |
| 202 expect(true, C_num_num, B_num_num); | 203 expect(true, C_num_num, B_num_num); |
| 203 expect(false, C_num_num, B_int_num); | 204 expect(false, C_num_num, B_int_num); |
| 204 expect(true, C_num_num, B_dynamic_dynamic); | 205 expect(true, C_num_num, B_dynamic_dynamic); |
| 205 expect(false, C_num_num, B_String_dynamic); | 206 expect(false, C_num_num, B_String_dynamic); |
| 206 | 207 |
| 207 expect(true, C_int_String, B_Object_Object); | 208 expect(true, C_int_String, B_Object_Object); |
| 208 expect(false, C_int_String, B_num_num); | 209 expect(false, C_int_String, B_num_num); |
| 209 expect(false, C_int_String, B_int_num); | 210 expect(false, C_int_String, B_int_num); |
| 210 expect(true, C_int_String, B_dynamic_dynamic); | 211 expect(true, C_int_String, B_dynamic_dynamic); |
| 211 expect(true, C_int_String, B_String_dynamic); | 212 expect(true, C_int_String, B_String_dynamic); |
| 212 | 213 |
| 213 expect(true, C_dynamic_dynamic, B_Object_Object); | 214 expect(true, C_dynamic_dynamic, B_Object_Object); |
| 214 expect(true, C_dynamic_dynamic, B_num_num); | 215 expect(true, C_dynamic_dynamic, B_num_num); |
| 215 expect(true, C_dynamic_dynamic, B_int_num); | 216 expect(true, C_dynamic_dynamic, B_int_num); |
| 216 expect(true, C_dynamic_dynamic, B_dynamic_dynamic); | 217 expect(true, C_dynamic_dynamic, B_dynamic_dynamic); |
| 217 expect(true, C_dynamic_dynamic, B_String_dynamic); | 218 expect(true, C_dynamic_dynamic, B_String_dynamic); |
| 218 | 219 |
| 219 expect(false, C_int_String, A_int); | 220 expect(false, C_int_String, A_int); |
| 220 expect(true, C_int_String, A_String); | 221 expect(true, C_int_String, A_String); |
| 221 // TODO(johnniwinther): Inheritance with different type arguments is | 222 // TODO(johnniwinther): Inheritance with different type arguments is |
| 222 // currently not supported by the implementation. | 223 // currently not supported by the implementation. |
| 223 //expect(true, C_int_String, instantiate(A, [A_int])); | 224 //expect(true, C_int_String, instantiate(A, [A_int])); |
| 224 expect(false, C_int_String, instantiate(A, [A_String])); | 225 expect(false, C_int_String, instantiate(A, [A_String])); |
| 226 })); |
| 225 } | 227 } |
| 226 | 228 |
| 227 void testCallableSubtype() { | 229 void testCallableSubtype() { |
| 228 | 230 asyncTest(() => TypeEnvironment.create(r""" |
| 229 var env = new TypeEnvironment(r""" | |
| 230 class U {} | 231 class U {} |
| 231 class V extends U {} | 232 class V extends U {} |
| 232 class W extends V {} | 233 class W extends V {} |
| 233 class A { | 234 class A { |
| 234 int call(V v, int i); | 235 int call(V v, int i); |
| 235 | 236 |
| 236 int m1(U u, int i); | 237 int m1(U u, int i); |
| 237 int m2(W w, num n); | 238 int m2(W w, num n); |
| 238 U m3(V v, int i); | 239 U m3(V v, int i); |
| 239 int m4(V v, U u); | 240 int m4(V v, U u); |
| 240 void m5(V v, int i); | 241 void m5(V v, int i); |
| 241 } | 242 } |
| 242 """); | 243 """).then((env) { |
| 244 void expect(bool value, DartType T, DartType S) { |
| 245 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); |
| 246 } |
| 243 | 247 |
| 244 void expect(bool value, DartType T, DartType S) { | 248 ClassElement classA = env.getElement('A'); |
| 245 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); | 249 DartType A = classA.rawType; |
| 246 } | 250 DartType function = env['Function']; |
| 251 DartType m1 = env.getMemberType(classA, 'm1'); |
| 252 DartType m2 = env.getMemberType(classA, 'm2'); |
| 253 DartType m3 = env.getMemberType(classA, 'm3'); |
| 254 DartType m4 = env.getMemberType(classA, 'm4'); |
| 255 DartType m5 = env.getMemberType(classA, 'm5'); |
| 247 | 256 |
| 248 ClassElement classA = env.getElement('A'); | 257 expect(true, A, function); |
| 249 DartType A = classA.rawType; | 258 expect(true, A, m1); |
| 250 DartType function = env['Function']; | 259 expect(true, A, m2); |
| 251 DartType m1 = env.getMemberType(classA, 'm1'); | 260 expect(false, A, m3); |
| 252 DartType m2 = env.getMemberType(classA, 'm2'); | 261 expect(false, A, m4); |
| 253 DartType m3 = env.getMemberType(classA, 'm3'); | 262 expect(true, A, m5); |
| 254 DartType m4 = env.getMemberType(classA, 'm4'); | 263 })); |
| 255 DartType m5 = env.getMemberType(classA, 'm5'); | |
| 256 | |
| 257 expect(true, A, function); | |
| 258 expect(true, A, m1); | |
| 259 expect(true, A, m2); | |
| 260 expect(false, A, m3); | |
| 261 expect(false, A, m4); | |
| 262 expect(true, A, m5); | |
| 263 } | 264 } |
| 264 | 265 |
| 265 testFunctionSubtyping() { | 266 testFunctionSubtyping() { |
| 266 var env = new TypeEnvironment(r""" | 267 asyncTest(() => TypeEnvironment.create(r""" |
| 267 _() => null; | 268 _() => null; |
| 268 void void_() {} | 269 void void_() {} |
| 269 void void_2() {} | 270 void void_2() {} |
| 270 int int_() => 0; | 271 int int_() => 0; |
| 271 int int_2() => 0; | 272 int int_2() => 0; |
| 272 Object Object_() => null; | 273 Object Object_() => null; |
| 273 double double_() => 0.0; | 274 double double_() => 0.0; |
| 274 void void__int(int i) {} | 275 void void__int(int i) {} |
| 275 int int__int(int i) => 0; | 276 int int__int(int i) => 0; |
| 276 int int__int2(int i) => 0; | 277 int int__int2(int i) => 0; |
| 277 int int__Object(Object o) => 0; | 278 int int__Object(Object o) => 0; |
| 278 Object Object__int(int i) => null; | 279 Object Object__int(int i) => null; |
| 279 int int__double(double d) => 0; | 280 int int__double(double d) => 0; |
| 280 int int__int_int(int i1, int i2) => 0; | 281 int int__int_int(int i1, int i2) => 0; |
| 281 void inline_void_(void f()) {} | 282 void inline_void_(void f()) {} |
| 282 void inline_void__int(void f(int i)) {} | 283 void inline_void__int(void f(int i)) {} |
| 283 """); | 284 """).then(functionSubtypingHelper)); |
| 284 functionSubtypingHelper(env); | |
| 285 } | 285 } |
| 286 | 286 |
| 287 testTypedefSubtyping() { | 287 testTypedefSubtyping() { |
| 288 var env = new TypeEnvironment(r""" | 288 asyncTest(() => TypeEnvironment.create(r""" |
| 289 typedef _(); | 289 typedef _(); |
| 290 typedef void void_(); | 290 typedef void void_(); |
| 291 typedef void void_2(); | 291 typedef void void_2(); |
| 292 typedef int int_(); | 292 typedef int int_(); |
| 293 typedef int int_2(); | 293 typedef int int_2(); |
| 294 typedef Object Object_(); | 294 typedef Object Object_(); |
| 295 typedef double double_(); | 295 typedef double double_(); |
| 296 typedef void void__int(int i); | 296 typedef void void__int(int i); |
| 297 typedef int int__int(int i); | 297 typedef int int__int(int i); |
| 298 typedef int int__int2(int i); | 298 typedef int int__int2(int i); |
| 299 typedef int int__Object(Object o); | 299 typedef int int__Object(Object o); |
| 300 typedef Object Object__int(int i); | 300 typedef Object Object__int(int i); |
| 301 typedef int int__double(double d); | 301 typedef int int__double(double d); |
| 302 typedef int int__int_int(int i1, int i2); | 302 typedef int int__int_int(int i1, int i2); |
| 303 typedef void inline_void_(void f()); | 303 typedef void inline_void_(void f()); |
| 304 typedef void inline_void__int(void f(int i)); | 304 typedef void inline_void__int(void f(int i)); |
| 305 """); | 305 """).then(functionSubtypingHelper)); |
| 306 functionSubtypingHelper(env); | |
| 307 } | 306 } |
| 308 | 307 |
| 309 functionSubtypingHelper(TypeEnvironment env) { | 308 functionSubtypingHelper(TypeEnvironment env) { |
| 310 void expect(bool expectedResult, String sub, String sup) { | 309 void expect(bool expectedResult, String sub, String sup) { |
| 311 DartType subtype = env.getElementType(sub); | 310 DartType subtype = env.getElementType(sub); |
| 312 DartType supertype = env.getElementType(sup); | 311 DartType supertype = env.getElementType(sup); |
| 313 Expect.equals(expectedResult, env.isSubtype(subtype, supertype), | 312 Expect.equals(expectedResult, env.isSubtype(subtype, supertype), |
| 314 '$subtype <: $supertype'); | 313 '$subtype <: $supertype'); |
| 315 } | 314 } |
| 316 | 315 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 expect(false, 'int__int', 'int__int_int'); | 355 expect(false, 'int__int', 'int__int_int'); |
| 357 // (int,int) -> int <: (int) -> int | 356 // (int,int) -> int <: (int) -> int |
| 358 expect(false, 'int__int_int', 'int__int'); | 357 expect(false, 'int__int_int', 'int__int'); |
| 359 // (()->void) -> void <: ((int)->void) -> void | 358 // (()->void) -> void <: ((int)->void) -> void |
| 360 expect(false, 'inline_void_', 'inline_void__int'); | 359 expect(false, 'inline_void_', 'inline_void__int'); |
| 361 // ((int)->void) -> void <: (()->void) -> void | 360 // ((int)->void) -> void <: (()->void) -> void |
| 362 expect(false, 'inline_void__int', 'inline_void_'); | 361 expect(false, 'inline_void__int', 'inline_void_'); |
| 363 } | 362 } |
| 364 | 363 |
| 365 testFunctionSubtypingOptional() { | 364 testFunctionSubtypingOptional() { |
| 366 var env = new TypeEnvironment(r""" | 365 asyncTest(() => TypeEnvironment.create(r""" |
| 367 void void_() {} | 366 void void_() {} |
| 368 void void__int(int i) {} | 367 void void__int(int i) {} |
| 369 void void___int([int i]) {} | 368 void void___int([int i]) {} |
| 370 void void___int2([int i]) {} | 369 void void___int2([int i]) {} |
| 371 void void___Object([Object o]) {} | 370 void void___Object([Object o]) {} |
| 372 void void__int__int(int i1, [int i2]) {} | 371 void void__int__int(int i1, [int i2]) {} |
| 373 void void__int__int2(int i1, [int i2]) {} | 372 void void__int__int2(int i1, [int i2]) {} |
| 374 void void__int__int_int(int i1, [int i2, int i3]); | 373 void void__int__int_int(int i1, [int i2, int i3]); |
| 375 void void___double(double d) {} | 374 void void___double(double d) {} |
| 376 void void___int_int([int i1, int i2]) {} | 375 void void___int_int([int i1, int i2]) {} |
| 377 void void___int_int_int([int i1, int i2, int i3]); | 376 void void___int_int_int([int i1, int i2, int i3]); |
| 378 void void___Object_int([Object o, int i]) {} | 377 void void___Object_int([Object o, int i]) {} |
| 379 """); | 378 """).then(functionSubtypingOptionalHelper)); |
| 380 functionSubtypingOptionalHelper(env); | |
| 381 } | 379 } |
| 382 | 380 |
| 383 testTypedefSubtypingOptional() { | 381 testTypedefSubtypingOptional() { |
| 384 var env = new TypeEnvironment(r""" | 382 asyncTest(() => TypeEnvironment.create(r""" |
| 385 typedef void void_(); | 383 typedef void void_(); |
| 386 typedef void void__int(int i); | 384 typedef void void__int(int i); |
| 387 typedef void void___int([int i]); | 385 typedef void void___int([int i]); |
| 388 typedef void void___int2([int i]); | 386 typedef void void___int2([int i]); |
| 389 typedef void void___Object([Object o]); | 387 typedef void void___Object([Object o]); |
| 390 typedef void void__int__int(int i1, [int i2]); | 388 typedef void void__int__int(int i1, [int i2]); |
| 391 typedef void void__int__int2(int i1, [int i2]); | 389 typedef void void__int__int2(int i1, [int i2]); |
| 392 typedef void void__int__int_int(int i1, [int i2, int i3]); | 390 typedef void void__int__int_int(int i1, [int i2, int i3]); |
| 393 typedef void void___double(double d); | 391 typedef void void___double(double d); |
| 394 typedef void void___int_int([int i1, int i2]); | 392 typedef void void___int_int([int i1, int i2]); |
| 395 typedef void void___int_int_int([int i1, int i2, int i3]); | 393 typedef void void___int_int_int([int i1, int i2, int i3]); |
| 396 typedef void void___Object_int([Object o, int i]); | 394 typedef void void___Object_int([Object o, int i]); |
| 397 """); | 395 """).then(functionSubtypingOptionalHelper)); |
| 398 functionSubtypingOptionalHelper(env); | |
| 399 } | 396 } |
| 400 | 397 |
| 401 functionSubtypingOptionalHelper(TypeEnvironment env) { | 398 functionSubtypingOptionalHelper(TypeEnvironment env) { |
| 402 expect(bool expectedResult, String sub, String sup) { | 399 expect(bool expectedResult, String sub, String sup) { |
| 403 DartType subtype = env.getElementType(sub); | 400 DartType subtype = env.getElementType(sub); |
| 404 DartType supertype = env.getElementType(sup); | 401 DartType supertype = env.getElementType(sup); |
| 405 Expect.equals(expectedResult, env.isSubtype(subtype, supertype), | 402 Expect.equals(expectedResult, env.isSubtype(subtype, supertype), |
| 406 '$subtype <: $supertype'); | 403 '$subtype <: $supertype'); |
| 407 } | 404 } |
| 408 | 405 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 436 expect(false, 'void___int', 'void___double'); | 433 expect(false, 'void___int', 'void___double'); |
| 437 // Test ([int])->void <: ([int,int])->void. | 434 // Test ([int])->void <: ([int,int])->void. |
| 438 expect(false, 'void___int', 'void___int_int'); | 435 expect(false, 'void___int', 'void___int_int'); |
| 439 // Test ([int,int])->void <: ([int])->void. | 436 // Test ([int,int])->void <: ([int])->void. |
| 440 expect(true, 'void___int_int', 'void___int'); | 437 expect(true, 'void___int_int', 'void___int'); |
| 441 // Test ([Object,int])->void <: ([int])->void. | 438 // Test ([Object,int])->void <: ([int])->void. |
| 442 expect(true, 'void___Object_int', 'void___int'); | 439 expect(true, 'void___Object_int', 'void___int'); |
| 443 } | 440 } |
| 444 | 441 |
| 445 testFunctionSubtypingNamed() { | 442 testFunctionSubtypingNamed() { |
| 446 var env = new TypeEnvironment(r""" | 443 asyncTest(() => TypeEnvironment.create(r""" |
| 447 void void_() {} | 444 void void_() {} |
| 448 void void__int(int i) {} | 445 void void__int(int i) {} |
| 449 void void___a_int({int a}) {} | 446 void void___a_int({int a}) {} |
| 450 void void___a_int2({int a}) {} | 447 void void___a_int2({int a}) {} |
| 451 void void___b_int({int b}) {} | 448 void void___b_int({int b}) {} |
| 452 void void___a_Object({Object a}) {} | 449 void void___a_Object({Object a}) {} |
| 453 void void__int__a_int(int i1, {int a}) {} | 450 void void__int__a_int(int i1, {int a}) {} |
| 454 void void__int__a_int2(int i1, {int a}) {} | 451 void void__int__a_int2(int i1, {int a}) {} |
| 455 void void___a_double({double a}) {} | 452 void void___a_double({double a}) {} |
| 456 void void___a_int_b_int({int a, int b}) {} | 453 void void___a_int_b_int({int a, int b}) {} |
| 457 void void___a_int_b_int_c_int({int a, int b, int c}) {} | 454 void void___a_int_b_int_c_int({int a, int b, int c}) {} |
| 458 void void___a_int_c_int({int a, int c}) {} | 455 void void___a_int_c_int({int a, int c}) {} |
| 459 void void___b_int_c_int({int b, int c}) {} | 456 void void___b_int_c_int({int b, int c}) {} |
| 460 void void___c_int({int c}) {} | 457 void void___c_int({int c}) {} |
| 461 """); | 458 """).then(functionSubtypingNamedHelper)); |
| 462 functionSubtypingNamedHelper(env); | |
| 463 } | 459 } |
| 464 | 460 |
| 465 testTypedefSubtypingNamed() { | 461 testTypedefSubtypingNamed() { |
| 466 var env = new TypeEnvironment(r""" | 462 asyncTest(() => TypeEnvironment.create(r""" |
| 467 typedef void void_(); | 463 typedef void void_(); |
| 468 typedef void void__int(int i); | 464 typedef void void__int(int i); |
| 469 typedef void void___a_int({int a}); | 465 typedef void void___a_int({int a}); |
| 470 typedef void void___a_int2({int a}); | 466 typedef void void___a_int2({int a}); |
| 471 typedef void void___b_int({int b}); | 467 typedef void void___b_int({int b}); |
| 472 typedef void void___a_Object({Object a}); | 468 typedef void void___a_Object({Object a}); |
| 473 typedef void void__int__a_int(int i1, {int a}); | 469 typedef void void__int__a_int(int i1, {int a}); |
| 474 typedef void void__int__a_int2(int i1, {int a}); | 470 typedef void void__int__a_int2(int i1, {int a}); |
| 475 typedef void void___a_double({double a}); | 471 typedef void void___a_double({double a}); |
| 476 typedef void void___a_int_b_int({int a, int b}); | 472 typedef void void___a_int_b_int({int a, int b}); |
| 477 typedef void void___a_int_b_int_c_int({int a, int b, int c}); | 473 typedef void void___a_int_b_int_c_int({int a, int b, int c}); |
| 478 typedef void void___a_int_c_int({int a, int c}); | 474 typedef void void___a_int_c_int({int a, int c}); |
| 479 typedef void void___b_int_c_int({int b, int c}); | 475 typedef void void___b_int_c_int({int b, int c}); |
| 480 typedef void void___c_int({int c}); | 476 typedef void void___c_int({int c}); |
| 481 """); | 477 """).then(functionSubtypingNamedHelper)); |
| 482 functionSubtypingNamedHelper(env); | |
| 483 } | 478 } |
| 484 | 479 |
| 485 functionSubtypingNamedHelper(TypeEnvironment env) { | 480 functionSubtypingNamedHelper(TypeEnvironment env) { |
| 486 expect(bool expectedResult, String sub, String sup) { | 481 expect(bool expectedResult, String sub, String sup) { |
| 487 DartType subtype = env.getElementType(sub); | 482 DartType subtype = env.getElementType(sub); |
| 488 DartType supertype = env.getElementType(sup); | 483 DartType supertype = env.getElementType(sup); |
| 489 Expect.equals(expectedResult, env.isSubtype(subtype, supertype), | 484 Expect.equals(expectedResult, env.isSubtype(subtype, supertype), |
| 490 '$subtype <: $supertype'); | 485 '$subtype <: $supertype'); |
| 491 } | 486 } |
| 492 | 487 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 514 expect(true, 'void___a_int_b_int', 'void___a_int'); | 509 expect(true, 'void___a_int_b_int', 'void___a_int'); |
| 515 // Test ({int a,int b,int c})->void <: ({int a,int c})->void. | 510 // Test ({int a,int b,int c})->void <: ({int a,int c})->void. |
| 516 expect(true, 'void___a_int_b_int_c_int', 'void___a_int_c_int'); | 511 expect(true, 'void___a_int_b_int_c_int', 'void___a_int_c_int'); |
| 517 // Test ({int a,int b,int c})->void <: ({int b,int c})->void. | 512 // Test ({int a,int b,int c})->void <: ({int b,int c})->void. |
| 518 expect(true, 'void___a_int_b_int_c_int', 'void___b_int_c_int'); | 513 expect(true, 'void___a_int_b_int_c_int', 'void___b_int_c_int'); |
| 519 // Test ({int a,int b,int c})->void <: ({int c})->void. | 514 // Test ({int a,int b,int c})->void <: ({int c})->void. |
| 520 expect(true, 'void___a_int_b_int_c_int', 'void___c_int'); | 515 expect(true, 'void___a_int_b_int_c_int', 'void___c_int'); |
| 521 } | 516 } |
| 522 | 517 |
| 523 void testTypeVariableSubtype() { | 518 void testTypeVariableSubtype() { |
| 524 var env = new TypeEnvironment(r""" | 519 asyncTest(() => TypeEnvironment.create(r""" |
| 525 class A<T> {} | 520 class A<T> {} |
| 526 class B<T extends Object> {} | 521 class B<T extends Object> {} |
| 527 class C<T extends num> {} | 522 class C<T extends num> {} |
| 528 class D<T extends int> {} | 523 class D<T extends int> {} |
| 529 class E<T extends S, S extends num> {} | 524 class E<T extends S, S extends num> {} |
| 530 class F<T extends num, S extends T> {} | 525 class F<T extends num, S extends T> {} |
| 531 class G<T extends T> {} | 526 class G<T extends T> {} |
| 532 class H<T extends S, S extends T> {} | 527 class H<T extends S, S extends T> {} |
| 533 class I<T extends S, S extends U, U extends T> {} | 528 class I<T extends S, S extends U, U extends T> {} |
| 534 class J<T extends S, S extends U, U extends S> {} | 529 class J<T extends S, S extends U, U extends S> {} |
| 535 """); | 530 """).then((env) { |
| 536 | 531 void expect(bool value, DartType T, DartType S) { |
| 537 void expect(bool value, DartType T, DartType S) { | 532 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); |
| 538 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); | 533 } |
| 539 } | 534 |
| 540 | 535 ClassElement A = env.getElement('A'); |
| 541 ClassElement A = env.getElement('A'); | 536 TypeVariableType A_T = A.thisType.typeArguments.head; |
| 542 TypeVariableType A_T = A.thisType.typeArguments.head; | 537 ClassElement B = env.getElement('B'); |
| 543 ClassElement B = env.getElement('B'); | 538 TypeVariableType B_T = B.thisType.typeArguments.head; |
| 544 TypeVariableType B_T = B.thisType.typeArguments.head; | 539 ClassElement C = env.getElement('C'); |
| 545 ClassElement C = env.getElement('C'); | 540 TypeVariableType C_T = C.thisType.typeArguments.head; |
| 546 TypeVariableType C_T = C.thisType.typeArguments.head; | 541 ClassElement D = env.getElement('D'); |
| 547 ClassElement D = env.getElement('D'); | 542 TypeVariableType D_T = D.thisType.typeArguments.head; |
| 548 TypeVariableType D_T = D.thisType.typeArguments.head; | 543 ClassElement E = env.getElement('E'); |
| 549 ClassElement E = env.getElement('E'); | 544 TypeVariableType E_T = E.thisType.typeArguments.head; |
| 550 TypeVariableType E_T = E.thisType.typeArguments.head; | 545 TypeVariableType E_S = E.thisType.typeArguments.tail.head; |
| 551 TypeVariableType E_S = E.thisType.typeArguments.tail.head; | 546 ClassElement F = env.getElement('F'); |
| 552 ClassElement F = env.getElement('F'); | 547 TypeVariableType F_T = F.thisType.typeArguments.head; |
| 553 TypeVariableType F_T = F.thisType.typeArguments.head; | 548 TypeVariableType F_S = F.thisType.typeArguments.tail.head; |
| 554 TypeVariableType F_S = F.thisType.typeArguments.tail.head; | 549 ClassElement G = env.getElement('G'); |
| 555 ClassElement G = env.getElement('G'); | 550 TypeVariableType G_T = G.thisType.typeArguments.head; |
| 556 TypeVariableType G_T = G.thisType.typeArguments.head; | 551 ClassElement H = env.getElement('H'); |
| 557 ClassElement H = env.getElement('H'); | 552 TypeVariableType H_T = H.thisType.typeArguments.head; |
| 558 TypeVariableType H_T = H.thisType.typeArguments.head; | 553 TypeVariableType H_S = H.thisType.typeArguments.tail.head; |
| 559 TypeVariableType H_S = H.thisType.typeArguments.tail.head; | 554 ClassElement I = env.getElement('I'); |
| 560 ClassElement I = env.getElement('I'); | 555 TypeVariableType I_T = I.thisType.typeArguments.head; |
| 561 TypeVariableType I_T = I.thisType.typeArguments.head; | 556 TypeVariableType I_S = I.thisType.typeArguments.tail.head; |
| 562 TypeVariableType I_S = I.thisType.typeArguments.tail.head; | 557 TypeVariableType I_U = I.thisType.typeArguments.tail.tail.head; |
| 563 TypeVariableType I_U = I.thisType.typeArguments.tail.tail.head; | 558 ClassElement J = env.getElement('J'); |
| 564 ClassElement J = env.getElement('J'); | 559 TypeVariableType J_T = J.thisType.typeArguments.head; |
| 565 TypeVariableType J_T = J.thisType.typeArguments.head; | 560 TypeVariableType J_S = J.thisType.typeArguments.tail.head; |
| 566 TypeVariableType J_S = J.thisType.typeArguments.tail.head; | 561 TypeVariableType J_U = J.thisType.typeArguments.tail.tail.head; |
| 567 TypeVariableType J_U = J.thisType.typeArguments.tail.tail.head; | 562 |
| 568 | 563 DartType Object_ = env['Object']; |
| 569 DartType Object_ = env['Object']; | 564 DartType num_ = env['num']; |
| 570 DartType num_ = env['num']; | 565 DartType int_ = env['int']; |
| 571 DartType int_ = env['int']; | 566 DartType String_ = env['String']; |
| 572 DartType String_ = env['String']; | 567 DartType dynamic_ = env['dynamic']; |
| 573 DartType dynamic_ = env['dynamic']; | 568 |
| 574 | 569 // class A<T> {} |
| 575 // class A<T> {} | 570 expect(true, A_T, Object_); |
| 576 expect(true, A_T, Object_); | 571 expect(false, A_T, num_); |
| 577 expect(false, A_T, num_); | 572 expect(false, A_T, int_); |
| 578 expect(false, A_T, int_); | 573 expect(false, A_T, String_); |
| 579 expect(false, A_T, String_); | 574 expect(true, A_T, dynamic_); |
| 580 expect(true, A_T, dynamic_); | 575 expect(true, A_T, A_T); |
| 581 expect(true, A_T, A_T); | 576 expect(false, A_T, B_T); |
| 582 expect(false, A_T, B_T); | 577 |
| 583 | 578 // class B<T extends Object> {} |
| 584 // class B<T extends Object> {} | 579 expect(true, B_T, Object_); |
| 585 expect(true, B_T, Object_); | 580 expect(false, B_T, num_); |
| 586 expect(false, B_T, num_); | 581 expect(false, B_T, int_); |
| 587 expect(false, B_T, int_); | 582 expect(false, B_T, String_); |
| 588 expect(false, B_T, String_); | 583 expect(true, B_T, dynamic_); |
| 589 expect(true, B_T, dynamic_); | 584 expect(true, B_T, B_T); |
| 590 expect(true, B_T, B_T); | 585 expect(false, B_T, A_T); |
| 591 expect(false, B_T, A_T); | 586 |
| 592 | 587 // class C<T extends num> {} |
| 593 // class C<T extends num> {} | 588 expect(true, C_T, Object_); |
| 594 expect(true, C_T, Object_); | 589 expect(true, C_T, num_); |
| 595 expect(true, C_T, num_); | 590 expect(false, C_T, int_); |
| 596 expect(false, C_T, int_); | 591 expect(false, C_T, String_); |
| 597 expect(false, C_T, String_); | 592 expect(true, C_T, dynamic_); |
| 598 expect(true, C_T, dynamic_); | 593 expect(true, C_T, C_T); |
| 599 expect(true, C_T, C_T); | 594 expect(false, C_T, A_T); |
| 600 expect(false, C_T, A_T); | 595 |
| 601 | 596 // class D<T extends int> {} |
| 602 // class D<T extends int> {} | 597 expect(true, D_T, Object_); |
| 603 expect(true, D_T, Object_); | 598 expect(true, D_T, num_); |
| 604 expect(true, D_T, num_); | 599 expect(true, D_T, int_); |
| 605 expect(true, D_T, int_); | 600 expect(false, D_T, String_); |
| 606 expect(false, D_T, String_); | 601 expect(true, D_T, dynamic_); |
| 607 expect(true, D_T, dynamic_); | 602 expect(true, D_T, D_T); |
| 608 expect(true, D_T, D_T); | 603 expect(false, D_T, A_T); |
| 609 expect(false, D_T, A_T); | 604 |
| 610 | 605 // class E<T extends S, S extends num> {} |
| 611 // class E<T extends S, S extends num> {} | 606 expect(true, E_T, Object_); |
| 612 expect(true, E_T, Object_); | 607 expect(true, E_T, num_); |
| 613 expect(true, E_T, num_); | 608 expect(false, E_T, int_); |
| 614 expect(false, E_T, int_); | 609 expect(false, E_T, String_); |
| 615 expect(false, E_T, String_); | 610 expect(true, E_T, dynamic_); |
| 616 expect(true, E_T, dynamic_); | 611 expect(true, E_T, E_T); |
| 617 expect(true, E_T, E_T); | 612 expect(true, E_T, E_S); |
| 618 expect(true, E_T, E_S); | 613 expect(false, E_T, A_T); |
| 619 expect(false, E_T, A_T); | 614 |
| 620 | 615 expect(true, E_S, Object_); |
| 621 expect(true, E_S, Object_); | 616 expect(true, E_S, num_); |
| 622 expect(true, E_S, num_); | 617 expect(false, E_S, int_); |
| 623 expect(false, E_S, int_); | 618 expect(false, E_S, String_); |
| 624 expect(false, E_S, String_); | 619 expect(true, E_S, dynamic_); |
| 625 expect(true, E_S, dynamic_); | 620 expect(false, E_S, E_T); |
| 626 expect(false, E_S, E_T); | 621 expect(true, E_S, E_S); |
| 627 expect(true, E_S, E_S); | 622 expect(false, E_S, A_T); |
| 628 expect(false, E_S, A_T); | 623 |
| 629 | 624 // class F<T extends num, S extends T> {} |
| 630 // class F<T extends num, S extends T> {} | 625 expect(true, F_T, Object_); |
| 631 expect(true, F_T, Object_); | 626 expect(true, F_T, num_); |
| 632 expect(true, F_T, num_); | 627 expect(false, F_T, int_); |
| 633 expect(false, F_T, int_); | 628 expect(false, F_T, String_); |
| 634 expect(false, F_T, String_); | 629 expect(true, F_T, dynamic_); |
| 635 expect(true, F_T, dynamic_); | 630 expect(false, F_T, F_S); |
| 636 expect(false, F_T, F_S); | 631 expect(true, F_T, F_T); |
| 637 expect(true, F_T, F_T); | 632 expect(false, F_T, A_T); |
| 638 expect(false, F_T, A_T); | 633 |
| 639 | 634 expect(true, F_S, Object_); |
| 640 expect(true, F_S, Object_); | 635 expect(true, F_S, num_); |
| 641 expect(true, F_S, num_); | 636 expect(false, F_S, int_); |
| 642 expect(false, F_S, int_); | 637 expect(false, F_S, String_); |
| 643 expect(false, F_S, String_); | 638 expect(true, F_S, dynamic_); |
| 644 expect(true, F_S, dynamic_); | 639 expect(true, F_S, F_S); |
| 645 expect(true, F_S, F_S); | 640 expect(true, F_S, F_T); |
| 646 expect(true, F_S, F_T); | 641 expect(false, F_S, A_T); |
| 647 expect(false, F_S, A_T); | 642 |
| 648 | 643 // class G<T extends T> {} |
| 649 // class G<T extends T> {} | 644 expect(true, G_T, Object_); |
| 650 expect(true, G_T, Object_); | 645 expect(false, G_T, num_); |
| 651 expect(false, G_T, num_); | 646 expect(false, G_T, int_); |
| 652 expect(false, G_T, int_); | 647 expect(false, G_T, String_); |
| 653 expect(false, G_T, String_); | 648 expect(true, G_T, dynamic_); |
| 654 expect(true, G_T, dynamic_); | 649 expect(true, G_T, G_T); |
| 655 expect(true, G_T, G_T); | 650 expect(false, G_T, A_T); |
| 656 expect(false, G_T, A_T); | 651 |
| 657 | 652 // class H<T extends S, S extends T> {} |
| 658 // class H<T extends S, S extends T> {} | 653 expect(true, H_T, Object_); |
| 659 expect(true, H_T, Object_); | 654 expect(false, H_T, num_); |
| 660 expect(false, H_T, num_); | 655 expect(false, H_T, int_); |
| 661 expect(false, H_T, int_); | 656 expect(false, H_T, String_); |
| 662 expect(false, H_T, String_); | 657 expect(true, H_T, dynamic_); |
| 663 expect(true, H_T, dynamic_); | 658 expect(true, H_T, H_T); |
| 664 expect(true, H_T, H_T); | 659 expect(true, H_T, H_S); |
| 665 expect(true, H_T, H_S); | 660 expect(false, H_T, A_T); |
| 666 expect(false, H_T, A_T); | 661 |
| 667 | 662 expect(true, H_S, Object_); |
| 668 expect(true, H_S, Object_); | 663 expect(false, H_S, num_); |
| 669 expect(false, H_S, num_); | 664 expect(false, H_S, int_); |
| 670 expect(false, H_S, int_); | 665 expect(false, H_S, String_); |
| 671 expect(false, H_S, String_); | 666 expect(true, H_S, dynamic_); |
| 672 expect(true, H_S, dynamic_); | 667 expect(true, H_S, H_T); |
| 673 expect(true, H_S, H_T); | 668 expect(true, H_S, H_S); |
| 674 expect(true, H_S, H_S); | 669 expect(false, H_S, A_T); |
| 675 expect(false, H_S, A_T); | 670 |
| 676 | 671 // class I<T extends S, S extends U, U extends T> {} |
| 677 // class I<T extends S, S extends U, U extends T> {} | 672 expect(true, I_T, Object_); |
| 678 expect(true, I_T, Object_); | 673 expect(false, I_T, num_); |
| 679 expect(false, I_T, num_); | 674 expect(false, I_T, int_); |
| 680 expect(false, I_T, int_); | 675 expect(false, I_T, String_); |
| 681 expect(false, I_T, String_); | 676 expect(true, I_T, dynamic_); |
| 682 expect(true, I_T, dynamic_); | 677 expect(true, I_T, I_T); |
| 683 expect(true, I_T, I_T); | 678 expect(true, I_T, I_S); |
| 684 expect(true, I_T, I_S); | 679 expect(true, I_T, I_U); |
| 685 expect(true, I_T, I_U); | 680 expect(false, I_T, A_T); |
| 686 expect(false, I_T, A_T); | 681 |
| 687 | 682 expect(true, I_S, Object_); |
| 688 expect(true, I_S, Object_); | 683 expect(false, I_S, num_); |
| 689 expect(false, I_S, num_); | 684 expect(false, I_S, int_); |
| 690 expect(false, I_S, int_); | 685 expect(false, I_S, String_); |
| 691 expect(false, I_S, String_); | 686 expect(true, I_S, dynamic_); |
| 692 expect(true, I_S, dynamic_); | 687 expect(true, I_S, I_T); |
| 693 expect(true, I_S, I_T); | 688 expect(true, I_S, I_S); |
| 694 expect(true, I_S, I_S); | 689 expect(true, I_S, I_U); |
| 695 expect(true, I_S, I_U); | 690 expect(false, I_S, A_T); |
| 696 expect(false, I_S, A_T); | 691 |
| 697 | 692 expect(true, I_U, Object_); |
| 698 expect(true, I_U, Object_); | 693 expect(false, I_U, num_); |
| 699 expect(false, I_U, num_); | 694 expect(false, I_U, int_); |
| 700 expect(false, I_U, int_); | 695 expect(false, I_U, String_); |
| 701 expect(false, I_U, String_); | 696 expect(true, I_U, dynamic_); |
| 702 expect(true, I_U, dynamic_); | 697 expect(true, I_U, I_T); |
| 703 expect(true, I_U, I_T); | 698 expect(true, I_U, I_S); |
| 704 expect(true, I_U, I_S); | 699 expect(true, I_U, I_U); |
| 705 expect(true, I_U, I_U); | 700 expect(false, I_U, A_T); |
| 706 expect(false, I_U, A_T); | 701 |
| 707 | 702 // class J<T extends S, S extends U, U extends S> {} |
| 708 // class J<T extends S, S extends U, U extends S> {} | 703 expect(true, J_T, Object_); |
| 709 expect(true, J_T, Object_); | 704 expect(false, J_T, num_); |
| 710 expect(false, J_T, num_); | 705 expect(false, J_T, int_); |
| 711 expect(false, J_T, int_); | 706 expect(false, J_T, String_); |
| 712 expect(false, J_T, String_); | 707 expect(true, J_T, dynamic_); |
| 713 expect(true, J_T, dynamic_); | 708 expect(true, J_T, J_T); |
| 714 expect(true, J_T, J_T); | 709 expect(true, J_T, J_S); |
| 715 expect(true, J_T, J_S); | 710 expect(true, J_T, J_U); |
| 716 expect(true, J_T, J_U); | 711 expect(false, J_T, A_T); |
| 717 expect(false, J_T, A_T); | 712 |
| 718 | 713 expect(true, J_S, Object_); |
| 719 expect(true, J_S, Object_); | 714 expect(false, J_S, num_); |
| 720 expect(false, J_S, num_); | 715 expect(false, J_S, int_); |
| 721 expect(false, J_S, int_); | 716 expect(false, J_S, String_); |
| 722 expect(false, J_S, String_); | 717 expect(true, J_S, dynamic_); |
| 723 expect(true, J_S, dynamic_); | 718 expect(false, J_S, J_T); |
| 724 expect(false, J_S, J_T); | 719 expect(true, J_S, J_S); |
| 725 expect(true, J_S, J_S); | 720 expect(true, J_S, J_U); |
| 726 expect(true, J_S, J_U); | 721 expect(false, J_S, A_T); |
| 727 expect(false, J_S, A_T); | 722 |
| 728 | 723 expect(true, J_U, Object_); |
| 729 expect(true, J_U, Object_); | 724 expect(false, J_U, num_); |
| 730 expect(false, J_U, num_); | 725 expect(false, J_U, int_); |
| 731 expect(false, J_U, int_); | 726 expect(false, J_U, String_); |
| 732 expect(false, J_U, String_); | 727 expect(true, J_U, dynamic_); |
| 733 expect(true, J_U, dynamic_); | 728 expect(false, J_U, J_T); |
| 734 expect(false, J_U, J_T); | 729 expect(true, J_U, J_S); |
| 735 expect(true, J_U, J_S); | 730 expect(true, J_U, J_U); |
| 736 expect(true, J_U, J_U); | 731 expect(false, J_U, A_T); |
| 737 expect(false, J_U, A_T); | 732 })); |
| 738 } | 733 } |
| OLD | NEW |