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).
As of the recent EmmyLua update (0.22.0) on Visual Studio Code, constructing a generic class (via the
constructorattribute) now occassionally returns theselftype, instead of its actual type.This seems to happen if the class's generic type is used in its constructor's parameters.
In this example,
bshould beClassB<string>(or at least some form ofClassB).