summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-05-12 14:54:40 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-05-12 14:54:40 +0800
commitcbff022761f244cbb8940f812ede207c44ab2614 (patch)
treecb4b04f568cb71136103103d2b348d77a1729542 /test
parent3b97d7d4d54755517db0fd776c006bbb37313967 (diff)
downloadlua-language-server-cbff022761f244cbb8940f812ede207c44ab2614.zip
update generic
Diffstat (limited to 'test')
-rw-r--r--test/definition/luadoc.lua70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua
index fe6d1e21..e6827d65 100644
--- a/test/definition/luadoc.lua
+++ b/test/definition/luadoc.lua
@@ -427,11 +427,81 @@ local <?<!c!>?> = f(b)
]]
TEST [[
+---@generic V
+---@return fun(t: V[]):V
+local function f() end
+
+---@class A
+local <!a!>
+
+---@type A[]
+local b
+
+local f2 = f()
+
+local <?<!c!>?> = f2(b)
+]]
+
+TEST [[
+---@generic T, V
+---@param t T
+---@return fun(t: V[]):V
+---@return T
+local function f(t) end
+
+---@class A
+local <!a!>
+
+---@type A[]
+local b
+
+local f2, c = f(b)
+
+local <?<!d!>?> = f2(c)
+]]
+
+TEST [[
+---@class C
+local <!v1!>
+
+---@generic V, T
+---@param t T
+---@return fun(t: V): V
+---@return T
+local function iterator(t) end
+
+for <!v!> in iterator(v1) do
+ print(<?v?>)
+end
+]]
+
+TEST [[
---@class C
+local <!v!>
+
+---@type C
local <!v1!>
---@generic V, T
---@param t T
+---@return fun(t: V): V
+---@return T
+local function iterator(t) end
+
+for <!v!> in iterator(v1) do
+ print(<?v?>)
+end
+]]
+
+TEST [[
+---@class C
+local <!v!>
+
+---@type C[]
+local v1
+
+---@generic V, T
+---@param t T
---@return fun(t: V[]): V
---@return T
local function iterator(t) end