Skip to content

Commit 702b0e7

Browse files
committed
fix viewing
1 parent e74d75c commit 702b0e7

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

script/vm/compiler.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ local function bindAs(source)
613613
local doc = ases[index]
614614
if doc and doc.touch == source.finish then
615615
local asNode = vm.compileNode(doc.as)
616-
asNode.resolved = true
617616
vm.setNode(source, asNode, true)
618617
return true
619618
end
@@ -1947,6 +1946,5 @@ function vm.compileNode(source)
19471946

19481947
local node = vm.getNode(source)
19491948
---@cast node -?
1950-
node.resolved = true
19511949
return node
19521950
end

script/vm/infer.lua

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ local viewNodeSwitch;viewNodeSwitch = util.switch()
134134
for i, sign in ipairs(source.signs) do
135135
buf[i] = vm.getInfer(sign):view(uri)
136136
end
137-
if infer._drop then
138-
local node = vm.compileNode(source)
139-
for c in node:eachObject() do
140-
if guide.isLiteral(c) then
141-
infer._drop[c] = true
137+
local node = vm.compileNode(source)
138+
for c in node:eachObject() do
139+
if guide.isLiteral(c) then
140+
local view = vm.viewObject(c, uri)
141+
if view then
142+
infer._drop[view] = true
142143
end
143144
end
144145
end
@@ -150,10 +151,6 @@ local viewNodeSwitch;viewNodeSwitch = util.switch()
150151
infer._hasTable = true
151152
return
152153
end
153-
if infer._drop and infer._drop[source] then
154-
infer._hasTable = true
155-
return
156-
end
157154
infer._hasClass = true
158155
local buf = {}
159156
buf[#buf+1] = '{ '
@@ -291,9 +288,7 @@ function mt:_trim()
291288
end
292289

293290
---@param uri uri
294-
---@return table<string, true>
295291
function mt:_eraseAlias(uri)
296-
local drop = {}
297292
local expandAlias = config.get(uri, 'Lua.hover.expandAlias')
298293
for n in self.node:eachObject() do
299294
if n.type == 'global' and n.cate == 'type' then
@@ -304,8 +299,10 @@ function mt:_eraseAlias(uri)
304299
for _, set in ipairs(n:getSets(uri)) do
305300
if set.type == 'doc.alias' then
306301
if expandAlias then
307-
drop[n.name] = true
308-
local newInfer = {}
302+
self._drop[n.name] = true
303+
local newInfer = setmetatable({
304+
_drop = {},
305+
}, mt)
309306
for _, ext in ipairs(set.extends.types) do
310307
viewNodeSwitch(ext.type, ext, newInfer, uri)
311308
end
@@ -316,7 +313,7 @@ function mt:_eraseAlias(uri)
316313
for _, ext in ipairs(set.extends.types) do
317314
local view = viewNodeSwitch(ext.type, ext, {}, uri)
318315
if view and view ~= n.name then
319-
drop[view] = true
316+
self._drop[view] = true
320317
end
321318
end
322319
end
@@ -326,7 +323,6 @@ function mt:_eraseAlias(uri)
326323
::CONTINUE::
327324
end
328325
end
329-
return drop
330326
end
331327

332328
---@param uri uri
@@ -393,14 +389,13 @@ function mt:view(uri, default)
393389
return 'any'
394390
end
395391

396-
local drop
397392
if self._hasClass then
398-
drop = self:_eraseAlias(uri)
393+
self:_eraseAlias(uri)
399394
end
400395

401396
local array = {}
402397
for view in pairs(self.views) do
403-
if not drop or not drop[view] then
398+
if not self._drop[view] then
404399
array[#array+1] = view
405400
end
406401
end
@@ -529,7 +524,10 @@ end
529524
---@param uri uri
530525
---@return string?
531526
function vm.viewObject(source, uri)
532-
return viewNodeSwitch(source.type, source, {}, uri)
527+
local infer = setmetatable({
528+
_drop = {},
529+
}, mt)
530+
return viewNodeSwitch(source.type, source, infer, uri)
533531
end
534532

535533
---@param source parser.object

0 commit comments

Comments
 (0)