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

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

Issue 9188004: Issue 1091: Static type warning for setters with non-void return types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Language multitest Created 8 years, 11 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
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 2eddbd02b19b6390df6085a5e5007b60de67ea8b..64ef5cb6e63f4057b7a2af29d18636a2512a2478 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -421,4 +421,26 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
libraryResult.getTypeErrors(),
errEx(TypeErrorCode.INSTANTIATION_OF_ABSTRACT_CLASS_USING_FACTORY, 8, 16, 1));
}
+
+ /**
+ * 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.
+ */
+ public void testWarnOnNonVoidSetter()
+ throws Exception {
+ AnalyzeLibraryResult libraryResult =
+ analyzeLibrary(
+ getName(),
+ makeCode(
+ "class A {",
+ " void set foo(bool a) {}",
+ " set bar(bool a) {}",
+ " Dynamic set baz(bool a) {}",
+ " bool set bob(bool a) {}",
+ "}"));
+ assertErrors(
+ libraryResult.getTypeErrors(),
+ errEx(TypeErrorCode.SETTER_RETURN_TYPE, 4, 3, 7),
+ errEx(TypeErrorCode.SETTER_RETURN_TYPE, 5, 3, 4));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698