Skip to content

Generic class constructors returning raw self type #1008

@SylviBlossom

Description

@SylviBlossom

As of the recent EmmyLua update (0.22.0) on Visual Studio Code, constructing a generic class (via the constructor attribute) now occassionally returns the self type, instead of its actual type.

This seems to happen if the class's generic type is used in its constructor's parameters.

-- Generic class taking a string in its constructor

---@class ClassA<T>
local ClassA = class("ClassA")

---@param str string
function ClassA:init(str) end


-- Generic class with its generic passed to its constructor

---@class ClassB<T>
local ClassB = class("ClassB")

---@param value T
function ClassB:init(value) end


local a = ClassA("I'm ClassA") -- ClassA<T>
local b = ClassB("I'm ClassB") -- self

In this example, b should be ClassB<string> (or at least some form of ClassB).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions