| 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 Expect.equals(#T, im.memberName); | 11 Expect.equals(#T, im.memberName); |
| 12 return 42; | 12 return 42; |
| 13 } | 13 } |
| 14 | 14 |
| 15 // Class 'C' has no instance method 'T': call noSuchMethod. | 15 // Class 'C' has no instance method 'T': call noSuchMethod. |
| 16 foo() => T(); // /// 01: static type warning | 16 foo() => T(); // //# 01: static type warning |
| 17 | 17 |
| 18 // T is in scope, even in static context. Compile-time error to call this.T(). | 18 // T is in scope, even in static context. Compile-time error to call this.T(). |
| 19 static bar() => T(); // /// 02: compile-time error | 19 static bar() => T(); // //# 02: compile-time error |
| 20 | 20 |
| 21 // X is not in scope. NoSuchMethodError. | 21 // X is not in scope. NoSuchMethodError. |
| 22 static baz() => X(); // /// 03: static type warning | 22 static baz() => X(); // //# 03: static type warning |
| 23 | 23 |
| 24 // Class 'C' has no static method 'T': NoSuchMethodError. | 24 // Class 'C' has no static method 'T': NoSuchMethodError. |
| 25 static qux() => C.T(); // /// 04: static type warning | 25 static qux() => C.T(); // //# 04: static type warning |
| 26 | 26 |
| 27 // Class '_Type' has no instance method 'call': NoSuchMethodError. | 27 // Class '_Type' has no instance method 'call': NoSuchMethodError. |
| 28 quux() => (T)(); // /// 05: static type warning | 28 quux() => (T)(); // //# 05: static type warning |
| 29 | 29 |
| 30 // Runtime type T not accessible from static context. Compile-time error. | 30 // Runtime type T not accessible from static context. Compile-time error. |
| 31 static corge() => (T)(); // /// 06: compile-time error | 31 static corge() => (T)(); // //# 06: compile-time error |
| 32 | 32 |
| 33 // Class '_Type' has no [] operator: NoSuchMethodError. | 33 // Class '_Type' has no [] operator: NoSuchMethodError. |
| 34 grault() => T[0]; // /// 07: static type warning | 34 grault() => T[0]; // //# 07: static type warning |
| 35 | 35 |
| 36 // Runtime type T not accessible from static context. Compile-time error. | 36 // Runtime type T not accessible from static context. Compile-time error. |
| 37 static garply() => T[0]; // /// 08: compile-time error | 37 static garply() => T[0]; // //# 08: compile-time error |
| 38 | 38 |
| 39 // Class '_Type' has no member m: NoSuchMethodError. | 39 // Class '_Type' has no member m: NoSuchMethodError. |
| 40 waldo() => T.m; // /// 09: static type warning | 40 waldo() => T.m; // //# 09: static type warning |
| 41 | 41 |
| 42 // Runtime type T not accessible from static context. Compile-time error. | 42 // Runtime type T not accessible from static context. Compile-time error. |
| 43 static fred() => T.m; // /// 10: compile-time error | 43 static fred() => T.m; // //# 10: compile-time error |
| 44 } | 44 } |
| 45 | 45 |
| 46 main() { | 46 main() { |
| 47 Expect.equals(42, new C().foo()); // /// 01: continued | 47 Expect.equals(42, new C().foo()); // //# 01: continued |
| 48 C.bar(); // /// 02: continued | 48 C.bar(); // //# 02: continued |
| 49 Expect.throws(() => C.baz(), (e) => e is NoSuchMethodError); // /// 03: contin
ued | 49 Expect.throws(() => C.baz(), (e) => e is NoSuchMethodError); // //# 03: contin
ued |
| 50 Expect.throws(() => C.qux(), (e) => e is NoSuchMethodError); // /// 04: contin
ued | 50 Expect.throws(() => C.qux(), (e) => e is NoSuchMethodError); // //# 04: contin
ued |
| 51 Expect.throws(() => new C().quux(), (e) => e is NoSuchMethodError); // /// 05:
continued | 51 Expect.throws(() => new C().quux(), (e) => e is NoSuchMethodError); // //# 05:
continued |
| 52 C.corge(); // /// 06: continued | 52 C.corge(); // //# 06: continued |
| 53 Expect.throws(() => new C().grault(), (e) => e is NoSuchMethodError); // /// 0
7: continued | 53 Expect.throws(() => new C().grault(), (e) => e is NoSuchMethodError); // //# 0
7: continued |
| 54 C.garply(); // /// 08: continued | 54 C.garply(); // //# 08: continued |
| 55 Expect.throws(() => new C().waldo(), (e) => e is NoSuchMethodError); // /// 09
: continued | 55 Expect.throws(() => new C().waldo(), (e) => e is NoSuchMethodError); // //# 09
: continued |
| 56 C.fred(); // /// 10: continued | 56 C.fred(); // //# 10: continued |
| 57 } | 57 } |
| OLD | NEW |