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

Unified Diff: tests/language/type_parameter_test.dart

Issue 10913081: Fix resolution of type parameters in static context, and the use of type parameters in closures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/type_parameter_test.dart
===================================================================
--- tests/language/type_parameter_test.dart (revision 0)
+++ tests/language/type_parameter_test.dart (revision 0)
@@ -0,0 +1,50 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A<T> {
+ Function closure;
+ A._(this.closure);
+
+ factory A() {
+ return new A._(() => new Set<T>());
+ }
+
+ A.bar() {
+ closure = () => new Set<T>();
+ }
+
+ static
+ T /// 01: static type warning, dynamic type error
+ staticMethod(
+ T /// 02: static type warning, dynamic type error
+ a) {
+ final
+ T /// 03: static type warning, dynamic type error
+ a = null;
+ print(a);
+ }
+
+ static final
+ T /// 04: static type warning, dynamic type error
+ staticField = null;
+}
+
+main() {
+ var s = ((new A()).closure)();
+ Expect.isTrue(s is Set);
+
+ s = ((new A.bar()).closure)();
+ Expect.isTrue(s is Set);
+
+ s = ((new A<int>()).closure)();
+ Expect.isTrue(s is Set<int>);
+ Expect.isFalse(s is Set<double>);
+
+ s = ((new A<int>.bar()).closure)();
+ Expect.isTrue(s is Set<int>);
+ Expect.isFalse(s is Set<double>);
+
+ A.staticMethod(null);
+ print(A.staticField);
+}
« no previous file with comments | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698