| 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 operator[](Node node); | 8 Element operator[](Node node); |
| 9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
| 10 DartType getType(Node node); | 10 DartType getType(Node node); |
| (...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2005 | 2005 |
| 2006 visitReturn(Return node) { | 2006 visitReturn(Return node) { |
| 2007 if (node.isRedirectingFactoryBody) { | 2007 if (node.isRedirectingFactoryBody) { |
| 2008 handleRedirectingFactoryBody(node); | 2008 handleRedirectingFactoryBody(node); |
| 2009 } else { | 2009 } else { |
| 2010 visit(node.expression); | 2010 visit(node.expression); |
| 2011 } | 2011 } |
| 2012 } | 2012 } |
| 2013 | 2013 |
| 2014 void handleRedirectingFactoryBody(Return node) { | 2014 void handleRedirectingFactoryBody(Return node) { |
| 2015 if (!enclosingElement.isFactoryConstructor()) { |
| 2016 compiler.reportMessage( |
| 2017 compiler.spanFromNode(node), |
| 2018 MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY.error([]), |
| 2019 Diagnostic.ERROR); |
| 2020 compiler.reportMessage( |
| 2021 compiler.spanFromElement(enclosingElement), |
| 2022 MessageKind.MISSING_FACTORY_KEYWORD.error([]), |
| 2023 Diagnostic.INFO); |
| 2024 } |
| 2015 Element redirectionTarget = resolveRedirectingFactory(node); | 2025 Element redirectionTarget = resolveRedirectingFactory(node); |
| 2016 var type = mapping.getType(node.expression); | 2026 var type = mapping.getType(node.expression); |
| 2017 if (type is InterfaceType && !type.isRaw) { | 2027 if (type is InterfaceType && !type.isRaw) { |
| 2018 unimplemented(node.expression, 'type arguments on redirecting factory'); | 2028 unimplemented(node.expression, 'type arguments on redirecting factory'); |
| 2019 } | 2029 } |
| 2020 useElement(node.expression, redirectionTarget); | 2030 useElement(node.expression, redirectionTarget); |
| 2021 assert(invariant(node, enclosingElement.isFactoryConstructor())); | |
| 2022 FunctionElement constructor = enclosingElement; | 2031 FunctionElement constructor = enclosingElement; |
| 2023 if (constructor.modifiers.isConst() && | 2032 if (constructor.modifiers.isConst() && |
| 2024 !redirectionTarget.modifiers.isConst()) { | 2033 !redirectionTarget.modifiers.isConst()) { |
| 2025 error(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); | 2034 error(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); |
| 2026 } | 2035 } |
| 2027 // TODO(ahe): Check that this doesn't lead to a cycle. For now, | 2036 // TODO(ahe): Check that this doesn't lead to a cycle. For now, |
| 2028 // just make sure that the redirection target isn't itself a | 2037 // just make sure that the redirection target isn't itself a |
| 2029 // redirecting factory. | 2038 // redirecting factory. |
| 2030 { // This entire block is temporary code per the above TODO. | 2039 { // This entire block is temporary code per the above TODO. |
| 2031 FunctionElement targetImplementation = redirectionTarget.implementation; | 2040 FunctionElement targetImplementation = redirectionTarget.implementation; |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3198 return e; | 3207 return e; |
| 3199 } | 3208 } |
| 3200 | 3209 |
| 3201 /// Assumed to be called by [resolveRedirectingFactory]. | 3210 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3202 Element visitReturn(Return node) { | 3211 Element visitReturn(Return node) { |
| 3203 Node expression = node.expression; | 3212 Node expression = node.expression; |
| 3204 return finishConstructorReference(visit(expression), | 3213 return finishConstructorReference(visit(expression), |
| 3205 expression, expression); | 3214 expression, expression); |
| 3206 } | 3215 } |
| 3207 } | 3216 } |
| OLD | NEW |