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