Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipe parameters infer differently? #1343

Open
Nexela opened this issue Jul 18, 2022 · 1 comment
Open

Multipe parameters infer differently? #1343

Nexela opened this issue Jul 18, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Nexela
Copy link
Contributor

Nexela commented Jul 18, 2022

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

@sumneko sumneko added the enhancement New feature or request label Jul 18, 2022
@sumneko
Copy link
Collaborator

sumneko commented Jul 18, 2022

Overloading functions based on parameter types is not yet supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants