| OLD | NEW |
| 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 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2613 if (!callSelector.applies(constructor, compiler)) { | 2613 if (!callSelector.applies(constructor, compiler)) { |
| 2614 warnArgumentMismatch(node.send, constructor); | 2614 warnArgumentMismatch(node.send, constructor); |
| 2615 compiler.backend.registerThrowNoSuchMethod(mapping); | 2615 compiler.backend.registerThrowNoSuchMethod(mapping); |
| 2616 } | 2616 } |
| 2617 | 2617 |
| 2618 // [constructor] might be the implementation element | 2618 // [constructor] might be the implementation element |
| 2619 // and only declaration elements may be registered. | 2619 // and only declaration elements may be registered. |
| 2620 world.registerStaticUse(constructor.declaration); | 2620 world.registerStaticUse(constructor.declaration); |
| 2621 ClassElement cls = constructor.getEnclosingClass(); | 2621 ClassElement cls = constructor.getEnclosingClass(); |
| 2622 InterfaceType type = mapping.getType(node); | 2622 InterfaceType type = mapping.getType(node); |
| 2623 if (node.isConst() && type.containsTypeVariables) { |
| 2624 compiler.reportErrorCode(node.send.selector, |
| 2625 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 2626 } |
| 2623 world.registerInstantiatedType(type, mapping); | 2627 world.registerInstantiatedType(type, mapping); |
| 2624 if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) { | 2628 if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) { |
| 2625 world.registerFactoryWithTypeArguments(mapping); | 2629 world.registerFactoryWithTypeArguments(mapping); |
| 2626 } | 2630 } |
| 2627 if (cls.isAbstract(compiler)) { | 2631 if (cls.isAbstract(compiler)) { |
| 2628 compiler.backend.registerAbstractClassInstantiation(mapping); | 2632 compiler.backend.registerAbstractClassInstantiation(mapping); |
| 2629 } | 2633 } |
| 2630 | 2634 |
| 2631 if (isSymbolConstructor) { | 2635 if (isSymbolConstructor) { |
| 2632 if (node.isConst()) { | 2636 if (node.isConst()) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2721 } else { | 2725 } else { |
| 2722 typeArgument = resolveTypeRequired(nodes.head); | 2726 typeArgument = resolveTypeRequired(nodes.head); |
| 2723 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { | 2727 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { |
| 2724 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 2728 error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 2725 resolveTypeRequired(nodes.head); | 2729 resolveTypeRequired(nodes.head); |
| 2726 } | 2730 } |
| 2727 } | 2731 } |
| 2728 } | 2732 } |
| 2729 DartType listType; | 2733 DartType listType; |
| 2730 if (typeArgument != null) { | 2734 if (typeArgument != null) { |
| 2735 if (node.isConst() && typeArgument.containsTypeVariables) { |
| 2736 compiler.reportErrorCode(arguments.nodes.head, |
| 2737 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 2738 } |
| 2731 listType = new InterfaceType(compiler.listClass, | 2739 listType = new InterfaceType(compiler.listClass, |
| 2732 new Link<DartType>.fromList([typeArgument])); | 2740 new Link<DartType>.fromList([typeArgument])); |
| 2733 } else { | 2741 } else { |
| 2734 compiler.listClass.computeType(compiler); | 2742 compiler.listClass.computeType(compiler); |
| 2735 listType = compiler.listClass.rawType; | 2743 listType = compiler.listClass.rawType; |
| 2736 } | 2744 } |
| 2737 mapping.setType(node, listType); | 2745 mapping.setType(node, listType); |
| 2738 world.registerInstantiatedType(listType, mapping); | 2746 world.registerInstantiatedType(listType, mapping); |
| 2739 visit(node.elements); | 2747 visit(node.elements); |
| 2740 } | 2748 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 } | 2944 } |
| 2937 } | 2945 } |
| 2938 DartType mapType; | 2946 DartType mapType; |
| 2939 if (valueTypeArgument != null) { | 2947 if (valueTypeArgument != null) { |
| 2940 mapType = new InterfaceType(compiler.mapClass, | 2948 mapType = new InterfaceType(compiler.mapClass, |
| 2941 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument])); | 2949 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument])); |
| 2942 } else { | 2950 } else { |
| 2943 compiler.mapClass.computeType(compiler); | 2951 compiler.mapClass.computeType(compiler); |
| 2944 mapType = compiler.mapClass.rawType; | 2952 mapType = compiler.mapClass.rawType; |
| 2945 } | 2953 } |
| 2954 if (node.isConst() && mapType.containsTypeVariables) { |
| 2955 compiler.reportErrorCode(arguments, |
| 2956 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 2957 } |
| 2946 mapping.setType(node, mapType); | 2958 mapping.setType(node, mapType); |
| 2947 world.registerInstantiatedClass(compiler.mapClass, mapping); | 2959 world.registerInstantiatedClass(compiler.mapClass, mapping); |
| 2948 if (node.isConst()) { | 2960 if (node.isConst()) { |
| 2949 compiler.backend.registerConstantMap(mapping); | 2961 compiler.backend.registerConstantMap(mapping); |
| 2950 } | 2962 } |
| 2951 node.visitChildren(this); | 2963 node.visitChildren(this); |
| 2952 } | 2964 } |
| 2953 | 2965 |
| 2954 visitLiteralMapEntry(LiteralMapEntry node) { | 2966 visitLiteralMapEntry(LiteralMapEntry node) { |
| 2955 node.visitChildren(this); | 2967 node.visitChildren(this); |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4035 return e; | 4047 return e; |
| 4036 } | 4048 } |
| 4037 | 4049 |
| 4038 /// Assumed to be called by [resolveRedirectingFactory]. | 4050 /// Assumed to be called by [resolveRedirectingFactory]. |
| 4039 Element visitReturn(Return node) { | 4051 Element visitReturn(Return node) { |
| 4040 Node expression = node.expression; | 4052 Node expression = node.expression; |
| 4041 return finishConstructorReference(visit(expression), | 4053 return finishConstructorReference(visit(expression), |
| 4042 expression, expression); | 4054 expression, expression); |
| 4043 } | 4055 } |
| 4044 } | 4056 } |
| OLD | NEW |