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

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

Issue 10540104: Issue 3115. Fix for using getter as 'switch' expression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 556cc154177ec5cb1778c1abb29237d463aabfca..f6e39c7fabbae35e24980ab184d578c6e80f5995 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -1948,8 +1948,9 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertInferredElementTypeString(libraryResult, "v2", "bool");
}
- public void test_getType_getterInSwitch() throws Exception {
+ public void test_getType_getterInSwitch_default() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
"int get foo() {}",
"f() {",
" switch (true) {",
@@ -1962,6 +1963,45 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3515
+ */
+ public void test_getType_getterInSwitchExpression_topLevel() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "int get foo() => 42;",
+ "f() {",
+ " switch (foo) {",
+ " case 2:",
+ " break;",
+ " }",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ }
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3515
+ */
+ public void test_getType_getterInSwitchExpression_inClass() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A<T> {",
+ " T get foo() => null;",
+ "}",
+ "f() {",
+ " A<int> a = new A<int>();",
+ " switch (a.foo) {",
+ " case 2:",
+ " break;",
+ " }",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ }
+
+ /**
* Asserts that {@link Element} with given name has expected type.
*/
private void assertInferredElementTypeString(
« 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