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

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

Issue 15712002: Specialize the return type of a factory constructor to be the enclosing type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | tests/language/factory_return_type_checked_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3725 matching lines...) Expand 10 before | Expand all | Expand 10 after
3736 } else { 3736 } else {
3737 compiler.onDeprecatedFeature(formalParameters, 'getter parameters'); 3737 compiler.onDeprecatedFeature(formalParameters, 'getter parameters');
3738 } 3738 }
3739 } 3739 }
3740 } 3740 }
3741 LinkBuilder<Element> parametersBuilder = 3741 LinkBuilder<Element> parametersBuilder =
3742 visitor.analyzeNodes(formalParameters.nodes); 3742 visitor.analyzeNodes(formalParameters.nodes);
3743 requiredParameterCount = parametersBuilder.length; 3743 requiredParameterCount = parametersBuilder.length;
3744 parameters = parametersBuilder.toLink(); 3744 parameters = parametersBuilder.toLink();
3745 } 3745 }
3746 DartType returnType = compiler.resolveReturnType(element, returnNode); 3746 DartType returnType = element.isFactoryConstructor()
3747 ? element.getEnclosingClass().computeType(compiler)
3748 : compiler.resolveReturnType(element, returnNode);
3747 if (element.isSetter() && (requiredParameterCount != 1 || 3749 if (element.isSetter() && (requiredParameterCount != 1 ||
3748 visitor.optionalParameterCount != 0)) { 3750 visitor.optionalParameterCount != 0)) {
3749 // If there are no formal parameters, we already reported an error above. 3751 // If there are no formal parameters, we already reported an error above.
3750 if (formalParameters != null) { 3752 if (formalParameters != null) {
3751 compiler.reportErrorCode(formalParameters, 3753 compiler.reportErrorCode(formalParameters,
3752 MessageKind.ILLEGAL_SETTER_FORMALS); 3754 MessageKind.ILLEGAL_SETTER_FORMALS);
3753 } 3755 }
3754 } 3756 }
3755 if (element.isGetter() && (requiredParameterCount != 0 3757 if (element.isGetter() && (requiredParameterCount != 0
3756 || visitor.optionalParameterCount != 0)) { 3758 || visitor.optionalParameterCount != 0)) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
3926 return e; 3928 return e;
3927 } 3929 }
3928 3930
3929 /// Assumed to be called by [resolveRedirectingFactory]. 3931 /// Assumed to be called by [resolveRedirectingFactory].
3930 Element visitReturn(Return node) { 3932 Element visitReturn(Return node) {
3931 Node expression = node.expression; 3933 Node expression = node.expression;
3932 return finishConstructorReference(visit(expression), 3934 return finishConstructorReference(visit(expression),
3933 expression, expression); 3935 expression, expression);
3934 } 3936 }
3935 } 3937 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/factory_return_type_checked_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698