Skip to content

Multipe parameters infer differently? #1343

Open
@Nexela

Description

@Nexela

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions