summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLei Zhu <uhziel@gmail.com>2020-12-24 19:56:15 +0800
committerLei Zhu <uhziel@gmail.com>2020-12-24 19:56:15 +0800
commit0161e51df7f8aed8406e964316eb98926a52c023 (patch)
treed73925ee20ca0fb60d31c75a0e0ef68bba669de9 /test
parentcb28b668db32b7afe29c9d01dfcc700b0377e266 (diff)
downloadlua-language-server-0161e51df7f8aed8406e964316eb98926a52c023.zip
针对generic,类型参数允许是字符串字面值来表达类型
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/init.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index cfd0f4cb..5fdc3891 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -945,3 +945,19 @@ v2 = v
v2:method1()
v2:method2() -- 这个感觉实际应该报错更合适
]]
+
+TEST [[
+---@generic T
+---@param arg1 T
+---@return T
+function Generic(arg1) return arg1 end
+
+---@class Foo
+---@field bar1 integer
+local Foo = {}
+
+local v1 = Generic("Foo")
+print(v1.bar1)
+local v2 = Generic(Foo)
+print(v2.bar1)
+]]