| Index: compiler/java/com/google/dart/compiler/resolver/TypeVariableElementImplementation.java
|
| diff --git a/compiler/java/com/google/dart/compiler/resolver/TypeVariableElementImplementation.java b/compiler/java/com/google/dart/compiler/resolver/TypeVariableElementImplementation.java
|
| index 149861ee25d405531e7315e746434148280c45e0..bfc01af84cab6180f429a5d2d259c8e904e28671 100644
|
| --- a/compiler/java/com/google/dart/compiler/resolver/TypeVariableElementImplementation.java
|
| +++ b/compiler/java/com/google/dart/compiler/resolver/TypeVariableElementImplementation.java
|
| @@ -4,7 +4,7 @@
|
|
|
| package com.google.dart.compiler.resolver;
|
|
|
| -import com.google.dart.compiler.ast.DartNode;
|
| +import com.google.dart.compiler.ast.DartTypeNode;
|
| import com.google.dart.compiler.ast.DartTypeParameter;
|
| import com.google.dart.compiler.type.Type;
|
| import com.google.dart.compiler.type.TypeVariable;
|
| @@ -12,19 +12,26 @@ import com.google.dart.compiler.type.Types;
|
|
|
| /**
|
| * Represention of a type variable.
|
| - *
|
| - * <p>For example, in {@code class Foo<T> { ... }}, {@code T} is a
|
| - * type variable.
|
| + *
|
| + * <p>
|
| + * For example, in {@code class Foo<T> ... } , {@code T} is a type variable.
|
| */
|
| class TypeVariableElementImplementation extends AbstractElement implements TypeVariableElement {
|
|
|
| private final Element owner;
|
| private TypeVariable type;
|
| private Type bound;
|
| + private final DartTypeNode boundNode;
|
|
|
| - TypeVariableElementImplementation(DartNode node, String name, Element owner) {
|
| + TypeVariableElementImplementation(String name, Type bound) {
|
| + this(null, name, null);
|
| + this.bound = bound;
|
| + }
|
| +
|
| + TypeVariableElementImplementation(DartTypeParameter node, String name, Element owner) {
|
| super(node, name);
|
| this.owner = owner;
|
| + this.boundNode = node != null ? node.getBound() : null;
|
| }
|
|
|
| @Override
|
| @@ -39,7 +46,7 @@ class TypeVariableElementImplementation extends AbstractElement implements TypeV
|
|
|
| static TypeVariableElementImplementation fromNode(DartTypeParameter node, Element owner) {
|
| TypeVariableElementImplementation element =
|
| - new TypeVariableElementImplementation(node, node.getName().getName(), owner);
|
| + new TypeVariableElementImplementation(node, node.getName().getName(), owner);
|
| element.setType(Types.typeVariable(element));
|
| return element;
|
| }
|
| @@ -55,12 +62,16 @@ class TypeVariableElementImplementation extends AbstractElement implements TypeV
|
| }
|
|
|
| @Override
|
| - public void setBound(Type bound) {
|
| - this.bound = bound;
|
| - }
|
| -
|
| - @Override
|
| public Type getBound() {
|
| + if (boundNode != null) {
|
| + return boundNode.getType();
|
| + }
|
| + // no explicit bound, try to get Object
|
| + if (bound == null) {
|
| + if (owner instanceof ClassElement) {
|
| + bound = ((ClassElement) owner).getLibrary().lookupLocalElement("Object").getType();
|
| + }
|
| + }
|
| return bound;
|
| }
|
|
|
| @@ -68,4 +79,9 @@ class TypeVariableElementImplementation extends AbstractElement implements TypeV
|
| public Element getDeclaringElement() {
|
| return owner;
|
| }
|
| +
|
| + @Override
|
| + public Element getEnclosingElement() {
|
| + return owner;
|
| + }
|
| }
|
|
|