Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: tests/language_strong/covariant_subtyping_test.dart

Issue 2995813002: fix #30423, covariant parameter tearoff type should be Object (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
224 main() { 250 main() {
225 testField(); 251 testField();
226 testPrivateFields(); 252 testPrivateFields();
227 testClassBounds(); 253 testClassBounds();
228 testReturnOfFunctionType(); 254 testReturnOfFunctionType();
229 testTearoffReturningFunctionType(); 255 testTearoffReturningFunctionType();
230 testFieldOfFunctionType(); 256 testFieldOfFunctionType();
231 testFieldOfGenericFunctionType(); 257 testFieldOfGenericFunctionType();
232 testMixinApplication(); 258 testMixinApplication();
233 testGenericMethodBounds(); 259 testGenericMethodBounds();
234 testCallMethod(); 260 testCallMethod();
261 testTearOffRuntimeType();
235 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698