| 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 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 resolvedSuper = true; | 1236 resolvedSuper = true; |
| 1237 } else if (Initializers.isConstructorRedirect(call)) { | 1237 } else if (Initializers.isConstructorRedirect(call)) { |
| 1238 // Check that there is no body (Language specification 7.5.1). | 1238 // Check that there is no body (Language specification 7.5.1). |
| 1239 if (functionNode.hasBody()) { | 1239 if (functionNode.hasBody()) { |
| 1240 error(functionNode, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_BODY); | 1240 error(functionNode, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_BODY); |
| 1241 } | 1241 } |
| 1242 // Check that there are no other initializers. | 1242 // Check that there are no other initializers. |
| 1243 if (!initializers.tail.isEmpty) { | 1243 if (!initializers.tail.isEmpty) { |
| 1244 error(call, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER); | 1244 error(call, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER); |
| 1245 } | 1245 } |
| 1246 // Check that there are no field initializing parameters. |
| 1247 Compiler compiler = visitor.compiler; |
| 1248 FunctionSignature signature = constructor.computeSignature(compiler); |
| 1249 signature.forEachParameter((Element parameter) { |
| 1250 if (parameter.isFieldParameter()) { |
| 1251 Node node = parameter.parseNode(compiler); |
| 1252 error(node, MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED); |
| 1253 } |
| 1254 }); |
| 1246 return resolveSuperOrThisForSend(constructor, functionNode, call); | 1255 return resolveSuperOrThisForSend(constructor, functionNode, call); |
| 1247 } else { | 1256 } else { |
| 1248 visitor.error(call, MessageKind.CONSTRUCTOR_CALL_EXPECTED); | 1257 visitor.error(call, MessageKind.CONSTRUCTOR_CALL_EXPECTED); |
| 1249 return null; | 1258 return null; |
| 1250 } | 1259 } |
| 1251 } else { | 1260 } else { |
| 1252 error(link.head, MessageKind.INVALID_INITIALIZER); | 1261 error(link.head, MessageKind.INVALID_INITIALIZER); |
| 1253 } | 1262 } |
| 1254 } | 1263 } |
| 1255 if (!resolvedSuper) { | 1264 if (!resolvedSuper) { |
| (...skipping 2500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3756 | 3765 |
| 3757 // The only valid [Send] can be in constructors and must be of the form | 3766 // The only valid [Send] can be in constructors and must be of the form |
| 3758 // [:this.x:] (where [:x:] represents an instance field). | 3767 // [:this.x:] (where [:x:] represents an instance field). |
| 3759 FieldParameterElement visitSend(Send node) { | 3768 FieldParameterElement visitSend(Send node) { |
| 3760 FieldParameterElement element; | 3769 FieldParameterElement element; |
| 3761 if (node.receiver.asIdentifier() == null || | 3770 if (node.receiver.asIdentifier() == null || |
| 3762 !node.receiver.asIdentifier().isThis()) { | 3771 !node.receiver.asIdentifier().isThis()) { |
| 3763 error(node, MessageKind.INVALID_PARAMETER); | 3772 error(node, MessageKind.INVALID_PARAMETER); |
| 3764 } else if (!identical(enclosingElement.kind, | 3773 } else if (!identical(enclosingElement.kind, |
| 3765 ElementKind.GENERATIVE_CONSTRUCTOR)) { | 3774 ElementKind.GENERATIVE_CONSTRUCTOR)) { |
| 3766 error(node, MessageKind.FIELD_PARAMETER_NOT_ALLOWED); | 3775 error(node, MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED); |
| 3767 } else { | 3776 } else { |
| 3768 SourceString name = getParameterName(node); | 3777 SourceString name = getParameterName(node); |
| 3769 Element fieldElement = currentClass.lookupLocalMember(name); | 3778 Element fieldElement = currentClass.lookupLocalMember(name); |
| 3770 if (fieldElement == null || | 3779 if (fieldElement == null || |
| 3771 !identical(fieldElement.kind, ElementKind.FIELD)) { | 3780 !identical(fieldElement.kind, ElementKind.FIELD)) { |
| 3772 error(node, MessageKind.NOT_A_FIELD, {'fieldName': name}); | 3781 error(node, MessageKind.NOT_A_FIELD, {'fieldName': name}); |
| 3773 } else if (!fieldElement.isInstanceMember()) { | 3782 } else if (!fieldElement.isInstanceMember()) { |
| 3774 error(node, MessageKind.NOT_INSTANCE_FIELD, {'fieldName': name}); | 3783 error(node, MessageKind.NOT_INSTANCE_FIELD, {'fieldName': name}); |
| 3775 } | 3784 } |
| 3776 Element variables = new VariableListElementX.node(currentDefinitions, | 3785 Element variables = new VariableListElementX.node(currentDefinitions, |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4052 return e; | 4061 return e; |
| 4053 } | 4062 } |
| 4054 | 4063 |
| 4055 /// Assumed to be called by [resolveRedirectingFactory]. | 4064 /// Assumed to be called by [resolveRedirectingFactory]. |
| 4056 Element visitReturn(Return node) { | 4065 Element visitReturn(Return node) { |
| 4057 Node expression = node.expression; | 4066 Node expression = node.expression; |
| 4058 return finishConstructorReference(visit(expression), | 4067 return finishConstructorReference(visit(expression), |
| 4059 expression, expression); | 4068 expression, expression); |
| 4060 } | 4069 } |
| 4061 } | 4070 } |
| OLD | NEW |