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

Unified Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/resolution/members.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/elements/modelx.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/elements/modelx.dart (revision 27593)
+++ sdk/lib/_internal/compiler/implementation/elements/modelx.dart (working copy)
@@ -1189,28 +1189,32 @@
* exception/call.
*/
bool isCompatibleWith(FunctionSignature signature) {
- if (optionalParametersAreNamed != signature.optionalParametersAreNamed) {
- return false;
- }
if (optionalParametersAreNamed) {
+ if (!signature.optionalParametersAreNamed) {
+ return requiredParameterCount == signature.parameterCount;
+ }
+ // If both signatures have named parameters, then they must have
+ // the same number of required parameters, and the names in
+ // [signature] must all be in [:this:].
if (requiredParameterCount != signature.requiredParameterCount) {
return false;
}
+ Set<String> names = optionalParameters.toList().map(
+ (Element element) => element.name.slowToString()).toSet();
for (Element namedParameter in signature.optionalParameters) {
- if (!optionalParameters.contains(namedParameter)) {
+ if (!names.contains(namedParameter.name.slowToString())) {
return false;
}
}
} else {
+ if (signature.optionalParametersAreNamed) return false;
// There must be at least as many arguments as in the other signature, but
// this signature must not have more required parameters. Having more
// optional parameters is not a problem, they simply are never provided
// by call sites of a call to a method with the other signature.
- if (requiredParameterCount > signature.requiredParameterCount ||
- requiredParameterCount < signature.parameterCount ||
- parameterCount < signature.parameterCount) {
- return false;
- }
+ int otherTotalCount = signature.parameterCount;
+ return requiredParameterCount <= otherTotalCount
+ && parameterCount >= otherTotalCount;
}
return true;
}
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/resolution/members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698