Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10824062: dart2dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/dart_backend/renamer.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 94808dc9e4b4d63e5c9a268f40e52da970dde9cf..fc52a7c9c71d18d8076bd420f84158b56fccd8d1 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -699,9 +699,9 @@ class TypeResolver {
final Compiler compiler;
TypeResolver(this.compiler);
- Element resolveTypeName(Scope context, TypeAnnotation node) {
- Identifier typeName = node.typeName.asIdentifier();
- Send send = node.typeName.asSend();
+ Element resolveTypeName(Scope context, Node typeNode) {
+ Identifier typeName = typeNode.asIdentifier();
+ Send send = typeNode.asSend();
if (send !== null) {
typeName = send.selector;
}
@@ -744,9 +744,26 @@ class TypeResolver {
whenResolved);
}
+ Type resolveTypeVariableInContext(Scope context, TypeVariable node,
+ onFailure) {
+ Element element = resolveTypeName(context, node.name);
+ Type type;
+ if (element === null) {
+ onFailure(node, MessageKind.CANNOT_RESOLVE_TYPE, [node.name]);
+ } else if (!element.impliesType()) {
+ onFailure(node, MessageKind.NOT_A_TYPE, [node.name]);
+ } else if (element.isTypeVariable()) {
+ type = element.computeType(compiler);
ahe 2012/08/02 18:56:15 I cannot rule out that this won't lead to an infin
+ } else {
+ compiler.cancel("unexpected element kind ${element.kind}",
+ node: node);
+ }
+ return type;
+ }
+
Type resolveTypeAnnotationInContext(Scope context, TypeAnnotation node,
onFailure, whenResolved) {
- Element element = resolveTypeName(context, node);
+ Element element = resolveTypeName(context, node.typeName);
Type type;
if (element === null) {
onFailure(node, MessageKind.CANNOT_RESOLVE_TYPE, [node.typeName]);
@@ -769,10 +786,16 @@ class TypeResolver {
onFailure(typeArguments.head,
MessageKind.ADDITIONAL_TYPE_ARGUMENT);
}
- Type argType = resolveTypeAnnotationInContext(context,
ahe 2012/08/02 18:56:15 The original code is probably broken as well and m
- typeArguments.head,
- onFailure,
- whenResolved);
+ // TypeVariable may happen in default clause of an interface.
ahe 2012/08/02 18:56:15 This is a hack. The problem is that the default cl
+ Type argType;
+ if (typeArguments.head is TypeVariable) {
+ argType = resolveTypeVariableInContext(
+ new ClassScope(cls, cls.getLibrary()), typeArguments.head,
+ onFailure);
+ } else {
+ argType = resolveTypeAnnotationInContext(context,
+ typeArguments.head, onFailure, whenResolved);
+ }
arguments.addLast(argType);
}
if (index < cls.typeParameters.length) {
« no previous file with comments | « lib/compiler/implementation/dart_backend/renamer.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698