Method calls on `super` objects should substitute the child object instead of itself as `this`.

This commit is contained in:
David Wendt 2020-04-13 17:37:54 -04:00
parent 869cbd17da
commit e76ba4de87
1 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,7 @@
//! Special object that implements `super` //! Special object that implements `super`
use crate::avm1::function::Executable; use crate::avm1::function::Executable;
use crate::avm1::object::search_prototype;
use crate::avm1::property::Attribute; use crate::avm1::property::Attribute;
use crate::avm1::return_value::ReturnValue; use crate::avm1::return_value::ReturnValue;
use crate::avm1::script_object::TYPE_OF_OBJECT; use crate::avm1::script_object::TYPE_OF_OBJECT;
@ -110,6 +111,26 @@ impl<'gc> TObject<'gc> for SuperObject<'gc> {
} }
} }
fn call_method(
&self,
name: &str,
args: &[Value<'gc>],
avm: &mut Avm1<'gc>,
context: &mut UpdateContext<'_, 'gc, '_>,
) -> Result<ReturnValue<'gc>, Error> {
let child = self.0.read().child;
let super_proto = self.0.read().super_proto;
let (method, base_proto) = search_prototype(super_proto, name, avm, context, child)?;
let method = method.resolve(avm, context)?;
if let Value::Object(_) = method {
} else {
log::warn!("Super method {} is not callable", name);
}
method.call(avm, context, child, base_proto, args)
}
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
fn new( fn new(
&self, &self,