Type quality of ArrayAccess is same as quality of target type.
Also tweak using "inferred exact" only for places where we sure about type. R=brianwilkerson@google.com BUG= Review URL: https://codereview.chromium.org//11364211 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14867 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -1398,7 +1398,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
||||
}
|
||||
}
|
||||
// print( t[k] )
|
||||
return analyzeBinaryOperator(node, target, Token.INDEX, node, argKey);
|
||||
Type result = analyzeBinaryOperator(node, target, Token.INDEX, node, argKey);
|
||||
return Types.makeInferred(result, target.getQuality());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3571,11 +3572,18 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
||||
*/
|
||||
public static TypeQuality getTypeQuality(DartExpression expr) {
|
||||
if (expr != null) {
|
||||
if (expr instanceof DartMethodInvocation) {
|
||||
return TypeQuality.INFERRED;
|
||||
if (expr instanceof DartIdentifier) {
|
||||
Type varType = expr.getType();
|
||||
if (varType != null) {
|
||||
TypeQuality varTypeQuality = varType.getQuality();
|
||||
if (varTypeQuality == TypeQuality.EXACT) {
|
||||
varTypeQuality = TypeQuality.INFERRED_EXACT;
|
||||
}
|
||||
return varTypeQuality;
|
||||
}
|
||||
}
|
||||
if (expr instanceof DartUnqualifiedInvocation) {
|
||||
return TypeQuality.INFERRED;
|
||||
if (expr instanceof DartLiteral) {
|
||||
return TypeQuality.INFERRED_EXACT;
|
||||
}
|
||||
if (expr instanceof DartUnaryExpression) {
|
||||
DartUnaryExpression unary = (DartUnaryExpression) expr;
|
||||
@@ -3592,10 +3600,15 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
||||
return TypeQuality.INFERRED;
|
||||
}
|
||||
if (expr instanceof DartNewExpression) {
|
||||
DartNewExpression newExpression = (DartNewExpression) expr;
|
||||
ConstructorElement constructorElement = newExpression.getElement();
|
||||
if (constructorElement != null && !constructorElement.getModifiers().isFactory()) {
|
||||
return TypeQuality.INFERRED_EXACT;
|
||||
}
|
||||
return TypeQuality.INFERRED;
|
||||
}
|
||||
}
|
||||
return TypeQuality.INFERRED_EXACT;
|
||||
return TypeQuality.INFERRED;
|
||||
}
|
||||
|
||||
private static boolean hasTypeBoolIntDouble(DartExpression expr) {
|
||||
|
||||
@@ -714,6 +714,9 @@ public class Types {
|
||||
if (type.getQuality().ordinal() > quality.ordinal()) {
|
||||
return type;
|
||||
}
|
||||
if (quality == TypeQuality.EXACT) {
|
||||
return type;
|
||||
}
|
||||
Set<Class<?>> interfaceSet = getAllImplementedInterfaces(type.getClass());
|
||||
if (!interfaceSet.isEmpty()) {
|
||||
Class<?>[] interfaces = (Class[]) interfaceSet.toArray(new Class[interfaceSet.size()]);
|
||||
|
||||
Reference in New Issue
Block a user