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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10574024: Issue 2379. Can't use type variable with const constructor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index 150b4b83f271310ef43d43fa28e813363d85bea7..11e4d8c0bd31a70ec52200461d0851a249981402 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -1177,7 +1177,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"}"));
assertErrors(libraryResult.getTypeErrors());
}
-
+
public void test_constField() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
getName(),
@@ -1198,6 +1198,31 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 7, 3, 1),
errEx(TypeErrorCode.FIELD_IS_FINAL, 9, 5, 1));
}
+
+ /**
+ * It is a compile-time error to use type variables in "const" instance creation.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2379
+ */
+ public void test_constInstantiation_withTypeVariable() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A<T> {",
+ " const A();",
+ " const A.name();",
+ "}",
+ "class B<U> {",
+ " test() {",
+ " const A<U>();",
+ " const A<U>.name();",
+ " }",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.CONST_WITH_TYPE_VARIABLE, 8, 13, 1),
+ errEx(ResolverErrorCode.CONST_WITH_TYPE_VARIABLE, 9, 13, 1));
+ }
/**
* <p>

Powered by Google App Engine
This is Rietveld 408576698