-
-
Notifications
You must be signed in to change notification settings - Fork 682
Open
Labels
@geraintluff
Description
Bug description
If I have two classes, with an overridden method:
class A { foo() : i32 { return 1; } } class B extends A { override foo() : i32 { return 2; } } let bAsA : A = new B(); console.log(`foo = ${bAsA.foo()}`);
This logs foo = 2 as expected, because it looks up the correct method via the object's header.
However, if you mark both classes as @unmanaged, it logs foo = 1:
@unmanaged class A {...} @unmanaged class B extends A {...}
This actual behaviour makes sense to me, since there aren't any fields in the C-style struct for the function pointers to be stored.
However, I think we should document this, and the compiler should also complain a bit when override is used in an @unmanaged class, to make it more obvious that it doesn't work.
Steps to reproduce
Run the code-examples above.
AssemblyScript version
v0.28.9