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

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

Issue 10996039: Bring type variables into static scope, but produce compile-time error when they are used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Just rebased Created 8 years, 2 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 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: compile-time error
19 staticMethod( 19 staticMethod(
20 T /// 02: static type warning, dynamic type error 20 T /// 02: compile-time error
21 a) { 21 a) {
22 final 22 final
23 T /// 03: static type warning, dynamic type error 23 T /// 03: compile-time error
24 a = null; 24 a = null;
25 print(a); 25 print(a);
26 } 26 }
27 27
28 static final 28 static final
29 T /// 04: static type warning, dynamic type error 29 T /// 04: compile-time error
30 staticField = null; 30 staticField = null;
31 } 31 }
32 32
33 main() { 33 main() {
34 var s = ((new A()).closure)(); 34 var s = ((new A()).closure)();
35 Expect.isTrue(s is Set); 35 Expect.isTrue(s is Set);
36 36
37 s = ((new A.bar()).closure)(); 37 s = ((new A.bar()).closure)();
38 Expect.isTrue(s is Set); 38 Expect.isTrue(s is Set);
39 39
40 s = ((new A<int>()).closure)(); 40 s = ((new A<int>()).closure)();
41 Expect.isTrue(s is Set<int>); 41 Expect.isTrue(s is Set<int>);
42 Expect.isFalse(s is Set<double>); 42 Expect.isFalse(s is Set<double>);
43 43
44 s = ((new A<int>.bar()).closure)(); 44 s = ((new A<int>.bar()).closure)();
45 Expect.isTrue(s is Set<int>); 45 Expect.isTrue(s is Set<int>);
46 Expect.isFalse(s is Set<double>); 46 Expect.isFalse(s is Set<double>);
47 47
48 A.staticMethod(null); 48 A.staticMethod(null);
49 print(A.staticField); 49 print(A.staticField);
50 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698