Skip to content

Commit 012a762

Browse files
committed
fix #318
1 parent 47fe75b commit 012a762

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.8.0
44
* `NEW` runtime: support nonstandard symbol
55
* `NEW` diagnostic: `close-non-object`
6+
* `FIX` [#318](https://github.com/sumneko/lua-language-server/issues/318)
67

78
## 1.7.4
89
`2020-12-20`

script/parser/guide.lua

+8-7
Original file line numberDiff line numberDiff line change
@@ -1767,18 +1767,18 @@ function m.searchSameMethodCrossSelf(ref, mark)
17671767
end
17681768

17691769
function m.searchSameMethod(ref, mark)
1770-
if mark['method'] then
1771-
return nil
1772-
end
17731770
local nxt = ref.next
17741771
if not nxt then
17751772
return nil
17761773
end
1777-
if nxt.type == 'setmethod' then
1778-
mark['method'] = true
1779-
return ref
1774+
if nxt.type ~= 'setmethod' then
1775+
return nil
1776+
end
1777+
if mark[ref] then
1778+
return nil
17801779
end
1781-
return nil
1780+
mark[ref] = true
1781+
return ref
17821782
end
17831783

17841784
function m.searchSameFieldsCrossMethod(status, ref, start, queue)
@@ -1795,6 +1795,7 @@ function m.searchSameFieldsCrossMethod(status, ref, start, queue)
17951795
local methodStatus = m.status(status)
17961796
m.searchRefs(methodStatus, method, 'ref')
17971797
for _, md in ipairs(methodStatus.results) do
1798+
mark[md] = true
17981799
queue[#queue+1] = {
17991800
obj = md,
18001801
start = start,

test/definition/bug.lua

+17
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,20 @@ TEST [[
152152
string.xx = ''
153153
string.xx:<?format?>()
154154
]]
155+
156+
TEST [[
157+
---@class Foo
158+
Foo = {}
159+
function Foo:Constructor()
160+
self.<!bar1!> = 1
161+
end
162+
163+
---@class Foo2: Foo
164+
Foo2 = {}
165+
function Foo2:Constructor()
166+
end
167+
168+
---@type Foo2
169+
local v
170+
v.<?bar1?>
171+
]]

0 commit comments

Comments
 (0)