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:
parent
fd2d14618d
commit
15cb9a9ce6
|
@ -544,7 +544,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
// todo: handle errors
|
||||
let (superclass_object, method) =
|
||||
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(
|
||||
activation,
|
||||
method.clone(),
|
||||
|
|
|
@ -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 function Test()
|
||||
public function instance_method()
|
||||
{
|
||||
trace("// Getting static property");
|
||||
trace("// Getting static property in instance method");
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -1,2 +1,5 @@
|
|||
// Getting static property
|
||||
static prop
|
||||
// Getting static property in subclass constructor
|
||||
static prop
|
||||
Calling super!
|
||||
// Getting static property in instance method
|
||||
static prop
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue