Chromium Code Reviews| 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 { |