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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 16549004: Add type arguments to constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 if (!callSelector.applies(constructor, compiler)) { 2612 if (!callSelector.applies(constructor, compiler)) {
2613 warnArgumentMismatch(node.send, constructor); 2613 warnArgumentMismatch(node.send, constructor);
2614 compiler.backend.registerThrowNoSuchMethod(mapping); 2614 compiler.backend.registerThrowNoSuchMethod(mapping);
2615 } 2615 }
2616 2616
2617 // [constructor] might be the implementation element 2617 // [constructor] might be the implementation element
2618 // and only declaration elements may be registered. 2618 // and only declaration elements may be registered.
2619 world.registerStaticUse(constructor.declaration); 2619 world.registerStaticUse(constructor.declaration);
2620 ClassElement cls = constructor.getEnclosingClass(); 2620 ClassElement cls = constructor.getEnclosingClass();
2621 InterfaceType type = mapping.getType(node); 2621 InterfaceType type = mapping.getType(node);
2622 if (node.isConst() && type.containsTypeVariables) {
2623 compiler.reportErrorCode(node.send.selector,
2624 MessageKind.TYPE_VARIABLE_IN_CONSTANT);
2625 }
2622 world.registerInstantiatedType(type, mapping); 2626 world.registerInstantiatedType(type, mapping);
2623 if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) { 2627 if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) {
2624 world.registerFactoryWithTypeArguments(mapping); 2628 world.registerFactoryWithTypeArguments(mapping);
2625 } 2629 }
2626 if (cls.isAbstract(compiler)) { 2630 if (cls.isAbstract(compiler)) {
2627 compiler.backend.registerAbstractClassInstantiation(mapping); 2631 compiler.backend.registerAbstractClassInstantiation(mapping);
2628 } 2632 }
2629 2633
2630 if (isSymbolConstructor) { 2634 if (isSymbolConstructor) {
2631 if (node.isConst()) { 2635 if (node.isConst()) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 } else { 2724 } else {
2721 typeArgument = resolveTypeRequired(nodes.head); 2725 typeArgument = resolveTypeRequired(nodes.head);
2722 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { 2726 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) {
2723 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); 2727 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
2724 resolveTypeRequired(nodes.head); 2728 resolveTypeRequired(nodes.head);
2725 } 2729 }
2726 } 2730 }
2727 } 2731 }
2728 DartType listType; 2732 DartType listType;
2729 if (typeArgument != null) { 2733 if (typeArgument != null) {
2734 if (node.isConst() && typeArgument.containsTypeVariables) {
2735 compiler.reportErrorCode(arguments.nodes.head,
2736 MessageKind.TYPE_VARIABLE_IN_CONSTANT);
2737 }
2730 listType = new InterfaceType(compiler.listClass, 2738 listType = new InterfaceType(compiler.listClass,
2731 new Link<DartType>.fromList([typeArgument])); 2739 new Link<DartType>.fromList([typeArgument]));
2732 } else { 2740 } else {
2733 compiler.listClass.computeType(compiler); 2741 compiler.listClass.computeType(compiler);
2734 listType = compiler.listClass.rawType; 2742 listType = compiler.listClass.rawType;
2735 } 2743 }
2736 mapping.setType(node, listType); 2744 mapping.setType(node, listType);
2737 world.registerInstantiatedType(listType, mapping); 2745 world.registerInstantiatedType(listType, mapping);
2738 visit(node.elements); 2746 visit(node.elements);
2739 } 2747 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 } 2943 }
2936 } 2944 }
2937 DartType mapType; 2945 DartType mapType;
2938 if (valueTypeArgument != null) { 2946 if (valueTypeArgument != null) {
2939 mapType = new InterfaceType(compiler.mapClass, 2947 mapType = new InterfaceType(compiler.mapClass,
2940 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument])); 2948 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument]));
2941 } else { 2949 } else {
2942 compiler.mapClass.computeType(compiler); 2950 compiler.mapClass.computeType(compiler);
2943 mapType = compiler.mapClass.rawType; 2951 mapType = compiler.mapClass.rawType;
2944 } 2952 }
2953 if (node.isConst() && mapType.containsTypeVariables) {
2954 compiler.reportErrorCode(arguments,
2955 MessageKind.TYPE_VARIABLE_IN_CONSTANT);
2956 }
2945 mapping.setType(node, mapType); 2957 mapping.setType(node, mapType);
2946 world.registerInstantiatedClass(compiler.mapClass, mapping); 2958 world.registerInstantiatedClass(compiler.mapClass, mapping);
2947 if (node.isConst()) { 2959 if (node.isConst()) {
2948 compiler.backend.registerConstantMap(mapping); 2960 compiler.backend.registerConstantMap(mapping);
2949 } 2961 }
2950 node.visitChildren(this); 2962 node.visitChildren(this);
2951 } 2963 }
2952 2964
2953 visitLiteralMapEntry(LiteralMapEntry node) { 2965 visitLiteralMapEntry(LiteralMapEntry node) {
2954 node.visitChildren(this); 2966 node.visitChildren(this);
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
4034 return e; 4046 return e;
4035 } 4047 }
4036 4048
4037 /// Assumed to be called by [resolveRedirectingFactory]. 4049 /// Assumed to be called by [resolveRedirectingFactory].
4038 Element visitReturn(Return node) { 4050 Element visitReturn(Return node) {
4039 Node expression = node.expression; 4051 Node expression = node.expression;
4040 return finishConstructorReference(visit(expression), 4052 return finishConstructorReference(visit(expression),
4041 expression, expression); 4053 expression, expression);
4042 } 4054 }
4043 } 4055 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698