| 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 910e9d1e39c86abb4c1ee7cc19bc972a245dd105..42e400aa8c2b421f782123b3067be38eeb42b735 100644
|
| --- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
|
| +++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
|
| @@ -5041,7 +5041,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
|
| errEx(ResolverErrorCode.REDIRECTION_CONSTRUCTOR_CYCLE, 6, 11, 7),
|
| errEx(ResolverErrorCode.REDIRECTION_CONSTRUCTOR_CYCLE, 9, 11, 7));
|
| }
|
| -
|
| +
|
| public void test_redirectingFactoryConstructor_notConst_fromConst() throws Exception {
|
| AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
| "// filler filler filler filler filler filler filler filler filler filler",
|
| @@ -5058,6 +5058,78 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
|
| errEx(ResolverErrorCode.REDIRECTION_CONSTRUCTOR_TARGET_MUST_BE_CONST, 7, 29, 5));
|
| }
|
|
|
| + public void test_redirectingFactoryConstructor_shouldBeSubType() throws Exception {
|
| + AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "class A {",
|
| + " A() {}",
|
| + " A.named(p0) {}",
|
| + "}",
|
| + "",
|
| + "class B {",
|
| + " factory B.foo(p0) = A;",
|
| + " factory B.bar() = A.named;",
|
| + "}",
|
| + "");
|
| + assertErrors(
|
| + libraryResult.getErrors(),
|
| + errEx(TypeErrorCode.REDIRECTION_CONSTRUCTOR_TARGET_MUST_BE_SUBTYPE, 8, 23, 1),
|
| + errEx(TypeErrorCode.REDIRECTION_CONSTRUCTOR_TARGET_MUST_BE_SUBTYPE, 9, 23, 5));
|
| + }
|
| +
|
| + public void test_redirectingFactoryConstructor_shouldBeSubType2() throws Exception {
|
| + AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "class A<T> {",
|
| + " A.named(T t) {}",
|
| + "}",
|
| + "",
|
| + "class B<T> {",
|
| + " factory B.foo(T t) = A<T>.named;",
|
| + "}",
|
| + "class B2<T, V> {",
|
| + " factory B2.foo(V v) = A<V>.named;",
|
| + "}",
|
| + "");
|
| + assertErrors(libraryResult.getErrors());
|
| + }
|
| +
|
| + public void test_redirectingFactoryConstructor_shouldBeSubType3() throws Exception {
|
| + AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "class A<T> {",
|
| + " A(A<T> p) {}",
|
| + "}",
|
| + "",
|
| + "class B<T> {",
|
| + " factory B.foo(A<T> p) = A;",
|
| + "}",
|
| + "");
|
| + assertErrors(libraryResult.getErrors());
|
| + }
|
| +
|
| + public void test_redirectingFactoryConstructor_notSubType_typeParameterBounds() throws Exception {
|
| + AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "class A1<T extends String> {",
|
| + " A1() {}",
|
| + "}",
|
| + "class A2<T> {",
|
| + " A2() {}",
|
| + "}",
|
| + "",
|
| + "class B {",
|
| + " factory B.name1() = A1<String>;",
|
| + " factory B.name2() = A1<int>;",
|
| + " factory B.name3() = A2<String>;",
|
| + " factory B.name4() = A2<int>;",
|
| + "}",
|
| + "");
|
| + assertErrors(
|
| + libraryResult.getErrors(),
|
| + errEx(TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, 11, 26, 3));
|
| + }
|
| +
|
| /**
|
| * <p>
|
| * http://code.google.com/p/dart/issues/detail?id=4778
|
|
|