diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-11-14 16:49:27 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-11-14 16:49:27 +0800 |
commit | 8c1669c85594e245eadfd1dbf1e537349640f2fb (patch) | |
tree | 9bacc4f2b1a57e71a21596deecdf58a355676026 /script/vm/type.lua | |
parent | ee590a4cd1bc972ffe19e232b176aa1ffaba2d47 (diff) | |
download | lua-language-server-8c1669c85594e245eadfd1dbf1e537349640f2fb.zip |
fix type infer in overload
Diffstat (limited to 'script/vm/type.lua')
-rw-r--r-- | script/vm/type.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/script/vm/type.lua b/script/vm/type.lua index 910d7960..545d2de5 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -767,3 +767,25 @@ function vm.viewTypeErrorMessage(uri, errs) return table.concat(lines, '\n') end end + +---@param name string +---@param uri uri +---@return parser.object[]? +function vm.getOverloadsByTypeName(name, uri) + local global = vm.getGlobal('type', name) + if not global then + return nil + end + local results + for _, set in ipairs(global:getSets(uri)) do + for _, doc in ipairs(set.bindGroup) do + if doc.type == 'doc.overload' then + if not results then + results = {} + end + results[#results+1] = doc.overload + end + end + end + return results +end |