diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/vm/function.lua | 10 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 20 |
3 files changed, 29 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md index c1b790fd..820c4af7 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # changelog ## 3.6.26 +* `FIX` wrong hover and signature for method with varargs and overloads * `FIX` [#2224] [#2224]: https://github.com/LuaLS/lua-language-server/issues/2224 diff --git a/script/vm/function.lua b/script/vm/function.lua index bdd7e229..c6df6349 100644 --- a/script/vm/function.lua +++ b/script/vm/function.lua @@ -372,8 +372,14 @@ function vm.isVarargFunctionWithOverloads(func) if not func.args then return false end - if not func.args[1] or func.args[1].type ~= '...' then - return false + if func.args[1] and func.args[1].type == 'self' then + if not func.args[2] or func.args[2].type ~= '...' then + return false + end + else + if not func.args[1] or func.args[1].type ~= '...' then + return false + end end if not func.bindDocs then return false diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index aee9ea0a..617b6f7e 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -1695,6 +1695,26 @@ function f(x: number, y: number) ```]] } +TEST { { path = 'a.lua', content = [[ +---@overload fun(self: self, x: number) +---@overload fun(self: self, x: number, y: number) +function M:f(...) +end + +M:<?f?> +]] }, +hover = [[ +```lua +(method) M:f(x: number) +``` + +--- + +```lua +(method) M:f(x: number, y: number) +```]] +} + TEST { {path = 'a.lua', content = [[ ---@class A |