OLD | NEW |
| (Empty) |
1 // compile options: --no-hoist-signature-types --no-hoist-instance-creation --na
me-type-tests | |
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
3 // for details. All rights reserved. Use of this source code is governed by a | |
4 // BSD-style license that can be found in the LICENSE file. | |
5 import "package:expect/expect.dart"; | |
6 | |
7 class A<T> { | |
8 A(this.x, T z); | |
9 A.make(); | |
10 void f(T x) {} | |
11 static String g(String x) { | |
12 return x; | |
13 } | |
14 | |
15 T x; | |
16 } | |
17 | |
18 class B extends A<int> { | |
19 B(int x, int z) : super(x, z); | |
20 B.make() : super.make(); | |
21 void f(int x) {} | |
22 static int g(int x) { | |
23 return x; | |
24 } | |
25 } | |
26 | |
27 class C { | |
28 C(this.x, int z); | |
29 void f(int x) {} | |
30 static int g(int x) { | |
31 return x; | |
32 } | |
33 | |
34 int x = 0; | |
35 } | |
36 | |
37 typedef void ToVoid<T>(T x); | |
38 typedef T Id<T>(T x); | |
39 | |
40 void main() { | |
41 { | |
42 A<String> a = new A<String>("hello", "world"); | |
43 Expect.isTrue(new A<String>.make() is! A<int>); | |
44 Expect.isTrue(new A.make() is A); | |
45 Expect.isTrue(a is! A<int>); | |
46 Expect.isTrue(a is A<String>); | |
47 Expect.isTrue(a.f is ToVoid<String>); | |
48 Expect.isTrue(A.g is Id<String>); | |
49 } | |
50 { | |
51 B b = new B(0, 1); | |
52 Expect.isTrue(new B.make() is B); | |
53 Expect.isTrue(new B.make() is A<int>); | |
54 Expect.isTrue(b is B); | |
55 Expect.isTrue(b.f is ToVoid<int>); | |
56 Expect.isTrue(B.g is Id<int>); | |
57 } | |
58 { | |
59 C c = new C(0, 1); | |
60 Expect.isTrue(c is C); | |
61 Expect.isTrue(c.f is ToVoid<int>); | |
62 Expect.isTrue(C.g is Id<int>); | |
63 } | |
64 } | |
OLD | NEW |