From 9f5bd0f4e506797da27b1e9769323f42d04f715b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 18 Sep 2020 20:14:37 +0800 Subject: =?UTF-8?q?=E5=B0=BD=E9=87=8F=E5=8E=BB=E6=8E=89table=E9=87=8C?= =?UTF-8?q?=E7=9A=84any?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/core/hover/table.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'script-beta/core/hover') diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua index 69cb84d3..be980092 100644 --- a/script-beta/core/hover/table.lua +++ b/script-beta/core/hover/table.lua @@ -113,6 +113,7 @@ end return function (source) local literals = {} local classes = {} + local knownClasses = {} vm.eachField(source, function (src) local key, class, literal = getField(src) if not key then @@ -130,9 +131,18 @@ return function (source) for key, class in pairs(classes) do classes[key] = guide.mergeTypes(class) literals[key] = mergeLiteral(literals[key]) + if key ~= '[any]' then + for i = 1, #class do + knownClasses[#knownClasses+1] = class[i] + end + end end - if classes['[any]'] == 'any' then - classes['[any]'] = nil + if classes['[any]'] then + if classes['[any]'] == 'any' then + classes['[any]'] = nil + elseif classes['[any]'] == guide.mergeTypes(knownClasses) then + classes['[any]'] = nil + end end if not next(classes) then return '{}' -- cgit v1.2.3