Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: tests/language/type_parameter_test.dart

Issue 19097003: Support new malformed types semantics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 staticField = "not_null"; 33 staticField = "not_null";
34 34
35 // Assigning null to a malformed type is not a dynamic error. 35 // Assigning null to a malformed type is not a dynamic error.
36 static 36 static
37 T staticMethod2(T a) { 37 T staticMethod2(T a) {
38 final T a = null; 38 final T a = null;
39 print(a); 39 print(a);
40 return a; 40 return a;
41 } 41 }
42 42
(...skipping 14 matching lines...) Expand all
57 s = ((new A<int>.bar()).closure)(); 57 s = ((new A<int>.bar()).closure)();
58 Expect.isTrue(s is Set<int>); 58 Expect.isTrue(s is Set<int>);
59 Expect.isFalse(s is Set<double>); 59 Expect.isFalse(s is Set<double>);
60 60
61 A.staticMethod("not_null"); 61 A.staticMethod("not_null");
62 print(A.staticField); 62 print(A.staticField);
63 63
64 A.staticMethod2(null); 64 A.staticMethod2(null);
65 print(A.staticField2); 65 print(A.staticField2);
66 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698