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

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

Issue 11368132: Issue 6560. Report error when generative constructor calls factory constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 8e46da100b051310153f0ad1d8f590e96972fa35..0c62e61b029914677d41403b7a0c503b463122d0 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -5570,4 +5570,43 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertEquals("A", node.getClassElement().getName());
}
}
+
+ public void test_notGenerativeConstructor_default() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " factory A() {",
+ " return null;",
+ " }",
+ "}",
+ "class B extends A {",
+ " B() : super() {}", // explicit call of super constructor
+ "}",
+ "class C extends A {",
+ " C() {}", // implicit call of super constructor
+ "}",
+ "class D extends A {", // implicit call of super constructor
+ "}",
+ "");
+ assertErrors(result.getErrors(),
+ errEx(ResolverErrorCode.NOT_GENERATIVE_SUPER_CONSTRUCTOR, 8, 9, 7),
+ errEx(ResolverErrorCode.NOT_GENERATIVE_SUPER_CONSTRUCTOR, 11, 3, 1),
+ errEx(ResolverErrorCode.NOT_GENERATIVE_SUPER_CONSTRUCTOR, 13, 7, 1));
+ }
+
+ public void test_notGenerativeConstructor_explicitNamed() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " factory A.named() {",
+ " return null;",
+ " }",
+ "}",
+ "class B extends A {",
+ " B() : super.named() {}", // explicit call of super constructor
+ "}",
+ "");
+ assertErrors(result.getErrors(),
+ errEx(ResolverErrorCode.NOT_GENERATIVE_SUPER_CONSTRUCTOR, 8, 9, 13));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698