summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-31 11:26:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-31 11:26:51 +0800
commit41ed018e80df12b59cdd0e60cce7484b0c972d81 (patch)
tree53926994aac1bdd07597fd2683606714072954e9 /test
parent51a43979dc277e1a4418725cd001b5520d84588d (diff)
downloadlua-language-server-41ed018e80df12b59cdd0e60cce7484b0c972d81.zip
fix reference cross generic return
Diffstat (limited to 'test')
-rw-r--r--test/references/init.lua48
-rw-r--r--test/type_inference/init.lua25
2 files changed, 73 insertions, 0 deletions
diff --git a/test/references/init.lua b/test/references/init.lua
index 8494e12b..c4e5018a 100644
--- a/test/references/init.lua
+++ b/test/references/init.lua
@@ -386,3 +386,51 @@ end
local v1 = Master:foobar("", Dog)
v1.<!eat!>()
]]
+
+TEST [[
+---@class A
+local <?A?>
+
+---@generic T
+---@param self T
+---@return T
+function m.f(self) end
+
+local <!b!> = m.f(<!A!>)
+]]
+
+TEST [[
+---@class A
+local <?A?>
+
+---@generic T
+---@param self T
+---@return T
+function m:f() end
+
+local <!b!> = m.f(<!A!>)
+]]
+
+TEST [[
+---@class A
+local <?A?>
+
+---@generic T
+---@param self T
+---@return T
+function <!A!>.f(self) end
+
+local <!b!> = <!A!>:f()
+]]
+
+TEST [[
+---@class A
+local <?A?>
+
+---@generic T
+---@param self T
+---@return T
+function <!A!>:f() end
+
+local <!b!> = <!A!>:f()
+]]
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 9265643a..02355a94 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -654,3 +654,28 @@ function Cls:new() return self end
local <?test?> = Cls.new(Cls)
]]
+
+TEST 'Rct' [[
+---@class Obj
+local Obj = {}
+
+---@generic T
+---@param self T
+---@return T
+function Obj.new(self) return self end
+
+
+---@class Pnt:Obj
+local Pnt = {x = 0, y = 0}
+
+
+---@class Rct:Pnt
+local Rct = {w = 0, h = 0}
+
+
+local <?test?> = Rct.new(Rct)
+
+-- local test = Rct:new()
+
+return test
+]]