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

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

Issue 10108014: Another case of creating from factory constructors was not taken into account in r6619 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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') | no next file » | 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 7b4860b0abbfb00326664250df27d471f1284454..27c912662af082602da749cb34cde975224f9bd8 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -416,8 +416,9 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
- * Factory constructor can instantiate any class and return it non-abstract class instance, but
- * spec requires warnings, so we provide it, but using different constant.
+ * Factory constructor can instantiate any class and return it non-abstract class instance, Even
+ * thought this is an abstract class, there should be no warnings for the invocation of the
+ * factory constructor.
*/
public void test_abstractClass_whenInstantiate_factoryConstructor()
throws Exception {
@@ -425,14 +426,14 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
analyzeLibrary(
getName(),
makeCode(
- "abstract class A {",
+ "abstract class A {", // explicitly abstract
" factory A() {",
" return null;",
" }",
"}",
"class C {",
" foo() {",
- " return new A();",
+ " return new A();", // no error - factory constructor
" }",
"}"));
assertErrors(
@@ -440,6 +441,35 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * Factory constructor can instantiate any class and return it non-abstract class instance, Even
+ * thought this is an abstract class, there should be no warnings for the invocation of the
+ * factory constructor.
+ */
+ public void test_abstractClass_whenInstantiate_factoryConstructor2()
+ throws Exception {
+ AnalyzeLibraryResult libraryResult =
+ analyzeLibrary(
+ getName(),
+ makeCode(
+ "class A extends B {", // class doesn't implement all abstract methods
+ " factory A() {",
+ " return null;",
+ " }",
+ "}",
+ "class B {",
+ " abstract method();",
+ "}",
+ "class C {",
+ " foo() {",
+ " return new A();", // no error, factory constructor
ahe 2012/04/17 11:44:55 Actually, this should never cause a warning. This
zundel 2012/04/17 13:49:17 Since I know the invoking factory method warning i
+ " }",
+ "}"));
+ assertErrors(
+ libraryResult.getTypeErrors(),
+ errEx(TypeErrorCode.ABSTRACT_CLASS_WITHOUT_ABSTRACT_MODIFIER, 1, 7, 1));
+ }
+
+ /**
* Spec 7.3 It is a static warning if a setter declares a return type other than void.
*/
public void testWarnOnNonVoidSetter() throws Exception {
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698