OLD | NEW |
(Empty) | |
| 1 // compile options: --hoist-signature-types --hoist-instance-creation --hoist-ty
pe-tests |
| 2 import "package:expect/expect.dart"; |
| 3 |
| 4 class A<T> { |
| 5 A(this.x, T z); |
| 6 A.make(); |
| 7 void f(T x) {} |
| 8 static String g(String x) {return x;} |
| 9 T x; |
| 10 } |
| 11 |
| 12 class B extends A<int> { |
| 13 B(int x, int z) : super(x, z); |
| 14 B.make(); |
| 15 void f(int x) {} |
| 16 static int g(int x) {return x;} |
| 17 } |
| 18 |
| 19 class C { |
| 20 C(this.x, int z); |
| 21 void f(int x) {} |
| 22 static int g(int x) {return x;} |
| 23 int x = 0; |
| 24 } |
| 25 typedef void ToVoid<T>(T x); |
| 26 typedef T Id<T>(T x); |
| 27 |
| 28 void main() { |
| 29 { |
| 30 A<String> a = new A<String>("hello", "world"); |
| 31 Expect.isTrue(new A.make<String>() is! A<int>); |
| 32 Expect.isTrue(new A.make() is! A<int>); |
| 33 Expect.isTrue(a is! A<int>); |
| 34 Expect.isTrue(a is A<String>); |
| 35 Expect.isTrue(a.f is ToVoid<String>); |
| 36 Expect.isTrue(a.f is! ToVoid<int>); |
| 37 Expect.isTrue(A.g is Id<String>); |
| 38 Expect.isTrue(A.g is! Id<int>); |
| 39 } |
| 40 { |
| 41 B b = new B(0, 1); |
| 42 Expect.isTrue(new B.make() is B); |
| 43 Expect.isTrue(new B.make() is A<int>); |
| 44 Expect.isTrue(b is B); |
| 45 Expect.isTrue(b is! B); |
| 46 Expect.isTrue(b.f is! ToVoid<String>); |
| 47 Expect.isTrue(b.f is ToVoid<int>); |
| 48 Expect.isTrue(B.g is! Id<String>); |
| 49 Expect.isTrue(B.g is Id<int>); |
| 50 } |
| 51 { |
| 52 C c = new C(0, 1); |
| 53 Expect.isTrue(c is C); |
| 54 Expect.isTrue(c is! C); |
| 55 Expect.isTrue(c.f is! ToVoid<String>); |
| 56 Expect.isTrue(c.f is ToVoid<int>); |
| 57 Expect.isTrue(C.g is! Id<String>); |
| 58 Expect.isTrue(C.g is Id<int>); |
| 59 } |
| 60 } |
OLD | NEW |