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

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

Issue 10543087: Fix for NPE when unresolved constructor used (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 b3e498d4e88539f60561cb5ace3a37a8c0cea491..e9151c91ecfe007813e26e869075bfd916786595 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -1498,6 +1498,21 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertInferredElementTypeString(libraryResult, "v", "<dynamic>");
}
+
+ /**
+ * When we can not identify type of assigned value we should keep "Dynamic" as type of variable.
+ */
+ public void test_typesPropagation_assign_newUnknownType() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "f() {",
+ " var v1 = new Unknown();",
+ " var v2 = new Unknown.name();",
+ "}",
+ "");
+ assertInferredElementTypeString(libraryResult, "v1", "<dynamic>");
+ assertInferredElementTypeString(libraryResult, "v2", "<dynamic>");
+ }
public void test_typesPropagation_ifIsType() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
@@ -1976,7 +1991,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
@Override
public Void visitIdentifier(DartIdentifier node) {
Element element = node.getElement();
- if (element.getName().equals(name)) {
+ if (element != null && element.getName().equals(name)) {
result[0] = element;
}
return super.visitIdentifier(node);
« 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