From 3981f28e23e1e7f4fb4cf44695490f0ce929a870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 22 Feb 2021 19:17:54 +0800 Subject: fix wrong type infer of doc.field --- script/core/hover/label.lua | 6 ++---- test/completion/init.lua | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index dd309c41..2fb0b14c 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -127,10 +127,8 @@ local function asDocField(source) end end local infers = {} - for _, ext in ipairs(source.extends) do - for _, infer in ipairs(vm.getInfers(ext) or {}) do - infers[#infers+1] = infer - end + for _, infer in ipairs(vm.getInfers(source.extends) or {}) do + infers[#infers+1] = infer end if not class then return ('field ?.%s: %s'):format( diff --git a/test/completion/init.lua b/test/completion/init.lua index fc9233d8..5f79ea21 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -2093,3 +2093,25 @@ local s = f() s.$ ]] (EXISTS) + +Cared['description'] = true +TEST [[ +---@class cc +---@field aaa number +---@field bbb number + +---@type cc +local t +print(t.aa$) +]] +{ + { + label = 'aaa', + kind = define.CompletionItemKind.Field, + description = [[ +```lua +field cc.aaa: number +```]] + }, +} +Cared['description'] = nil -- cgit v1.2.3