Chromium Code Reviews| 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 10a9cf02941ca7f327d1d87301d1687cd7db4857..4b491d15756f1d97bedad8e20192abca4df97b17 100644 |
| --- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java |
| +++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java |
| @@ -1028,9 +1028,31 @@ public class TypeAnalyzer implements DartCompilationPhase { |
| public Type visitNewExpression(DartNewExpression node) { |
| ConstructorElement constructorElement = node.getSymbol(); |
| node.setReferencedElement(constructorElement); |
| + |
| DartTypeNode typeNode = Types.constructorTypeNode(node); |
| + Type type = null; |
| + |
| + // When using a constructor defined in an interface, the bounds can be tighter |
| + // in the default class than defined in the interface. |
|
scheglov
2012/01/04 18:01:15
I don't see in tests "tighter" case, only case whe
zundel
2012/01/04 18:18:19
The spec doesn't actually state tighter bounds, bu
|
| + if (TypeKind.of(typeNode.getType()).equals(TypeKind.INTERFACE) |
| + && ((InterfaceType)typeNode.getType()).getElement().isInterface()) { |
| + InterfaceType itype = (InterfaceType)typeNode.getType(); |
| + ClassElement interfaceElement = itype.getElement(); |
| + InterfaceType defaultClassType = interfaceElement.getDefaultClass(); |
| + if (defaultClassType != null && defaultClassType.getElement() != null) { |
| + validateBounds(typeNode.getTypeArguments(), |
| + itype.getArguments(), |
| + defaultClassType.getElement().getTypeParameters(), |
| + false); |
| + type = itype; |
| + } |
| + } |
| + if (type == null) { |
| + type = validateTypeNode(typeNode, false); |
| + } |
| + |
| DartNode typeName = typeNode.getIdentifier(); |
| - Type type = validateTypeNode(typeNode, false); |
| + |
| if (constructorElement == null) { |
| visit(node.getArgs()); |
| } else { |