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

Unified Diff: runtime/vm/object.cc

Issue 12940010: Update function subtyping rules to latest spec (issue 9057). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | tests/co19/co19-compiler.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 20492)
+++ runtime/vm/object.cc (working copy)
@@ -3901,8 +3901,11 @@
const intptr_t num_ignored_params =
(other.IsRedirectingFactory() && IsConstructor()) ? 1 : 0;
// The default values of optional parameters can differ.
- if (((num_fixed_params - num_ignored_params) != other_num_fixed_params) ||
- (num_opt_pos_params < other_num_opt_pos_params) ||
+ // This function requires the same arguments or less and accepts the same
+ // arguments or more.
+ if (((num_fixed_params - num_ignored_params) > other_num_fixed_params) ||
+ ((num_fixed_params - num_ignored_params) + num_opt_pos_params <
+ other_num_fixed_params + other_num_opt_pos_params) ||
(num_opt_named_params < other_num_opt_named_params)) {
return false;
}
@@ -3999,8 +4002,11 @@
other.NumOptionalPositionalParameters();
const intptr_t other_num_opt_named_params =
other.NumOptionalNamedParameters();
- if ((num_fixed_params != other_num_fixed_params) ||
- (num_opt_pos_params < other_num_opt_pos_params) ||
+ // This function requires the same arguments or less and accepts the same
+ // arguments or more.
+ if ((num_fixed_params > other_num_fixed_params) ||
+ (num_fixed_params + num_opt_pos_params <
+ other_num_fixed_params + other_num_opt_pos_params) ||
(num_opt_named_params < other_num_opt_named_params)) {
return false;
}
@@ -4033,7 +4039,8 @@
}
}
// Check the types of fixed and optional positional parameters.
- for (intptr_t i = 0; i < num_fixed_params + other_num_opt_pos_params; i++) {
+ for (intptr_t i = 0;
+ i < other_num_fixed_params + other_num_opt_pos_params; i++) {
if (!TestParameterType(test_kind,
i, i, type_arguments, other, other_type_arguments,
malformed_error)) {
« no previous file with comments | « no previous file | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698