Index: lib/compiler/implementation/resolver.dart |
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart |
index 32fb20465b7abbe712d85c8c3102b23af36b53fe..5b89c283f5d6605a9d1c97cbeff85c5d09f1a805 100644 |
--- a/lib/compiler/implementation/resolver.dart |
+++ b/lib/compiler/implementation/resolver.dart |
@@ -376,12 +376,20 @@ class ResolverTask extends CompilerTask { |
compiler, node.parameters, node.returnType, element)); |
} |
- FunctionSignature resolveTypedef(TypedefElement element) { |
+ void resolveTypedef(TypedefElement element) { |
ahe
2012/08/16 13:22:58
Could you make this look more like resolveClass an
Johnni Winther
2012/08/17 11:15:19
I will do that in a later CL.
|
+ if (element.isResolved || element.isBeingResolved) return; |
+ element.isBeingResolved = true; |
return compiler.withCurrentElement(element, () { |
ahe
2012/08/16 13:22:58
You can use:
..., () => measure() {
This is short
Johnni Winther
2012/08/17 11:15:19
I will do that in a later CL.
|
- Typedef node = |
+ measure(() { |
+ Typedef node = |
compiler.parser.measure(() => element.parseNode(compiler)); |
- return measure(() => SignatureResolver.analyze( |
- compiler, node.formals, node.returnType, element)); |
+ TypedefResolverVisitor visitor = |
+ new TypedefResolverVisitor(compiler, element); |
+ visitor.visit(node); |
+ |
+ element.isBeingResolved = false; |
+ element.isResolved = true; |
+ }); |
}); |
} |
@@ -812,7 +820,19 @@ class TypeResolver { |
type = new InterfaceType(cls, arguments); |
} |
} else if (element.isTypedef()) { |
- type = element.computeType(compiler); |
+ TypedefElement typdef = element; |
+ // TODO(ahe): Should be [ensureResolved]. |
ahe
2012/08/16 13:22:58
I think you have to do this now :-)
Johnni Winther
2012/08/17 11:15:19
I will do that in a later CL.
|
+ compiler.resolveTypedef(typdef); |
+ typdef.computeType(compiler); |
+ Link<Type> arguments = resolveTypeArguments( |
+ node, typdef.typeVariables, |
+ scope, onFailure, whenResolved); |
+ if (typdef.typeVariables.isEmpty() && arguments.isEmpty()) { |
+ // Return the canonical type if it has no type parameters. |
+ type = typdef.computeType(compiler); |
+ } else { |
+ type = new TypedefType(typdef, arguments); |
+ } |
} else if (element.isTypeVariable()) { |
type = element.computeType(compiler); |
} else { |
@@ -1752,6 +1772,27 @@ class TypeDefinitionVisitor extends CommonResolverVisitor<Type> { |
} |
} |
+class TypedefResolverVisitor extends TypeDefinitionVisitor { |
+ TypedefElement get element() => super.element; |
+ |
+ TypedefResolverVisitor(Compiler compiler, TypedefElement typedefElement) |
+ : super(compiler, typedefElement); |
+ |
+ visitTypedef(Typedef node) { |
+ TypedefType type = element.computeType(compiler); |
+ scope = new TypeDeclarationScope(scope, element); |
+ resolveTypeVariableBounds(node.typeParameters); |
+ |
+ element.functionSignature = SignatureResolver.analyze( |
+ compiler, node.formals, node.returnType, element); |
+ |
+ element.alias = compiler.computeFunctionType( |
+ element, element.functionSignature); |
+ |
+ // TODO(johnniwinther): Check for cyclic references in the typedef alias. |
+ } |
+} |
+ |
/** |
* The implementation of [ResolverTask.resolveClass]. |
* |
@@ -1770,7 +1811,7 @@ class ClassResolverVisitor extends TypeDefinitionVisitor { |
ClassResolverVisitor(Compiler compiler, ClassElement classElement) |
: super(compiler, classElement); |
- Type visitClassNode(ClassNode node) { |
+ visitClassNode(ClassNode node) { |
ngeoffray
2012/08/16 12:45:44
Why this change?
Johnni Winther
2012/08/17 11:15:19
A leftover from another change which hasn't been c
|
compiler.ensure(element !== null); |
compiler.ensure(element.resolutionState == ClassElement.STATE_STARTED); |