You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generic class constructors returning raw self type #1008
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---@classClassA<T>localClassA=class("ClassA")
---@paramstrstringfunctionClassA:init(str) end-- Generic class with its generic passed to its constructor---@classClassB<T>localClassB=class("ClassB")
---@paramvalueTfunctionClassB:init(value) endlocala=ClassA("I'm ClassA") -- ClassA<T>localb=ClassB("I'm ClassB") -- self
In this example, b should be ClassB<string> (or at least some form of ClassB).
---@genericT---@[constructor("init")]---@paramclass`T`---@returnTfunctionclass(class) return {} end-- Generic class taking a string in its constructor---@classClassA<T>localClassA=class("ClassA")
---@paramstrstringfunctionClassA:init(str) end-- Generic class with its generic passed to its constructor---@classClassB<T>localClassB=class("ClassB")
---@paramvalueTfunctionClassB:init(value) endlocala=ClassA("I'm ClassA") -- ClassA<T>localb=ClassB("I'm ClassB") -- self
Activity
xuhuanzy commentedon Apr 3, 2026
Minimal Complete Reproducible Code
SylviBlossom commentedon Apr 3, 2026
Sorry, forgot to add the meta function
fix: EmmyLuaLs#1008
xuhuanzy commentedon Apr 5, 2026
#1017 Changed the
constructorparameters. It now prioritizes a defined@return, and falls back toselfonly when none is provided.