Use `instance_scope` when making `super` method call

A method called with `super` is always an instance method,
so we should be using `instance_scope` for consistency with
`call_property`. This fixes a bug where a method cannot
access static class members (via `getlex`) when called bia
`super.method()`
This commit is contained in:
Aaron Hill 2022-05-24 17:53:51 -04:00 committed by kmeisthax
parent fd2d14618d
commit 15cb9a9ce6
4 changed files with 32 additions and 9 deletions

View File

@ -544,7 +544,7 @@ impl<'gc> ClassObject<'gc> {
// todo: handle errors // todo: handle errors
let (superclass_object, method) = let (superclass_object, method) =
self.instance_vtable().get_full_method(disp_id).unwrap(); self.instance_vtable().get_full_method(disp_id).unwrap();
let scope = superclass_object.unwrap().class_scope(); let scope = superclass_object.unwrap().instance_scope();
let callee = FunctionObject::from_method( let callee = FunctionObject::from_method(
activation, activation,
method.clone(), method.clone(),

View File

@ -1,14 +1,34 @@
package package
{ {
public class Test public class Test {
public function Test() {
new Subclass();
}
}
}
class BaseClass
{ {
public static var t = "static prop"; public static var t = "static prop";
public function Test() public function instance_method()
{ {
trace("// Getting static property"); trace("// Getting static property in instance method");
trace(t); trace(t);
} }
} }
class Subclass extends BaseClass
{
public function Subclass()
{
trace("// Getting static property in subclass constructor");
trace(t);
instance_method();
}
public override function instance_method() {
trace("Calling super!");
super.instance_method();
}
} }

View File

@ -1,2 +1,5 @@
// Getting static property // Getting static property in subclass constructor
static prop
Calling super!
// Getting static property in instance method
static prop static prop