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

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

Issue 24153008: Check if signatures are compatible in a redirecting factory before synthesizing a call in the infer… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
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 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 return; 2646 return;
2647 } 2647 }
2648 2648
2649 // Check that the target constructor is type compatible with the 2649 // Check that the target constructor is type compatible with the
2650 // redirecting constructor. 2650 // redirecting constructor.
2651 ClassElement targetClass = redirectionTarget.getEnclosingClass(); 2651 ClassElement targetClass = redirectionTarget.getEnclosingClass();
2652 InterfaceType type = mapping.getType(node.expression); 2652 InterfaceType type = mapping.getType(node.expression);
2653 FunctionType targetType = redirectionTarget.computeType(compiler) 2653 FunctionType targetType = redirectionTarget.computeType(compiler)
2654 .subst(type.typeArguments, targetClass.typeVariables); 2654 .subst(type.typeArguments, targetClass.typeVariables);
2655 FunctionType constructorType = constructor.computeType(compiler); 2655 FunctionType constructorType = constructor.computeType(compiler);
2656 if (!compiler.types.isSubtype(targetType, constructorType)) { 2656 bool isSubtype = compiler.types.isSubtype(targetType, constructorType);
2657 if (!isSubtype) {
2657 warning(node, MessageKind.NOT_ASSIGNABLE.warning, 2658 warning(node, MessageKind.NOT_ASSIGNABLE.warning,
2658 {'fromType': targetType, 'toType': constructorType}); 2659 {'fromType': targetType, 'toType': constructorType});
2659 } 2660 }
2660 2661
2661 FunctionSignature targetSignature = 2662 FunctionSignature targetSignature =
2662 redirectionTarget.computeSignature(compiler); 2663 redirectionTarget.computeSignature(compiler);
2663 FunctionSignature constructorSignature = 2664 FunctionSignature constructorSignature =
2664 constructor.computeSignature(compiler); 2665 constructor.computeSignature(compiler);
2665 if (!targetSignature.isCompatibleWith(constructorSignature)) { 2666 if (!targetSignature.isCompatibleWith(constructorSignature)) {
2667 assert(!isSubtype);
2666 compiler.backend.registerThrowNoSuchMethod(mapping); 2668 compiler.backend.registerThrowNoSuchMethod(mapping);
2667 } 2669 }
2668 2670
2669 // TODO(ahe): Check that this doesn't lead to a cycle. For now, 2671 // TODO(ahe): Check that this doesn't lead to a cycle. For now,
2670 // just make sure that the redirection target isn't itself a 2672 // just make sure that the redirection target isn't itself a
2671 // redirecting factory. 2673 // redirecting factory.
2672 { // This entire block is temporary code per the above TODO. 2674 { // This entire block is temporary code per the above TODO.
2673 FunctionElement targetImplementation = redirectionTarget.implementation; 2675 FunctionElement targetImplementation = redirectionTarget.implementation;
2674 FunctionExpression function = targetImplementation.parseNode(compiler); 2676 FunctionExpression function = targetImplementation.parseNode(compiler);
2675 if (function != null 2677 if (function != null
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
4223 return e; 4225 return e;
4224 } 4226 }
4225 4227
4226 /// Assumed to be called by [resolveRedirectingFactory]. 4228 /// Assumed to be called by [resolveRedirectingFactory].
4227 Element visitReturn(Return node) { 4229 Element visitReturn(Return node) {
4228 Node expression = node.expression; 4230 Node expression = node.expression;
4229 return finishConstructorReference(visit(expression), 4231 return finishConstructorReference(visit(expression),
4230 expression, expression); 4232 expression, expression);
4231 } 4233 }
4232 } 4234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698