OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
eernst
2017/09/04 17:04:57
Lost coverage: don't delete this file.
| |
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. | |
4 | |
5 // Regression test for issue 13134. Invocation of a type parameter. | |
6 | |
7 import "package:expect/expect.dart"; | |
8 | |
9 class C<T> { | |
10 noSuchMethod(Invocation im) { | |
11 throw "noSuchMethod shouldn't be called in this test."; | |
12 } | |
13 | |
14 // This is equivalent to (T).call(). See issue 19725 | |
15 foo() => T(); // //# 01: static type warning | |
16 | |
17 // T is in scope, even in static context. Compile-time error to call this.T(). | |
18 static bar() => T(); // //# 02: compile-time error | |
19 | |
20 // X is not in scope. NoSuchMethodError. | |
21 static baz() => X(); // //# 03: static type warning | |
22 | |
23 // Class 'C' has no static method 'T': NoSuchMethodError. | |
24 static qux() => C.T(); // //# 04: static type warning | |
25 | |
26 // Class '_Type' has no instance method 'call': NoSuchMethodError. | |
27 quux() => (T)(); // //# 05: static type warning | |
28 | |
29 // Runtime type T not accessible from static context. Compile-time error. | |
30 static corge() => (T)(); // //# 06: compile-time error | |
31 | |
32 // Class '_Type' has no [] operator: NoSuchMethodError. | |
33 grault() => T[0]; // //# 07: static type warning | |
34 | |
35 // Runtime type T not accessible from static context. Compile-time error. | |
36 static garply() => T[0]; // //# 08: compile-time error | |
37 | |
38 // Class '_Type' has no member m: NoSuchMethodError. | |
39 waldo() => T.m; // //# 09: static type warning | |
40 | |
41 // Runtime type T not accessible from static context. Compile-time error. | |
42 static fred() => T.m; // //# 10: compile-time error | |
43 } | |
44 | |
45 main() { | |
46 Expect.throws(() => new C().foo(), (e) => e is NoSuchMethodError); //# 01: con tinued | |
47 C.bar(); // //# 02: continued | |
48 Expect.throws(() => C.baz(), (e) => e is NoSuchMethodError); // //# 03: contin ued | |
49 Expect.throws(() => C.qux(), (e) => e is NoSuchMethodError); // //# 04: contin ued | |
50 Expect.throws(() => new C().quux(), (e) => e is NoSuchMethodError); // //# 05: continued | |
51 C.corge(); // //# 06: continued | |
52 Expect.throws(() => new C().grault(), (e) => e is NoSuchMethodError); // //# 0 7: continued | |
53 C.garply(); // //# 08: continued | |
54 Expect.throws(() => new C().waldo(), (e) => e is NoSuchMethodError); // //# 09 : continued | |
55 C.fred(); // //# 10: continued | |
56 } | |
OLD | NEW |