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

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

Issue 10826045: Substitution handled for most Send nodes. (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/elements/elements.dart ('k') | lib/compiler/implementation/ssa/codegen.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 771c5dc12db4721d708bbf8cec6c9cdc9d12e5e9..e6f318669266e92f4079050283c060538e33ecf9 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1357,23 +1357,13 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
return null;
}
- TypeAnnotation getTypeAnnotationFromSend(Send send) {
- if (send.selector.asTypeAnnotation() !== null) {
- return send.selector;
- } else if (send.selector.asSend() !== null) {
- Send selector = send.selector;
- if (selector.receiver.asTypeAnnotation() !== null) {
- return selector.receiver;
- }
- } else {
- compiler.internalError("malformed send in new expression");
- }
- }
-
FunctionElement resolveConstructor(NewExpression node) {
FunctionElement constructor =
node.accept(new ConstructorResolver(compiler, this));
- TypeAnnotation annotation = getTypeAnnotationFromSend(node.send);
+ TypeAnnotation annotation = node.getTypeAnnotation();
+ if (annotation == null) {
+ compiler.internalError("malformed send in new expression");
+ }
Type type = resolveTypeRequired(annotation);
if (constructor === null) {
Element resolved = (type != null) ? type.element : null;
@@ -1384,6 +1374,8 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
error(node.send, MessageKind.CANNOT_FIND_CONSTRUCTOR, [node.send]);
return null;
}
+ } else {
+ useType(annotation, type);
}
return constructor;
}
@@ -1729,13 +1721,20 @@ class ClassResolverVisitor extends CommonResolverVisitor<Type> {
// TODO(johnniwinther): Handle function types.
return type;
}
+ int typeParameterCount = type.element.typeParameters.length;
if (node.typeArguments === null) {
- if (type.arguments.isEmpty()) {
+ if (type.typeArguments.isEmpty() || typeParameterCount == 0) {
return type;
}
// Return the 'raw' version, for example List for List<E>.
return new InterfaceType(type.element);
}
+ int typeArgumentCount = node.typeArguments.length();
+ if (typeArgumentCount < typeParameterCount) {
+ error(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT);
+ } else if (typeArgumentCount > typeParameterCount) {
+ error(node.typeArguments, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
+ }
var typeArguments = new LinkBuilder<Type>();
var link = node.typeArguments.nodes;
while (!link.isEmpty()) {
@@ -1796,9 +1795,9 @@ class ClassResolverVisitor extends CommonResolverVisitor<Type> {
return e.computeType(compiler);
}
- Link<Type> getOrCalculateAllSupertypes(ClassElement cls,
- [Set<ClassElement> seen]) {
- Link<Type> allSupertypes = cls.allSupertypes;
+ Link<InterfaceType> getOrCalculateAllSupertypes(ClassElement cls,
+ [Set<ClassElement> seen]) {
+ Link<InterfaceType> allSupertypes = cls.allSupertypes;
if (allSupertypes !== null) return allSupertypes;
if (seen === null) {
seen = new Set<ClassElement>();
@@ -1807,7 +1806,7 @@ class ClassResolverVisitor extends CommonResolverVisitor<Type> {
error(cls.parseNode(compiler),
MessageKind.CYCLIC_CLASS_HIERARCHY,
[cls.name]);
- cls.allSupertypes = const EmptyLink<Type>();
+ cls.allSupertypes = const EmptyLink<InterfaceType>();
} else {
cls.ensureResolved(compiler);
calculateAllSupertypes(cls, seen);
@@ -1824,32 +1823,27 @@ class ClassResolverVisitor extends CommonResolverVisitor<Type> {
error(cls.parseNode(compiler),
MessageKind.CYCLIC_CLASS_HIERARCHY,
[cls.name]);
- cls.allSupertypes = const EmptyLink<Type>();
+ cls.allSupertypes = const EmptyLink<InterfaceType>();
} else if (supertype != null) {
seen.add(cls);
ClassElement supertypeElement = supertype.element;
- Link<Type> superSupertypes =
+ Link<InterfaceType> superSupertypes =
getOrCalculateAllSupertypes(supertypeElement, seen);
- var superTypesBuilder = new LinkBuilder<Type>();
+ var superTypesBuilder = new LinkBuilder<InterfaceType>();
superTypesBuilder.addLast(supertype);
// Substitute type variables in supertypes.
- var superTypeParameters = <Type>[];
- var typeVariableElements = supertypeElement.typeParameters.getValues();
- for (TypeVariableElement typeVariableElement in typeVariableElements) {
- superTypeParameters.add(typeVariableElement.type);
- }
for (Type superSupertype in superSupertypes) {
- superTypesBuilder.addLast(superSupertype.subst(
- supertype.arguments, superTypeParameters));
+ superTypesBuilder.addLast(superSupertype.subst(compiler,
+ supertype.typeArguments, supertypeElement.typeParameters));
}
- Link<Type> supertypes = superTypesBuilder.toLink();
- for (Link<Type> interfaces = cls.interfaces;
+ Link<InterfaceType> supertypes = superTypesBuilder.toLink();
+ for (Link<InterfaceType> interfaces = cls.interfaces;
!interfaces.isEmpty();
interfaces = interfaces.tail) {
Element element = interfaces.head.element;
- Link<Type> interfaceSupertypes =
+ Link<InterfaceType> interfaceSupertypes =
getOrCalculateAllSupertypes(element, seen);
supertypes = supertypes.reversePrependAll(interfaceSupertypes);
supertypes = supertypes.prepend(interfaces.head);
@@ -1857,7 +1851,7 @@ class ClassResolverVisitor extends CommonResolverVisitor<Type> {
seen.remove(cls);
cls.allSupertypes = supertypes;
} else {
- cls.allSupertypes = const EmptyLink<Type>();
+ cls.allSupertypes = const EmptyLink<InterfaceType>();
}
}
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698