From cf3d5108c52e9194ed9fff1a54569edb7bd6ee1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 14 Apr 2022 23:38:13 +0800 Subject: #1050 class -> local/global -> .value --- script/vm/compiler.lua | 10 ++++++++++ test/definition/luadoc.lua | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 05057e68..708b4e12 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -214,6 +214,16 @@ function vm.getClassFields(suri, node, key, pushResult) pushResult(field) end end) + if src.value and src.value.type == 'table' then + searchFieldSwitch('table', suri, src.value, key, function (field) + local fieldKey = guide.getKeyName(field) + if not searchedFields[fieldKey] + and guide.isSet(field) then + hasFounded[fieldKey] = true + pushResult(field) + end + end) + end end end -- look into extends(if field not found) diff --git a/test/definition/luadoc.lua b/test/definition/luadoc.lua index 97b12b85..d7ac9a5b 100644 --- a/test/definition/luadoc.lua +++ b/test/definition/luadoc.lua @@ -859,3 +859,25 @@ end ]] + +TEST [[ +---@class A +local t = { + = nil, +} + +---@type A +local f +f. +]] + +TEST [[ +---@class A +G = { + = nil, +} + +---@type A +local f +f. +]] -- cgit v1.2.3