[VM / Runtime] Remove Class::ApplyPatch which is dead code now.
All application of patches is now done in the front end there
are no callers to Class::ApplyPatch, deleting it.
Change-Id: I84857ea49463faea8df6ce1ce88c0f704a893e65
Reviewed-on: https://dart-review.googlesource.com/c/88426
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 906ea2e..3882361 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3209,116 +3209,6 @@
StorePointer(&raw_ptr()->dependent_code_, array.raw());
}
-// Apply the members from the patch class to the original class.
-bool Class::ApplyPatch(const Class& patch, Error* error) const {
- ASSERT(error != NULL);
- ASSERT(!is_finalized());
- // Shared handles used during the iteration.
- String& member_name = String::Handle();
-
- const PatchClass& patch_class = PatchClass::Handle(
- PatchClass::New(*this, Script::Handle(patch.script())));
-
- Array& orig_list = Array::Handle(functions());
- intptr_t orig_len = orig_list.Length();
- Array& patch_list = Array::Handle(patch.functions());
- intptr_t patch_len = patch_list.Length();
-
- Function& func = Function::Handle();
- Function& orig_func = Function::Handle();
- // Lookup the original implicit constructor, if any.
- member_name = Name();
- member_name = String::Concat(member_name, Symbols::Dot());
- Function& orig_implicit_ctor = Function::Handle(LookupFunction(member_name));
- if (!orig_implicit_ctor.IsNull() &&
- !orig_implicit_ctor.IsImplicitConstructor()) {
- // Not an implicit constructor, but a user declared one.
- orig_implicit_ctor = Function::null();
- }
- const GrowableObjectArray& new_functions =
- GrowableObjectArray::Handle(GrowableObjectArray::New(orig_len));
- for (intptr_t i = 0; i < orig_len; i++) {
- orig_func ^= orig_list.At(i);
- member_name ^= orig_func.name();
- func = patch.LookupFunction(member_name);
- if (func.IsNull()) {
- // Non-patched function is preserved, all patched functions are added in
- // the loop below.
- // However, an implicitly created constructor should not be preserved if
- // the patch provides a constructor or a factory. Wait for now.
- if (orig_func.raw() != orig_implicit_ctor.raw()) {
- new_functions.Add(orig_func);
- }
- } else if (func.UserVisibleSignature() !=
- orig_func.UserVisibleSignature()) {
- // Compare user visible signatures to ignore different implicit parameters
- // when patching a constructor with a factory.
- *error = LanguageError::NewFormatted(
- *error, // No previous error.
- Script::Handle(patch.script()), func.token_pos(), Report::AtLocation,
- Report::kError, Heap::kNew, "signature mismatch: '%s'",
- member_name.ToCString());
- return false;
- }
- }
- for (intptr_t i = 0; i < patch_len; i++) {
- func ^= patch_list.At(i);
- if (func.IsGenerativeConstructor() || func.IsFactory()) {
- // Do not preserve the original implicit constructor, if any.
- orig_implicit_ctor = Function::null();
- }
- func.set_owner(patch_class);
- new_functions.Add(func);
- }
- if (!orig_implicit_ctor.IsNull()) {
- // Preserve the original implicit constructor.
- new_functions.Add(orig_implicit_ctor);
- }
- Array& new_list = Array::Handle(Array::MakeFixedLength(new_functions));
- SetFunctions(new_list);
-
- // Merge the two list of fields. Raise an error when duplicates are found or
- // when a public field is being added.
- orig_list = fields();
- orig_len = orig_list.Length();
- patch_list = patch.fields();
- patch_len = patch_list.Length();
-
- Field& field = Field::Handle();
- Field& orig_field = Field::Handle();
- new_list = Array::New(patch_len + orig_len);
- for (intptr_t i = 0; i < patch_len; i++) {
- field ^= patch_list.At(i);
- field.set_owner(patch_class);
- member_name = field.name();
- // TODO(iposva): Verify non-public fields only.
-
- // Verify no duplicate additions.
- orig_field ^= LookupField(member_name);
- if (!orig_field.IsNull()) {
- *error = LanguageError::NewFormatted(
- *error, // No previous error.
- Script::Handle(patch.script()), field.token_pos(), Report::AtLocation,
- Report::kError, Heap::kNew, "duplicate field: %s",
- member_name.ToCString());
- return false;
- }
- new_list.SetAt(i, field);
- }
- for (intptr_t i = 0; i < orig_len; i++) {
- field ^= orig_list.At(i);
- new_list.SetAt(patch_len + i, field);
- }
- SetFields(new_list);
-
- // The functions and fields in the patch class are no longer needed.
- // The patch class itself is also no longer needed.
- patch.SetFunctions(Object::empty_array());
- patch.SetFields(Object::empty_array());
- Library::Handle(patch.library()).RemovePatchClass(patch);
- return true;
-}
-
// Conventions:
// * For throwing a NSM in a class klass we use its runtime type as receiver,
// i.e., klass.RareType().
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index b3b6831..66dd582 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1206,10 +1206,6 @@
void Finalize() const;
- // Apply given patch class to this class.
- // Return true on success, or false and error otherwise.
- bool ApplyPatch(const Class& patch, Error* error) const;
-
RawObject* Invoke(const String& selector,
const Array& arguments,
const Array& argument_names,