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

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

Issue 10919087: Change type of variable using assignment only if it was not explicitly declared (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 669891965d3c508c065823e12edb95ab8a0be25d..0cd749bb8b22fca4f845849ba9f9e9caeb02e89c 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -2017,6 +2017,26 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
}
+ /**
+ * We should infer types only if variable declared without type.
+ */
+ public void test_typesPropagation_dontChangeDeclaredType() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {}",
+ "class B extends A {}",
+ "main() {",
+ " B v = new B();",
+ " var v1 = v;",
+ " v = new A();",
+ " var v2 = v;",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ assertInferredElementTypeString(testUnit, "v1", "B");
+ assertInferredElementTypeString(testUnit, "v2", "B");
+ }
+
public void test_typesPropagation_multiAssign() 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