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

Unified Diff: runtime/vm/object.cc

Issue 18652002: Revert "Relax method override restrictions." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/corelib/corelib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 765748070de34a5561d6d8377753898ef18a8596..913ff45d25fb989ad9917f92d6d7ac60f37d91fc 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -4100,9 +4100,12 @@ const char* Function::ToFullyQualifiedCString() const {
bool Function::HasCompatibleParametersWith(const Function& other) const {
const intptr_t num_fixed_params = num_fixed_parameters();
const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
+ const intptr_t num_opt_named_params = NumOptionalNamedParameters();
const intptr_t other_num_fixed_params = other.num_fixed_parameters();
const intptr_t other_num_opt_pos_params =
other.NumOptionalPositionalParameters();
+ const intptr_t other_num_opt_named_params =
+ other.NumOptionalNamedParameters();
// A generative constructor may be compared to a redirecting factory and be
// compatible although it has an additional phase parameter.
const intptr_t num_ignored_params =
@@ -4112,9 +4115,36 @@ bool Function::HasCompatibleParametersWith(const Function& other) const {
// 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)) {
+ other_num_fixed_params + other_num_opt_pos_params) ||
+ (num_opt_named_params < other_num_opt_named_params)) {
return false;
}
+ if (other_num_opt_named_params == 0) {
+ return true;
+ }
+ // Check that for each optional named parameter of the other function there
+ // exists an optional named parameter of this function with an identical
+ // name.
+ // Note that SetParameterNameAt() guarantees that names are symbols, so we
+ // can compare their raw pointers.
+ const int num_params = num_fixed_params + num_opt_named_params;
+ const int other_num_params =
+ other_num_fixed_params + other_num_opt_named_params;
+ bool found_param_name;
+ String& other_param_name = String::Handle();
+ for (intptr_t i = other_num_fixed_params; i < other_num_params; i++) {
+ other_param_name = other.ParameterNameAt(i);
+ found_param_name = false;
+ for (intptr_t j = num_fixed_params; j < num_params; j++) {
+ if (ParameterNameAt(j) == other_param_name.raw()) {
+ found_param_name = true;
+ break;
+ }
+ }
+ if (!found_param_name) {
+ return false;
+ }
+ }
return true;
}
« no previous file with comments | « no previous file | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698