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 3ae944a73002ad0dec5baf46668e0fd4a370de19..8a01391827ba72830c7d46436dc9753422169b72 100644 |
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java |
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java |
@@ -18,6 +18,7 @@ import com.google.dart.compiler.DartCompilerErrorCode; |
import com.google.dart.compiler.DartCompilerListener; |
import com.google.dart.compiler.MockArtifactProvider; |
import com.google.dart.compiler.MockLibrarySource; |
+import com.google.dart.compiler.ast.ASTVisitor; |
import com.google.dart.compiler.ast.DartClass; |
import com.google.dart.compiler.ast.DartExprStmt; |
import com.google.dart.compiler.ast.DartExpression; |
@@ -29,7 +30,6 @@ import com.google.dart.compiler.ast.DartInvocation; |
import com.google.dart.compiler.ast.DartMethodDefinition; |
import com.google.dart.compiler.ast.DartNewExpression; |
import com.google.dart.compiler.ast.DartNode; |
-import com.google.dart.compiler.ast.ASTVisitor; |
import com.google.dart.compiler.ast.DartParameter; |
import com.google.dart.compiler.ast.DartUnit; |
import com.google.dart.compiler.ast.DartUnqualifiedInvocation; |
@@ -768,7 +768,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase { |
DartExprStmt stmt = (DartExprStmt) methodBar.getFunction().getBody().getStatements().get(0); |
invocation = (DartUnqualifiedInvocation) stmt.getExpression(); |
} |
- // Check that unqualified foo() invocation is resolved to the top-level (library) function. |
+ // Check that unqualified foo() invocation is resolved to the top-level (library) function. |
Symbol symbol = invocation.getTarget().getSymbol(); |
assertNotNull(symbol); |
assertSame(unit, symbol.getNode().getParent()); |
@@ -963,6 +963,49 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase { |
assertErrors(result.getErrors(), errEx(ResolverErrorCode.NO_SUCH_TYPE, 2, 17, 7)); |
} |
+ /** |
+ * <p> |
+ * http://code.google.com/p/dart/issues/detail?id=380 |
+ */ |
+ public void test_setterGetterDifferentType() throws Exception { |
+ AnalyzeLibraryResult result = |
+ analyzeLibrary( |
+ "// filler filler filler filler filler filler filler filler filler filler", |
+ "class A {} ", |
+ "class B extends A {}", |
+ "class C {", |
+ " A getterField; ", |
+ " B setterField; ", |
+ " A get field() { return getterField; }", |
+ " void set field(B arg) { setterField = arg; }", |
+ "}", |
+ "main() {", |
+ " C instance = new C();", |
+ " instance.field = new B();", |
+ " A resultA = instance.field;", |
+ " instance.field = new A();", |
+ " B resultB = instance.field;", |
+ "}"); |
+ |
+ assertErrors(result.getErrors()); |
+ } |
+ |
+ public void test_setterGetterNotAssignable() throws Exception { |
+ AnalyzeLibraryResult result = |
+ analyzeLibrary( |
+ "// filler filler filler filler filler filler filler filler filler filler", |
+ "class A {} ", |
+ "class B {}", |
+ "class C {", |
+ " A getterField; ", |
+ " B setterField; ", |
+ " A get field() { return getterField; }", |
+ " void set field(B arg) { setterField = arg; }", |
+ "}"); |
+ assertErrors(result.getErrors(), |
+ errEx(TypeErrorCode.SETTER_TYPE_MUST_BE_ASSIGNABLE, 8, 18, 5)); |
+ |
+ } |
private AnalyzeLibraryResult analyzeLibrary(String... lines) throws Exception { |
return analyzeLibrary(getName(), makeCode(lines)); |