diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-06 20:49:07 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-06 20:49:07 +0800 |
commit | 73c4266110bd1013610db15a7e19d40498687b09 (patch) | |
tree | 2e017e058cc38003beeb128b44adf263e03b1f56 | |
parent | c3a596e3056315bb2501351aaa049a19bc91b6e8 (diff) | |
download | lua-language-server-73c4266110bd1013610db15a7e19d40498687b09.zip |
fix may infer a custom class as a string
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/infer.lua | 4 | ||||
-rw-r--r-- | test/type_inference/init.lua | 7 |
3 files changed, 11 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md index 76524c59..0a98c3ec 100644 --- a/changelog.md +++ b/changelog.md @@ -19,6 +19,7 @@ * `CHG` improve hover color * `CHG` improve performance * `FIX` supports for file with LF +* `FIX` may infer a custom class as a string ## 2.1.0 `2021-7-2` diff --git a/script/core/infer.lua b/script/core/infer.lua index aa1e1f28..c4af5122 100644 --- a/script/core/infer.lua +++ b/script/core/infer.lua @@ -244,7 +244,9 @@ local function cleanInfers(infers) -- 如果是通过 # 来推测的,且结果里没有其他的 table 与 string,则加入这2个类型 if infers[STRING_OR_TABLE] then infers[STRING_OR_TABLE] = nil - if not infers['table'] and not infers['string'] then + if not infers['table'] + and not infers['string'] + and not infers[CLASS] then infers['table'] = true infers['string'] = true end diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index c07074f7..77440cf6 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -882,3 +882,10 @@ print(t.<?x?>) TEST 'table' [[ local <?t?> = setmetatable({}, { __index = function () end }) ]] + +TEST 'player' [[ +---@class player +local t + +<?t?>:getOwner() +]] |