Skip to content

Commit 8ca1599

Browse files
committed
fix: address code review feedback and add changelog entry
- Remove unnecessary doc.field handling (vm.compileNode already handles it) - Keep doc.type.function support in parent class field lookup - Add changelog entry for the new feature
1 parent 255e83b commit 8ca1599

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5+
* `NEW` Support type inference for `@field` and `@type` function declarations in method overrides [#3367](https://github.com/LuaLS/lua-language-server/issues/3367)
56
* `CHG` Modified the `ResolveRequire` function to pass the source URI as a third argument.
67

78
## 3.17.1

script/vm/compiler.lua

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,16 +1353,10 @@ local function compileFunctionParam(func, source)
13531353
]]
13541354
local found = false
13551355
for n in funcNode:eachObject() do
1356-
-- Extract actual function type node
1357-
local funcType = n
1358-
if n.type == 'doc.field' and n.extends then
1359-
funcType = n.extends
1360-
end
1361-
1362-
if (funcType.type == 'doc.type.function' or funcType.type == 'function')
1363-
and funcType.args and funcType.args[aindex] and funcType.args[aindex] ~= source
1356+
if (n.type == 'doc.type.function' or n.type == 'function')
1357+
and n.args and n.args[aindex] and n.args[aindex] ~= source
13641358
then
1365-
local argNode = vm.compileNode(funcType.args[aindex])
1359+
local argNode = vm.compileNode(n.args[aindex])
13661360
for an in argNode:eachObject() do
13671361
if an.type ~= 'doc.generic.name' then
13681362
vm.setNode(source, an)
@@ -1466,16 +1460,10 @@ local function compileFunctionParam(func, source)
14661460
end
14671461
vm.getClassFields(suri, extClass, key, function (field, _isMark)
14681462
for n in vm.compileNode(field):eachObject() do
1469-
-- Extract actual function type node
1470-
local funcType = n
1471-
if n.type == 'doc.field' and n.extends then
1472-
funcType = n.extends
1473-
end
1474-
1475-
if (funcType.type == 'function' or funcType.type == 'doc.type.function')
1476-
and funcType.args and funcType.args[aindex]
1463+
if (n.type == 'function' or n.type == 'doc.type.function')
1464+
and n.args and n.args[aindex]
14771465
then
1478-
local argNode = vm.compileNode(funcType.args[aindex])
1466+
local argNode = vm.compileNode(n.args[aindex])
14791467
for an in argNode:eachObject() do
14801468
if an.type ~= 'doc.generic.name' then
14811469
vm.setNode(source, an)

0 commit comments

Comments
 (0)