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

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

Issue 10546118: Issue 3534. It is a compile-time error if a typedef refers to itself (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up 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
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 556cc154177ec5cb1778c1abb29237d463aabfca..a511dff1ef24f35e6d98cb7a80dd61aea2fc094f 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -71,6 +71,52 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
libraryResult.getErrors(),
errEx(ResolverErrorCode.MAIN_FUNCTION_PARAMETERS, 2, 1, 4));
}
+
+ /**
+ * It is a compile-time error if a typedef refers to itself via a chain of references that does
+ * not include a class or interface type.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3534
+ */
+ public void test_functionTypeAlias_selfRerences_direct() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "typedef A A();",
+ "typedef B(B b);",
+ "typedef C([C c]);",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 2, 1, 14),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 3, 1, 15),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 4, 1, 17));
+ }
+
+ /**
+ * It is a compile-time error if a typedef refers to itself via a chain of references that does
+ * not include a class or interface type.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3534
+ */
+ public void test_functionTypeAlias_selfRerences_indirect() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "typedef B1 A1();",
+ "typedef A1 B1();",
+ "typedef B2 A2();",
+ "typedef B2(A2 a);",
+ "typedef B3 A3();",
+ "typedef B3([A3 a]);",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 2, 1, 16),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 3, 1, 16),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 4, 1, 16),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 5, 1, 17),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 6, 1, 16),
+ errEx(TypeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 7, 1, 19));
+ }
/**
* It is a compile-time error if initializer list contains an initializer for a variable that
@@ -2239,4 +2285,4 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
private AnalyzeLibraryResult analyzeLibrary(String... lines) throws Exception {
return analyzeLibrary(getName(), makeCode(lines));
}
-}
+}
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698