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

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

Issue 10894008: Issue 4770. Infer type only constant List/Map literals (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | compiler/javatests/com/google/dart/compiler/CompilerTestCase.java » ('j') | 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 1f9124c7c6d74e2b8743767c2231d9392e9da4e8..35cda0e7ae6b7ccdd29f6d9bee75e6f2de8d9a20 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -180,7 +180,6 @@ public class TypeAnalyzer implements DartCompilationPhase {
private final Type nullType;
private final InterfaceType functionType;
private final InterfaceType dynamicIteratorType;
- private final InterfaceType typeType;
private final boolean developerModeChecks;
private final boolean suppressSdkWarnings;
private final boolean typeChecksForInferredTypes;
@@ -215,7 +214,6 @@ public class TypeAnalyzer implements DartCompilationPhase {
this.nullType = typeProvider.getNullType();
this.functionType = typeProvider.getFunctionType();
this.dynamicIteratorType = typeProvider.getIteratorType(dynamicType);
- this.typeType = typeProvider.getTypeType();
CompilerOptions compilerOptions = context.getCompilerConfiguration().getCompilerOptions();
this.suppressSdkWarnings = compilerOptions.suppressSdkWarnings();
this.typeChecksForInferredTypes = compilerOptions.typeChecksForInferredTypes();
@@ -1853,8 +1851,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
}
- // no type arguments, try to infer
- if (node.getTypeArguments().isEmpty()) {
+ // infer type of constant literal
+ if (node.isConst() && node.getTypeArguments().isEmpty()) {
List<Type> valueTypes = Lists.newArrayList();
for (DartMapLiteralEntry literalEntry : node.getEntries()) {
DartExpression value = literalEntry.getValue();
@@ -2707,8 +2705,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
}
}
- // no type arguments, try to infer
- if (node.getTypeArguments().isEmpty()) {
+ // infer type of constant literal
+ if (node.isConst() && node.getTypeArguments().isEmpty()) {
List<Type> elementTypes = Lists.newArrayList();
for (DartExpression expression : node.getExpressions()) {
Type elementType = expression.getType();
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/CompilerTestCase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698