---@field a number
---@field b number
local A = {
a = 1,
aa = 2
}
function A:print()
end
---@generic V
---@param super any
---@param name `V`
---@return V
function inherit(super, name)
local newClass = {}
newClass.__index = newClass
return setmetatable(newClass, super)
end
---@class B : A
local B = inherit(A, "B")
function B:print()
local sf = self
sf.a = 10
end
如上代码,期望倒数第二行sf.a可以查到找基类A中a字段的定义,基类A中查找field a的引用可以查找到sf.a=10的代码行。 目前测试下来,a的定义和引用极大概率查找不成功,小概率成功