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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java

Issue 9250017: Allow classes shadowed by type variables to be referenced in static context (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: oops, left bad test in. Created 8 years, 11 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
Index: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
index 0108c02167c0a769693e4159d4d3dbf450185a4b..c8342351e8975ae28ab8f04ab1fa8e5332ed3b0a 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// 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.
@@ -1112,4 +1112,24 @@ public class ResolverTest extends ResolverTestCase {
"}"),
ResolverErrorCode.CANNOT_OVERRIDE_METHOD_ORDER_NAMED_PARAMS);
}
+
+ public void testTypeVariableInStatic() {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "class A<T> {",
+ " static foo() { new T(); }", // can't ref type variable in method
+ "}"),
+ ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT,
+ ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR);
+ }
+
+ public void testTypeVariableShadowsClass() {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "class T {}",
+ "class A<T> {", // type var T shadows class T
+ " static foo() { new T(); }", // should resolve to class T
+ "}"),
+ ResolverErrorCode.DUPLICATE_TYPE_VARIABLE_WARNING);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698