summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/parser/guide.lua15
-rw-r--r--test/definition/bug.lua17
3 files changed, 26 insertions, 7 deletions
diff --git a/changelog.md b/changelog.md
index 8118e1bb..71a880b2 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,6 +3,7 @@
## 1.8.0
* `NEW` runtime: support nonstandard symbol
* `NEW` diagnostic: `close-non-object`
+* `FIX` [#318](https://github.com/sumneko/lua-language-server/issues/318)
## 1.7.4
`2020-12-20`
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index b07a301e..35658c94 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1767,18 +1767,18 @@ function m.searchSameMethodCrossSelf(ref, mark)
end
function m.searchSameMethod(ref, mark)
- if mark['method'] then
- return nil
- end
local nxt = ref.next
if not nxt then
return nil
end
- if nxt.type == 'setmethod' then
- mark['method'] = true
- return ref
+ if nxt.type ~= 'setmethod' then
+ return nil
+ end
+ if mark[ref] then
+ return nil
end
- return nil
+ mark[ref] = true
+ return ref
end
function m.searchSameFieldsCrossMethod(status, ref, start, queue)
@@ -1795,6 +1795,7 @@ function m.searchSameFieldsCrossMethod(status, ref, start, queue)
local methodStatus = m.status(status)
m.searchRefs(methodStatus, method, 'ref')
for _, md in ipairs(methodStatus.results) do
+ mark[md] = true
queue[#queue+1] = {
obj = md,
start = start,
diff --git a/test/definition/bug.lua b/test/definition/bug.lua
index 9eafe302..8c446123 100644
--- a/test/definition/bug.lua
+++ b/test/definition/bug.lua
@@ -152,3 +152,20 @@ TEST [[
string.xx = ''
string.xx:<?format?>()
]]
+
+TEST [[
+---@class Foo
+Foo = {}
+function Foo:Constructor()
+ self.<!bar1!> = 1
+end
+
+---@class Foo2: Foo
+Foo2 = {}
+function Foo2:Constructor()
+end
+
+---@type Foo2
+local v
+v.<?bar1?>
+]]