Chromium Code Reviews| Index: compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java |
| diff --git a/compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java b/compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java |
| index 133fac6e4465660fdf5f7f91e24919a51b5a46b0..da6331f1798b4105a24252507b52fc8f57bd5e07 100644 |
| --- a/compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java |
| +++ b/compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java |
| @@ -7,6 +7,7 @@ package com.google.dart.compiler.resolver; |
| import com.google.dart.compiler.ErrorCode; |
| import com.google.dart.compiler.ast.DartCatchBlock; |
| import com.google.dart.compiler.ast.DartFunction; |
| +import com.google.dart.compiler.ast.DartFunctionTypeAlias; |
| import com.google.dart.compiler.ast.DartNode; |
| import com.google.dart.compiler.ast.DartNodeTraverser; |
| import com.google.dart.compiler.ast.DartParameter; |
| @@ -67,6 +68,49 @@ abstract class ResolveVisitor extends DartNodeTraverser<Element> { |
| return element; |
| } |
| + final FunctionAliasElement resolveFunctionAlias(DartFunctionTypeAlias node) { |
| + List<TypeVariable> typeVariables = Elements.makeTypeVariables(node.getTypeParameters(), |
| + node.getSymbol()); |
| + if (typeVariables != null) { |
| + for (TypeVariable typeParameter : typeVariables) { |
| + TypeVariableElement variable = (TypeVariableElement) typeParameter.getElement(); |
|
zundel
2011/11/16 23:54:56
Could we consolidate the resolution of type parame
codefu
2011/11/17 21:17:10
Certainly.
|
| + DartTypeParameter typeParameterNode = (DartTypeParameter) variable.getNode(); |
| + DartTypeNode boundNode = typeParameterNode.getBound(); |
| + Type bound; |
| + if (boundNode != null) { |
| + bound = getContext().resolveType(boundNode, true, ResolverErrorCode.NO_SUCH_TYPE); |
| + boundNode.setType(bound); |
| + } else { |
| + bound = typeProvider.getObjectType(); |
| + } |
| + variable.setBound(bound); |
| + // typedef List<T> ParametrizedFun2<T, U, V extends Map<T, int>>; |
| + // T & V need to be added to the scope before Map<T,int> can be resolved |
| + getContext().getScope().declareElement(variable.getName(), variable); |
| + } |
| + } |
| + DartTypeNode returnType = node.getReturnTypeNode(); |
| + if (returnType != null) { |
| + for (DartTypeNode typeNode : returnType.getTypeArguments()) { |
| + if (!(typeNode.getType().getElement() instanceof TypeVariableElement)) { |
| + continue; |
|
zundel
2011/11/16 23:54:56
I don't understand this continue. Maybe this shou
codefu
2011/11/17 21:17:10
Cleaned up
|
| + } |
| + TypeVariableElement variable = (TypeVariableElement) typeNode.getType().getElement(); |
| + DartTypeParameter typeParameterNode = (DartTypeParameter) variable.getNode(); |
| + DartTypeNode boundNode = typeParameterNode.getBound(); |
| + Type bound; |
| + if (boundNode != null) { |
| + bound = getContext().resolveType(boundNode, true, ResolverErrorCode.NO_SUCH_TYPE); |
| + boundNode.setType(bound); |
| + } else { |
| + bound = typeProvider.getObjectType(); |
| + } |
| + variable.setBound(bound); |
| + } |
| + } |
| + return null; |
| + } |
| + |
| abstract boolean isStaticContext(); |
| @Override |