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

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 9959110: Prevent NPE in TypeAnalyzer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index b7486dd22918302c9ae0531784e07d6acf3e6246..367993591fffb80f0bb1aac1a145ad271eadf744 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -1715,15 +1715,19 @@ public class TypeAnalyzer implements DartCompilationPhase {
@Override
public Type visitArrayLiteral(DartArrayLiteral node) {
visit(node.getTypeArguments());
- InterfaceType type = node.getType();
- Type elementType = type.getArguments().get(0);
- for (DartExpression expression : node.getExpressions()) {
- boolean isValueAssignable = checkAssignable(elementType, expression);
- if (developerModeChecks && !isValueAssignable) {
- typeError(expression, ResolverErrorCode.LIST_LITERAL_ELEMENT_TYPE, elementType);
+ InterfaceType interfaceType = node.getType();
+ if (interfaceType != null
+ && interfaceType.getArguments() != null
+ && interfaceType.getArguments().size() > 0) {
+ Type elementType = interfaceType.getArguments().get(0);
+ for (DartExpression expression : node.getExpressions()) {
+ boolean isValueAssignable = checkAssignable(elementType, expression);
+ if (developerModeChecks && !isValueAssignable) {
+ typeError(expression, ResolverErrorCode.LIST_LITERAL_ELEMENT_TYPE, elementType);
+ }
}
}
- return type;
+ return interfaceType;
}
@Override
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698