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

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

Issue 10913168: Issue 5004. Type inference with 'is!' and 'continue'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks comments 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 a6c47020b19ac7538eece7eb31b042b7b9b30027..b365bc1f04f32ee84e4d0b97f7868f5a3e8f740e 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -2592,6 +2592,42 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertInferredElementTypeString(testUnit, "v1", "Dynamic");
}
+ public void test_typesPropagation_ifIsNotType_hasThenContinue() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " for (var v in <Object>[1, 'two', 3]) {",
+ " var v1 = v;",
+ " if (v is! String) {",
+ " continue;",
+ " }",
+ " var v2 = v;",
+ " }",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ assertInferredElementTypeString(testUnit, "v1", "Object");
+ assertInferredElementTypeString(testUnit, "v2", "String");
+ }
+
+ public void test_typesPropagation_ifIsNotType_hasThenBreak() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " for (var v in <Object>[1, 'two', 3]) {",
+ " var v1 = v;",
+ " if (v is! String) {",
+ " break;",
+ " }",
+ " var v2 = v;",
+ " }",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ assertInferredElementTypeString(testUnit, "v1", "Object");
+ assertInferredElementTypeString(testUnit, "v2", "String");
+ }
+
public void test_typesPropagation_ifIsNotType_or() 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