| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Tests cyclic reference to type variables in type expressions | 5 // Tests cyclic reference to type variables in type expressions |
| 6 | 6 |
| 7 class Base<T> {} | 7 class Base<T> {} |
| 8 | 8 |
| 9 class Derived extends Base<Derived> {} // legal | 9 class Derived extends Base<Derived> {} // legal |
| 10 | 10 |
| 11 typedef void funcType<T | 11 typedef void funcType<T |
| 12 extends T /// 01: static type error | 12 extends T /// 01: static type warning |
| 13 >(T arg); | 13 >(T arg); |
| 14 | 14 |
| 15 class DerivedFunc extends Base<funcType<DerivedFunc>> { } | 15 class DerivedFunc extends Base<funcType<DerivedFunc>> { } |
| 16 | 16 |
| 17 | 17 |
| 18 interface A<S | 18 interface A<S |
| 19 extends S /// 02: static type error | 19 extends S /// 02: static type warning |
| 20 > { | 20 > { |
| 21 S field; | 21 S field; |
| 22 } | 22 } |
| 23 | 23 |
| 24 interface B<U extends Base<U>> { // legal | 24 interface B<U extends Base<U>> { // legal |
| 25 U field; | 25 U field; |
| 26 } | 26 } |
| 27 | 27 |
| 28 class C1<V | 28 class C1<V |
| 29 extends V /// 03: static type error | 29 extends V /// 03: static type warning |
| 30 > { | 30 > { |
| 31 V field; | 31 V field; |
| 32 } | 32 } |
| 33 | 33 |
| 34 class C2<V | 34 class C2<V |
| 35 extends V /// 04: static type error | 35 extends V /// 04: static type warning |
| 36 > implements A<V> { | 36 > implements A<V> { |
| 37 V field; | 37 V field; |
| 38 } | 38 } |
| 39 | 39 |
| 40 class D1<W extends Base<W>> { // legal | 40 class D1<W extends Base<W>> { // legal |
| 41 W field; | 41 W field; |
| 42 } | 42 } |
| 43 | 43 |
| 44 class D2<W extends Base<W>> implements B<W>{ // legal | 44 class D2<W extends Base<W>> implements B<W>{ // legal |
| 45 W field; | 45 W field; |
| 46 } | 46 } |
| 47 | 47 |
| 48 class E<X extends Base<funcType<X>>> { // legal | 48 class E<X extends Base<funcType<X>>> { // legal |
| 49 | 49 |
| 50 X field; | 50 X field; |
| 51 } | 51 } |
| 52 | 52 |
| 53 main() { | 53 main() { |
| 54 new C1<int>(); | 54 new C1<int>(); |
| 55 new C2<int>(); | 55 new C2<int>(); |
| 56 new D1<Derived>(); | 56 new D1<Derived>(); |
| 57 new D2<Derived>(); | 57 new D2<Derived>(); |
| 58 new E<DerivedFunc>(); | 58 new E<DerivedFunc>(); |
| 59 funcType<Object> val = null; | 59 funcType<Object> val = null; |
| 60 } | 60 } |
| OLD | NEW |