Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lualib/Descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function ____descriptorNewindex(this: any, key: string, value: any): void {

// It's also used directly in class transform to add descriptors to the prototype
function __TS__SetDescriptor(this: void, metatable: Metatable, prop: string, descriptor: PropertyDescriptor): void {
if (!metatable._descriptors) metatable._descriptors = {};
if (!rawget(metatable, "_descriptors")) metatable._descriptors = {};
metatable._descriptors[prop] = descriptor;

if (descriptor.get) metatable.__index = ____descriptorIndex;
Expand Down
20 changes: 20 additions & 0 deletions test/unit/classes/accessors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ test("get accessor override accessor", () => {
`.expectToMatchJsResult();
});

test("get accessor override accessor (multiple)", () => {
util.testFunction`
class Foo {
_foo = "foo";
get foo() { return this._foo; }
}
class Bar extends Foo {
_bar = "bar";
get foo() { return this._bar; }
}
class Baz extends Foo {
_baz = "baz";
get foo() { return this._baz; }
}
const bar = new Bar();
const baz = new Baz();
return bar.foo + baz.foo;
`.expectToMatchJsResult();
});

test("get accessor from interface", () => {
util.testFunction`
class Foo {
Expand Down