Chromium Code Reviews| 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 // Test of parameterized types with invalid bounds. | 5 // Test of parameterized types with invalid bounds. |
| 6 | 6 |
| 7 interface I<T extends num> { } | |
| 8 | |
| 9 interface J<T> { } | 7 interface J<T> { } |
| 10 | 8 |
| 11 interface K<T> { } | 9 interface K<T> { } |
| 12 | 10 |
| 11 interface I<T | |
| 12 extends num /// 00: continued | |
|
zundel
2012/03/12 14:54:39
This test required a bit of hacking. The multiple
| |
| 13 extends num /// 01: continued | |
| 14 extends num /// 02: continued | |
| 15 extends num /// 03: continued | |
| 16 extends num /// 04: continued | |
| 17 extends num /// 05: continued | |
| 18 extends num /// 06: continued | |
| 19 > { } | |
| 20 | |
| 13 class A<T> implements I<T>, J<T> { | 21 class A<T> implements I<T>, J<T> { |
| 14 } | 22 } |
| 15 | 23 |
| 16 main() { | 24 main() { |
| 17 var a = new A<String>(); | 25 var a = new A<String>(); |
| 18 | 26 |
| 19 { | 27 { |
| 20 I i = a; /// 00: dynamic type error, static type warning | 28 I i = a; /// 00: dynamic type error, static type warning |
| 21 J j = a; /// 01: static type warning | 29 J j = a; /// 01: static type warning |
| 22 K k = a; /// 02: dynamic type error, static type warning | 30 K k = a; /// 02: dynamic type error, static type warning |
| 23 | 31 |
| 24 // In production mode, A<String> is subtype of I, but error in checked mode. | 32 // In production mode, A<String> is subtype of I, error in checked mode. |
| 25 var x = a is I; /// 03: dynamic type error, static type warning | 33 var x = a is I; /// 03: dynamic type error, static type warning |
| 26 | 34 |
| 27 // In both production and checked modes, A<String> is a subtype of I. | 35 // In both production and checked modes, A<String> is a subtype of I. |
|
Bill Hesse
2012/03/12 16:02:49
subtype of J, not I.
| |
| 28 Expect.isTrue(a is J); /// 04: static type warning | 36 Expect.isTrue(a is J); /// 04: static type warning |
| 29 | 37 |
| 30 // In both production and checked modes, A<String> is not a subtype of K. | 38 // In both production and checked modes, A<String> is not a subtype of K. |
| 31 // However, while unsuccessfully trying to prove that A<String> is a K, | 39 // However, while unsuccessfully trying to prove that A<String> is a K, |
| 32 // a malformed type is encountered in checked mode, resulting in a dynamic | 40 // a malformed type is encountered in checked mode, resulting in a dynamic |
| 33 // type error. | 41 // type error. |
| 34 Expect.isTrue(a is !K); /// 05: dynamic type error | 42 Expect.isTrue(a is !K); /// 05: dynamic type error |
| 35 } | 43 } |
| 36 | 44 |
| 37 a = new A<int>(); | 45 a = new A<int>(); |
| 38 | 46 |
| 39 { | 47 { |
| 40 I i = a; | 48 I i = a; |
| 41 J j = a; | 49 J j = a; |
| 42 K k = a; /// 06: dynamic type error, static type warning | 50 K k = a; /// 06: dynamic type error, static type warning |
| 43 | 51 |
| 44 // In both production and checked modes, A<int> is a subtype of I. | 52 // In both production and checked modes, A<int> is a subtype of I. |
| 45 Expect.isTrue(a is I); | 53 Expect.isTrue(a is I); |
| 46 | 54 |
| 47 // In both production and checked modes, A<int> is a subtype of J. | 55 // In both production and checked modes, A<int> is a subtype of J. |
| 48 Expect.isTrue(a is J); | 56 Expect.isTrue(a is J); |
| 49 | 57 |
| 50 // In both production and checked modes, A<int> is not a subtype of K. | 58 // In both production and checked modes, A<int> is not a subtype of K. |
| 51 Expect.isTrue(a is !K); | 59 Expect.isTrue(a is !K); |
| 52 } | 60 } |
| 53 } | 61 } |
| 62 | |
|
Bill Hesse
2012/03/12 16:02:49
Extra line.
| |
| OLD | NEW |