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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class A<T> { | 7 class A<T> { |
8 Function closure; | 8 Function closure; |
9 A._(this.closure); | 9 A._(this.closure); |
10 | 10 |
11 factory A() { | 11 factory A() { |
12 return new A._(() => new Set<T>()); | 12 return new A._(() => new Set<T>()); |
13 } | 13 } |
14 | 14 |
15 A.bar() { | 15 A.bar() { |
16 closure = () => new Set<T>(); | 16 closure = () => new Set<T>(); |
17 } | 17 } |
18 | 18 |
19 static | 19 static |
20 T /// 01: static type warning, dynamic type error | 20 T /// 01: static type warning |
21 staticMethod( | 21 staticMethod( |
22 T /// 02: static type warning, dynamic type error | 22 T /// 02: static type warning |
23 a) { | 23 a) { |
24 final | 24 final |
25 T /// 03: static type warning, dynamic type error | 25 T /// 03: static type warning |
26 a = "not_null"; | 26 a = "not_null"; |
27 print(a); | 27 print(a); |
28 return a; | 28 return a; |
29 } | 29 } |
30 | 30 |
31 static final | 31 static final |
32 T /// 04: static type warning, dynamic type error | 32 T /// 04: static type warning |
33 staticFinalField = "not_null"; | 33 staticFinalField = "not_null"; |
34 | 34 |
35 static const | 35 static const |
36 // TODO(regis): Support 'compile-time type error' in test.dart and use below. | 36 T /// 05: static type warning |
37 T /// 05: static type warning, compile-time error | |
38 staticConstField = "not_null"; | 37 staticConstField = "not_null"; |
39 | 38 |
40 static not_null() => "not_null"; | 39 static not_null() => "not_null"; |
41 static final | 40 static final |
42 T /// 06: static type warning, dynamic type error | 41 T /// 06: static type warning |
43 staticFinalField2 = not_null(); | 42 staticFinalField2 = not_null(); |
44 | 43 |
45 | |
46 // Assigning null to a malformed type is not a dynamic error. | 44 // Assigning null to a malformed type is not a dynamic error. |
47 static | 45 static |
48 T staticMethod2(T a) { | 46 T staticMethod2(T a) { |
49 final T a = null; | 47 final T a = null; |
50 print(a); | 48 print(a); |
51 return a; | 49 return a; |
52 } | 50 } |
53 | 51 |
54 static final T staticFinalField3 = null; | 52 static final T staticFinalField3 = null; |
55 | 53 |
(...skipping 18 matching lines...) Expand all Loading... |
74 | 72 |
75 A.staticMethod("not_null"); | 73 A.staticMethod("not_null"); |
76 print(A.staticFinalField); | 74 print(A.staticFinalField); |
77 print(A.staticConstField); | 75 print(A.staticConstField); |
78 print(A.staticFinalField2); | 76 print(A.staticFinalField2); |
79 | 77 |
80 A.staticMethod2(null); | 78 A.staticMethod2(null); |
81 print(A.staticFinalField3); | 79 print(A.staticFinalField3); |
82 print(A.staticFinalField4); | 80 print(A.staticFinalField4); |
83 } | 81 } |
OLD | NEW |