Skip to content

Commit

Permalink
fix #421 keep order
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Mar 1, 2021
1 parent d529a50 commit 916820f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* `CHG` intelli-scense: improve infer across `table<K, V>` and `V[]`.
* `CHG` intelli-scense: improve infer across `pairs` and `ipairs`
* `FIX` [#398](https://github.com/sumneko/lua-language-server/issues/398)
* `FIX` [#421](https://github.com/sumneko/lua-language-server/issues/421)

## 1.17.0
`2021-2-24`
Expand Down
3 changes: 2 additions & 1 deletion script/parser/guide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3663,7 +3663,8 @@ function m.inferCheckUpDoc(status, source)
return
end
status.results = {}
for _, doc in ipairs(binds) do
for i = #binds, 1, -1 do
local doc = binds[i]
if doc.type == 'doc.class' then
status.results[#status.results+1] = {
type = doc.class[1],
Expand Down
3 changes: 2 additions & 1 deletion script/vm/getClass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ local function lookUpDocClass(source)
for _, infer in ipairs(infers) do
if infer.source.type == 'doc.class'
or infer.source.type == 'doc.type' then
return infer.type
return guide.viewInferType(infers)
end
end
return nil
end

local function getClass(source, classes, depth, deep)
Expand Down
18 changes: 18 additions & 0 deletions test/hover/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1544,3 +1544,21 @@ local k, v = next(<?t?>)
[[
local t: table<string, boolean>
]]

TEST [[
---@class A
---@class B: A
---@class C: B
---@class D: C
---@class E: D
local m
function m:f()
return <?self?>
end
]]
[[
local self: E {
f: function,
}
]]
1 change: 1 addition & 0 deletions test/type_inference/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ TEST 'E' [[
---@class B: A
---@class C: B
---@class D: C
---@class E: D
local m
Expand Down

0 comments on commit 916820f

Please sign in to comment.