Skip to content

Incorrect transform this arg for optional super method call #1585

@pilaoda

Description

@pilaoda

playground:
https://typescripttolua.github.io/play/#code/FAYwNghgzlAEAKEBOBTAdgF1gb2LfsAsgIwAUAlDgL54GEBMA-BdcDaJDLAMIAWAlmAAmsFAA8M6IXESpMOWvhItcBNbCgBXAA4okAOmXlFsGmoYqTarboMNG+iiZpUgA

key input:

class Child extends Parent {
    M2() {
        super.M2?.()
    }
}

incorrect output (this become Parent.prototype, it should be self)

function Child.prototype.M2(self)
    local ____this_1
    ____this_1 = Parent.prototype
    local ____opt_0 = ____this_1.M2
    if ____opt_0 ~= nil then
        ____opt_0(____this_1)
    end
end

expected output

function Child.prototype.M2(self)
    local ____opt_0 = Parent.prototype.M2
    if ____opt_0 ~= nil then
        ____opt_0(self)
    end
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions