| 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   factory XFoo.bad() { return null; } /// 00: compile-time error | 11   factory XFoo.bad() { return null; } /// 00: compile-time error | 
| 12 | 12 | 
| 13   factory IFoo.good() { return null; } | 13   factory IFoo.good() { return null; } | 
| 14 | 14 | 
| 15   factory IFoo() { return null; } | 15   factory IFoo() { return null; } | 
| 16 } | 16 } | 
| 17 | 17 | 
| 18 interface IFoo<T extends num> factory Foo<T extends num> { | 18 interface IFoo<T extends num> default Foo<T extends num> { | 
| 19 } | 19 } | 
| 20 | 20 | 
| 21 // String is not assignable to num. | 21 // String is not assignable to num. | 
| 22 class Baz extends Foo<String> {} /// 01: compile-time error | 22 class Baz | 
|  | 23     extends Foo<String> /// 01: static type error | 
|  | 24 {} | 
| 23 | 25 | 
| 24 class Biz extends Foo<int> {} | 26 class Biz extends Foo<int> {} | 
| 25 | 27 | 
| 26 Foo<int> fi; | 28 Foo<int> fi; | 
| 27 | 29 | 
| 28 // String is not assignable to num. | 30 // String is not assignable to num. | 
| 29 Foo<String> fs; /// 02: compile-time error | 31 Foo | 
|  | 32     <String> /// 02: static type error | 
|  | 33   fs; | 
| 30 | 34 | 
| 31 class Box<T> { | 35 class Box<T> { | 
| 32 | 36 | 
| 33   // Box.T is not assignable to num. | 37   // Box.T is not assignable to num. | 
| 34   Foo<T> t; /// 03: static type error | 38   Foo<T> t; /// 03: static type error | 
| 35 | 39 | 
| 36   makeFoo() { | 40   makeFoo() { | 
| 37     // Box.T is not assignable to num. | 41     // Box.T is not assignable to num. | 
| 38     return new Foo<T>(); /// 04: static type error | 42     return new Foo<T>(); /// 04: static type error | 
| 39   } | 43   } | 
| 40 } | 44 } | 
| 41 | 45 | 
| 42 class TypeVariableBoundsTest { |  | 
| 43   static testMain() { |  | 
| 44     // String is not assignable to num. |  | 
| 45     var v1 = new Foo<String>(); /// 05: compile-time error |  | 
| 46 |  | 
| 47     // String is not assignable to num. |  | 
| 48     Foo<String> v2 = null; /// 06: compile-time error |  | 
| 49   } |  | 
| 50 } |  | 
| 51 |  | 
| 52 main() { | 46 main() { | 
| 53   TypeVariableBoundsTest.testMain(); | 47   // String is not assignable to num. | 
|  | 48   var v1 = new Foo<String>(); /// 05: static type error | 
|  | 49 | 
|  | 50   // String is not assignable to num. | 
|  | 51   Foo<String> v2 = null; /// 06: static type error | 
|  | 52 | 
|  | 53   new Baz(); | 
|  | 54   new Biz(); | 
|  | 55 | 
|  | 56   fi = new Foo(); | 
|  | 57   fs = new Foo(); | 
|  | 58 | 
|  | 59   new Box().makeFoo(); | 
|  | 60   new Box<int>().makeFoo(); | 
|  | 61   new Box<String>().makeFoo(); | 
|  | 62 | 
|  | 63   // Fisk does not exist. | 
|  | 64   new Box<Fisk>(); /// 07: compile-time error | 
|  | 65 | 
|  | 66   // Too many type arguments. | 
|  | 67   new Box<Object, Object>(); /// 08: compile-time error | 
|  | 68 | 
|  | 69   // Fisk does not exist. | 
|  | 70   Box<Fisk> box = null; /// 09: static type error | 
|  | 71 | 
|  | 72   // Too many type arguments. | 
|  | 73   Box<Object, Object> box = null; /// 10: static type error | 
| 54 } | 74 } | 
| OLD | NEW | 
|---|