lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Multipe parameters infer differently?

Open Nexela opened this issue 3 years ago • 1 comments

Infers a and aa correctly but not the rest

---@diagnostic disable: codestyle-check, spell-check, unused-local

---@alias AnyChild A|B|C
---@class PARENT
local PARENT = {}
---@class A: PARENT
local A = {}
---@class B: PARENT
local B = {}
---@class C: PARENT
local C = {}

---@overload fun(self:PARENT): A
---@overload fun(self:AnyChild, other: A): A
---@overload fun(self:AnyChild, other: B): B
function PARENT:new(other)
  self.a = 2
  return {}
end

local a = A:new()
local aa = a:new()

local aaa = a:new(B)
local b = B:new(B)
local bb = b:new(B)
local bbb = b:new(C)

image

Nexela avatar Jul 18 '22 02:07 Nexela

Overloading functions based on parameter types is not yet supported.

sumneko avatar Jul 18 '22 07:07 sumneko