| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 a) { | 23 a) { |
| 24 final | 24 final |
| 25 T /// 03: static type warning, dynamic type error | 25 T /// 03: static type warning, dynamic type error |
| 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, dynamic type error |
| 33 staticField = "not_null"; | 33 staticFinalField = "not_null"; |
| 34 |
| 35 static const |
| 36 // TODO(regis): Support 'compile-time type error' in test.dart and use below. |
| 37 T /// 05: static type warning, compile-time error |
| 38 staticConstField = "not_null"; |
| 39 |
| 40 static not_null() => "not_null"; |
| 41 static final |
| 42 T /// 06: static type warning, dynamic type error |
| 43 staticFinalField2 = not_null(); |
| 44 |
| 34 | 45 |
| 35 // Assigning null to a malformed type is not a dynamic error. | 46 // Assigning null to a malformed type is not a dynamic error. |
| 36 static | 47 static |
| 37 T staticMethod2(T a) { | 48 T staticMethod2(T a) { |
| 38 final T a = null; | 49 final T a = null; |
| 39 print(a); | 50 print(a); |
| 40 return a; | 51 return a; |
| 41 } | 52 } |
| 42 | 53 |
| 43 static final T staticField2 = null; | 54 static final T staticFinalField3 = null; |
| 55 |
| 56 static null_() => null; |
| 57 static final T staticFinalField4 = null_(); |
| 44 } | 58 } |
| 45 | 59 |
| 46 main() { | 60 main() { |
| 47 var s = ((new A()).closure)(); | 61 var s = ((new A()).closure)(); |
| 48 Expect.isTrue(s is Set); | 62 Expect.isTrue(s is Set); |
| 49 | 63 |
| 50 s = ((new A.bar()).closure)(); | 64 s = ((new A.bar()).closure)(); |
| 51 Expect.isTrue(s is Set); | 65 Expect.isTrue(s is Set); |
| 52 | 66 |
| 53 s = ((new A<int>()).closure)(); | 67 s = ((new A<int>()).closure)(); |
| 54 Expect.isTrue(s is Set<int>); | 68 Expect.isTrue(s is Set<int>); |
| 55 Expect.isFalse(s is Set<double>); | 69 Expect.isFalse(s is Set<double>); |
| 56 | 70 |
| 57 s = ((new A<int>.bar()).closure)(); | 71 s = ((new A<int>.bar()).closure)(); |
| 58 Expect.isTrue(s is Set<int>); | 72 Expect.isTrue(s is Set<int>); |
| 59 Expect.isFalse(s is Set<double>); | 73 Expect.isFalse(s is Set<double>); |
| 60 | 74 |
| 61 A.staticMethod("not_null"); | 75 A.staticMethod("not_null"); |
| 62 print(A.staticField); | 76 print(A.staticFinalField); |
| 77 print(A.staticConstField); |
| 78 print(A.staticFinalField2); |
| 63 | 79 |
| 64 A.staticMethod2(null); | 80 A.staticMethod2(null); |
| 65 print(A.staticField2); | 81 print(A.staticFinalField3); |
| 82 print(A.staticFinalField4); |
| 66 } | 83 } |
| OLD | NEW |