| 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 class A<T> { | 5 class A<T> { |
| 6 Function closure; | 6 Function closure; |
| 7 A._(this.closure); | 7 A._(this.closure); |
| 8 | 8 |
| 9 factory A() { | 9 factory A() { |
| 10 return new A._(() => new Set<T>()); | 10 return new A._(() => new Set<T>()); |
| 11 } | 11 } |
| 12 | 12 |
| 13 A.bar() { | 13 A.bar() { |
| 14 closure = () => new Set<T>(); | 14 closure = () => new Set<T>(); |
| 15 } | 15 } |
| 16 | 16 |
| 17 static | 17 static |
| 18 T /// 01: static type warning, dynamic type error | 18 T /// 01: static type warning, dynamic type error |
| 19 staticMethod( | 19 staticMethod( |
| 20 T /// 02: static type warning, dynamic type error | 20 T /// 02: static type warning, dynamic type error |
| 21 a) { | 21 a) { |
| 22 final | 22 final |
| 23 T /// 03: static type warning, dynamic type error | 23 T /// 03: static type warning, dynamic type error |
| 24 a = null; | 24 a = "not_null"; |
| 25 print(a); | 25 print(a); |
| 26 return a; |
| 26 } | 27 } |
| 27 | 28 |
| 28 static final | 29 static final |
| 29 T /// 04: static type warning, dynamic type error | 30 T /// 04: static type warning, dynamic type error |
| 30 staticField = null; | 31 staticField = "not_null"; |
| 32 |
| 33 // Assigning null to a malformed type is not a dynamic error. |
| 34 static |
| 35 T staticMethod2(T a) { |
| 36 final T a = null; |
| 37 print(a); |
| 38 return a; |
| 39 } |
| 40 |
| 41 static final T staticField2 = null; |
| 31 } | 42 } |
| 32 | 43 |
| 33 main() { | 44 main() { |
| 34 var s = ((new A()).closure)(); | 45 var s = ((new A()).closure)(); |
| 35 Expect.isTrue(s is Set); | 46 Expect.isTrue(s is Set); |
| 36 | 47 |
| 37 s = ((new A.bar()).closure)(); | 48 s = ((new A.bar()).closure)(); |
| 38 Expect.isTrue(s is Set); | 49 Expect.isTrue(s is Set); |
| 39 | 50 |
| 40 s = ((new A<int>()).closure)(); | 51 s = ((new A<int>()).closure)(); |
| 41 Expect.isTrue(s is Set<int>); | 52 Expect.isTrue(s is Set<int>); |
| 42 Expect.isFalse(s is Set<double>); | 53 Expect.isFalse(s is Set<double>); |
| 43 | 54 |
| 44 s = ((new A<int>.bar()).closure)(); | 55 s = ((new A<int>.bar()).closure)(); |
| 45 Expect.isTrue(s is Set<int>); | 56 Expect.isTrue(s is Set<int>); |
| 46 Expect.isFalse(s is Set<double>); | 57 Expect.isFalse(s is Set<double>); |
| 47 | 58 |
| 48 A.staticMethod(null); | 59 A.staticMethod("not_null"); |
| 49 print(A.staticField); | 60 print(A.staticField); |
| 61 |
| 62 A.staticMethod2(null); |
| 63 print(A.staticField2); |
| 50 } | 64 } |
| OLD | NEW |