| 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 // VMOptions=--enable_type_checks |
| 5 | 5 |
| 6 // Test of parameterized factory methods. | 6 // Test of parameterized factory methods. |
| 7 | 7 |
| 8 class Foo<T extends num> { | 8 class Foo<T extends num> { |
| 9 Foo(); | 9 Foo(); |
| 10 | 10 |
| 11 // F is not assignable to num. | 11 factory XFoo.bad() { return null; } /// 00: compile-time error |
| 12 factory IFoo<F extends String>.bad() { return null; } /// 00: static type erro
r | |
| 13 | 12 |
| 14 factory IFoo<F extends num>.good() { return null; } | 13 factory IFoo.good() { return null; } |
| 15 | 14 |
| 16 // The bound of F is Object which is assignable to num. | 15 factory IFoo() { return null; } |
| 17 factory IFoo<F>.ish() { return null; } | |
| 18 } | 16 } |
| 19 | 17 |
| 20 interface IFoo<X extends num> factory Foo<T extends num> { | 18 interface IFoo<T extends num> factory Foo<T extends num> { |
| 21 } | 19 } |
| 22 | 20 |
| 23 // String is not assignable to num. | 21 // String is not assignable to num. |
| 24 class Baz extends Foo<String> {} /// 01: compile-time error | 22 class Baz extends Foo<String> {} /// 01: compile-time error |
| 25 | 23 |
| 26 class Biz extends Foo<int> {} | 24 class Biz extends Foo<int> {} |
| 27 | 25 |
| 28 Foo<int> fi; | 26 Foo<int> fi; |
| 29 | 27 |
| 30 // String is not assignable to num. | 28 // String is not assignable to num. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 47 var v1 = new Foo<String>(); /// 05: compile-time error | 45 var v1 = new Foo<String>(); /// 05: compile-time error |
| 48 | 46 |
| 49 // String is not assignable to num. | 47 // String is not assignable to num. |
| 50 Foo<String> v2 = null; /// 06: compile-time error | 48 Foo<String> v2 = null; /// 06: compile-time error |
| 51 } | 49 } |
| 52 } | 50 } |
| 53 | 51 |
| 54 main() { | 52 main() { |
| 55 TypeVariableBoundsTest.testMain(); | 53 TypeVariableBoundsTest.testMain(); |
| 56 } | 54 } |
| OLD | NEW |