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

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

Issue 10962047: Issue 5327. Fix for invalid 'instantiation of a class with the inherited abstract members' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 98ae0054ae7047136d42a5cd5db3a5f34967ca65..ab61e6e8c9991a7ee0640e5f252873a66a039ae0 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -762,6 +762,70 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * There was bug that implementing setter still caused warning.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=5327
+ */
+ public void test_warnAbstract_whenInstantiate_implementSetter() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "interface I {",
Brian Wilkerson 2012/09/22 16:19:59 It might be good to re-write this now to use an ab
+ " set foo(x);",
+ "}",
+ "class A implements I {",
+ " set foo(x) {}",
+ "}",
+ "main() {",
+ " new A();",
+ "}");
+ assertErrors(libraryResult.getTypeErrors());
+ }
+
+ /**
+ * When both getter and setter were abstract and only getter implemented, we should report error.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=5327
+ */
+ public void test_warnAbstract_whenInstantiate_implementsOnlyGetter() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "interface I {",
+ " get foo();",
+ " set foo(x);",
+ "}",
+ "class A implements I {",
+ " get foo() => 0;",
+ "}",
+ "main() {",
+ " new A();",
+ "}");
+ assertErrors(
+ libraryResult.getTypeErrors(),
+ errEx(TypeErrorCode.INSTANTIATION_OF_CLASS_WITH_UNIMPLEMENTED_MEMBERS, 9, 7, 1));
+ }
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=5327
+ */
+ public void test_warnAbstract_whenInstantiate_implementsSetter_inSuperClass() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "interface I {",
+ " get foo();",
+ " set foo(x);",
+ "}",
+ "class A implements I {",
+ " abstract get foo();",
+ " set foo(x) {}",
+ "}",
+ "class B extends A {",
+ " get foo() => 0;",
+ "}",
+ "main() {",
+ " new B();",
+ "}");
+ assertErrors(libraryResult.getTypeErrors());
+ }
+
+ /**
* 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.
@@ -4993,7 +5057,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
result.getErrors(),
errEx(ResolverErrorCode.DUPLICATE_INITIALIZATION, 4, 9, 5));
}
-
+
public void test_getOverridden_method() throws Exception {
analyzeLibrary(
"// filler filler filler filler filler filler filler filler filler filler",
« 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