diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-31 11:26:51 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-31 11:26:51 +0800 |
commit | 41ed018e80df12b59cdd0e60cce7484b0c972d81 (patch) | |
tree | 53926994aac1bdd07597fd2683606714072954e9 /test | |
parent | 51a43979dc277e1a4418725cd001b5520d84588d (diff) | |
download | lua-language-server-41ed018e80df12b59cdd0e60cce7484b0c972d81.zip |
fix reference cross generic return
Diffstat (limited to 'test')
-rw-r--r-- | test/references/init.lua | 48 | ||||
-rw-r--r-- | test/type_inference/init.lua | 25 |
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 +]] |