@@ -1088,21 +1088,26 @@ end
1088
1088
--- @param func parser.object
1089
1089
--- @param source parser.object
1090
1090
local function compileFunctionParam (func , source )
1091
+ local aindex
1092
+ for index , arg in ipairs (func .args ) do
1093
+ if arg == source then
1094
+ aindex = index
1095
+ break
1096
+ end
1097
+ end
1098
+ --- @cast aindex integer
1099
+
1091
1100
-- local call ---@type fun(f: fun(x: number));call(function (x) end) --> x -> number
1092
1101
local funcNode = vm .compileNode (func )
1093
1102
for n in funcNode :eachObject () do
1094
1103
if n .type == ' doc.type.function' then
1095
- for index , arg in ipairs (n .args ) do
1096
- if func .args [index ] == source then
1097
- local argNode = vm .compileNode (arg )
1098
- for an in argNode :eachObject () do
1099
- if an .type ~= ' doc.generic.name' then
1100
- vm .setNode (source , an )
1101
- end
1102
- end
1103
- return true
1104
+ local argNode = vm .compileNode (n .args [aindex ])
1105
+ for an in argNode :eachObject () do
1106
+ if an .type ~= ' doc.generic.name' then
1107
+ vm .setNode (source , an )
1104
1108
end
1105
1109
end
1110
+ return true
1106
1111
end
1107
1112
end
1108
1113
@@ -1118,19 +1123,50 @@ local function compileFunctionParam(func, source)
1118
1123
if not caller .args then
1119
1124
goto continue
1120
1125
end
1121
- for index , arg in ipairs (source .parent ) do
1122
- if arg == source then
1123
- local callerArg = caller .args [index ]
1124
- if callerArg then
1125
- vm .setNode (source , vm .compileNode (callerArg ))
1126
- found = true
1127
- end
1128
- end
1126
+ local callerArg = caller .args [aindex ]
1127
+ if callerArg then
1128
+ vm .setNode (source , vm .compileNode (callerArg ))
1129
+ found = true
1129
1130
end
1130
1131
:: continue::
1131
1132
end
1132
1133
return found
1133
1134
end
1135
+
1136
+ do
1137
+ local parent = func .parent
1138
+ local key = vm .getKeyName (parent )
1139
+ local classDef = vm .getParentClass (parent )
1140
+ local suri = guide .getUri (func )
1141
+ if classDef and key then
1142
+ local found
1143
+ for _ , set in ipairs (classDef :getSets (suri )) do
1144
+ if set .type == ' doc.class' and set .extends then
1145
+ for _ , ext in ipairs (set .extends ) do
1146
+ local extClass = vm .getGlobal (' type' , ext [1 ])
1147
+ if extClass then
1148
+ vm .getClassFields (suri , extClass , key , function (field , isMark )
1149
+ for n in vm .compileNode (field ):eachObject () do
1150
+ if n .type == ' function' then
1151
+ local argNode = vm .compileNode (n .args [aindex ])
1152
+ for an in argNode :eachObject () do
1153
+ if an .type ~= ' doc.generic.name' then
1154
+ vm .setNode (source , an )
1155
+ found = true
1156
+ end
1157
+ end
1158
+ end
1159
+ end
1160
+ end )
1161
+ end
1162
+ end
1163
+ end
1164
+ end
1165
+ if found then
1166
+ return true
1167
+ end
1168
+ end
1169
+ end
1134
1170
end
1135
1171
1136
1172
--- @param source parser.object
0 commit comments