| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:expect/expect.dart'; | 4 import 'package:expect/expect.dart'; |
| 5 | 5 |
| 6 bool isTypeError(e) => e is TypeError; | 6 bool isTypeError(e) => e is TypeError; |
| 7 | 7 |
| 8 class Fields<T> { | 8 class Fields<T> { |
| 9 T x; | 9 T x; |
| 10 T _y; | 10 T _y; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 testCallMethod() { | 214 testCallMethod() { |
| 215 ClassF<int> cc = new ClassF<int>(); | 215 ClassF<int> cc = new ClassF<int>(); |
| 216 ClassF<Object> ca = cc; // An upcast, per covariance. | 216 ClassF<Object> ca = cc; // An upcast, per covariance. |
| 217 F<Object> f = ca; | 217 F<Object> f = ca; |
| 218 Expect.equals(f.runtimeType.toString(), 'ClassF<int>'); | 218 Expect.equals(f.runtimeType.toString(), 'ClassF<int>'); |
| 219 Expect.throws(() { | 219 Expect.throws(() { |
| 220 f(new Object()); | 220 f(new Object()); |
| 221 }, isTypeError); | 221 }, isTypeError); |
| 222 } | 222 } |
| 223 | 223 |
| 224 class TearOff<T> { | |
| 225 method1(T t) => null; // needs check | |
| 226 method2(Function(T) takesT) => null; | |
| 227 method3(T Function() returnsT) => null; // needs check | |
| 228 method4(Function(Function(T)) takesTakesT) => null; // needs check | |
| 229 method5(Function(T Function()) takesReturnsT) => null; | |
| 230 method6(Function(T) Function() returnsTakesT) => null; | |
| 231 method7(T Function() Function() returnsReturnsT) => null; // needs check | |
| 232 } | |
| 233 | |
| 234 testTearOffRuntimeType() { | |
| 235 expectRTTI(tearoff, type) => Expect.equals('${tearoff.runtimeType}', type, | |
| 236 'covariant params should reify with Object as their type'); | |
| 237 | |
| 238 TearOff<num> t = new TearOff<int>(); | |
| 239 expectRTTI(t.method1, '(Object) -> dynamic'); | |
| 240 | |
| 241 expectRTTI(t.method2, '((int) -> dynamic) -> dynamic'); | |
| 242 expectRTTI(t.method3, '(Object) -> dynamic'); | |
| 243 | |
| 244 expectRTTI(t.method4, '(Object) -> dynamic'); | |
| 245 expectRTTI(t.method5, '((() -> int) -> dynamic) -> dynamic'); | |
| 246 expectRTTI(t.method6, '(() -> (int) -> dynamic) -> dynamic'); | |
| 247 expectRTTI(t.method7, '(Object) -> dynamic'); | |
| 248 } | |
| 249 | |
| 250 main() { | 224 main() { |
| 251 testField(); | 225 testField(); |
| 252 testPrivateFields(); | 226 testPrivateFields(); |
| 253 testClassBounds(); | 227 testClassBounds(); |
| 254 testReturnOfFunctionType(); | 228 testReturnOfFunctionType(); |
| 255 testTearoffReturningFunctionType(); | 229 testTearoffReturningFunctionType(); |
| 256 testFieldOfFunctionType(); | 230 testFieldOfFunctionType(); |
| 257 testFieldOfGenericFunctionType(); | 231 testFieldOfGenericFunctionType(); |
| 258 testMixinApplication(); | 232 testMixinApplication(); |
| 259 testGenericMethodBounds(); | 233 testGenericMethodBounds(); |
| 260 testCallMethod(); | 234 testCallMethod(); |
| 261 testTearOffRuntimeType(); | |
| 262 } | 235 } |
| OLD | NEW |