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