| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Test of parameterized types with invalid bounds. | |
| 6 | |
| 7 interface J<T> { } | |
| 8 | |
| 9 interface K<T> { } | |
| 10 | |
| 11 interface I<T | |
| 12 extends num /// 00: continued | |
| 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 | |
| 21 class A<T> implements I<T>, J<T> { | |
| 22 } | |
| 23 | |
| 24 main() { | |
| 25 var a = new A<String>(); | |
| 26 | |
| 27 { | |
| 28 I i = a; /// 00: dynamic type error, static type warning | |
| 29 J j = a; /// 01: static type warning | |
| 30 K k = a; /// 02: dynamic type error, static type warning | |
| 31 | |
| 32 // In production mode, A<String> is subtype of I, error in checked mode. | |
| 33 var x = a is I; /// 03: dynamic type error, static type warning | |
| 34 | |
| 35 // In both production and checked modes, A<String> is a subtype of J. | |
| 36 Expect.isTrue(a is J); /// 04: static type warning | |
| 37 | |
| 38 // In both production and checked modes, A<String> is not a subtype of K. | |
| 39 // However, while unsuccessfully trying to prove that A<String> is a K, | |
| 40 // a malformed type is encountered in checked mode, resulting in a dynamic | |
| 41 // type error. | |
| 42 Expect.isTrue(a is !K); /// 05: dynamic type error | |
| 43 } | |
| 44 | |
| 45 a = new A<int>(); | |
| 46 | |
| 47 { | |
| 48 I i = a; | |
| 49 J j = a; | |
| 50 K k = a; /// 06: dynamic type error, static type warning | |
| 51 | |
| 52 // In both production and checked modes, A<int> is a subtype of I. | |
| 53 Expect.isTrue(a is I); | |
| 54 | |
| 55 // In both production and checked modes, A<int> is a subtype of J. | |
| 56 Expect.isTrue(a is J); | |
| 57 | |
| 58 // In both production and checked modes, A<int> is not a subtype of K. | |
| 59 Expect.isTrue(a is !K); | |
| 60 } | |
| 61 } | |
| OLD | NEW |