| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // VMOptions=--enable_type_checks |
| 4 | 5 |
| 5 // Test that type variables aren't in scope of static methods and factories. | 6 // Test that type variables aren't in scope of static methods and factories. |
| 6 | 7 |
| 7 class Foo<T> { | 8 class Foo<T> { |
| 8 // T is not in scope for a static method. | 9 // T is not in scope for a static method. |
| 9 static | 10 static |
| 10 Foo<T> /// 00: compile-time error | 11 Foo<T> /// 00: compile-time error |
| 11 m( | 12 m( |
| 12 Foo<T> /// 01: compile-time error | 13 Foo<T> /// 01: compile-time error |
| 13 f) { | 14 f) { |
| 14 I<T> x; /// 02: compile-time error | 15 I<T> x; /// 02: compile-time error |
| 15 } | 16 } |
| 16 | 17 |
| 17 // T is not in scope for a static method. | 18 // T is not in scope for a static method. |
| 18 factory I( | 19 factory I<X>( |
| 19 I<T> /// 03: compile-time error | 20 I<T> /// 03: compile-time error |
| 20 i) { | 21 i) { |
| 21 I<T> x; /// 04: compile-time error | 22 I<T> x; /// 04: compile-time error |
| 22 } | 23 } |
| 23 | 24 |
| 24 // T is not in scope for a static field. | 25 // T is not in scope for a static field. |
| 25 static Foo<T> f1; /// 05: compile-time error | 26 static Foo<T> f1; /// 05: compile-time error |
| 26 | 27 |
| 27 static | 28 static |
| 28 Foo<T> /// 06: compile-time error | 29 Foo<T> /// 06: compile-time error |
| 29 get f() { return null; } | 30 get f() { return null; } |
| 30 | 31 |
| 31 static void set f( | 32 static void set f( |
| 32 Foo<T> /// 07: compile-time error | 33 Foo<T> /// 07: compile-time error |
| 33 value) {} | 34 value) {} |
| 34 } | 35 } |
| 35 | 36 |
| 36 interface I<X> factory Foo<X> { | 37 interface I<X> factory Foo<T> { |
| 37 I(I<X> i); | 38 I(I<X> i); |
| 38 } | 39 } |
| 39 | 40 |
| 40 main() { | 41 main() { |
| 41 Foo.m(null); | 42 Foo.m(null); |
| 42 new I(null); | 43 new I(null); |
| 43 } | 44 } |
| OLD | NEW |