summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-12-28 16:58:59 +0800
committerGitHub <noreply@github.com>2020-12-28 16:58:59 +0800
commite0ff9a81c623efc1882b1fd4fad8389c7fa3ca63 (patch)
tree75d100145eef870fa4a5743b9f225a7d1fd7cd6a /test
parentf9cf323b0e0de084c74c243432d02ec1598cc6dc (diff)
parent9586b303e9b76d5da19352bd42599480c0f2c0d1 (diff)
downloadlua-language-server-e0ff9a81c623efc1882b1fd4fad8389c7fa3ca63.zip
Merge pull request #326 from uhziel/generic-name-string-literal
针对generic,类型参数允许是字符串字面值来表达类型
Diffstat (limited to 'test')
-rw-r--r--test/definition/luadoc.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua
index 4a23b2ac..1f3dae00 100644
--- a/test/definition/luadoc.lua
+++ b/test/definition/luadoc.lua
@@ -197,3 +197,59 @@ TEST [[
---@type Cat
local <?<!v!>?>
]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@generic T
+---@param arg1 T
+---@return T
+function Generic(arg1) print(arg1) end
+
+local v1 = Generic(Foo)
+print(v1.<?bar1?>)
+]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:bar1() end
+
+---@generic T
+---@param arg1 T
+---@return T
+function Generic(arg1) print(arg1) end
+
+local v1 = Generic("Foo")
+print(v1.<?bar1?>)
+]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:bar1() end
+
+---@generic T
+---@param arg1 `T`
+---@return T
+function Generic(arg1) print(arg1) end
+
+local v1 = Generic(Foo)
+print(v1.<?bar1?>)
+]]
+
+TEST [[
+---@class Foo
+local Foo = {}
+function Foo:<!bar1!>() end
+
+---@generic T
+---@param arg1 `T`
+---@return T
+function Generic(arg1) print(arg1) end
+
+local v1 = Generic("Foo")
+print(v1.<?bar1?>)
+]]