TEST [[ ---@class A local a = {} a. = 1 ---@return A local function f() end local b = f() return b. ]] TEST [[ ---@class A local a = {} a. = 1 ---@return table ---@return A local function f() end local a, b = f() return a.x, b. ]] TEST [[ local = {} function :x() :x() end ]] TEST [[ local mt = {} function mt:() self:() end ]] --TEST [[ -----@class Dog --local mt = {} --function mt:() --end -- -----@class Master --local mt2 = {} --function mt2:init() -- ---@type Dog -- local foo = self:doSomething() -- ---@type Dog -- self.dog = getDog() --end --function mt2:feed() -- self.dog:() --end --function mt2:doSomething() --end --]] TEST [[ local function f() return <~ () end!> end local = f() ]] TEST [[ local function f() return nil, <~ () end!> end local _, = f() ]] TEST [[ local local function f() return end local = f() ]] TEST [[ local local function f() return function () return end end local = f()() ]] -- TODO -- 泛型的反向搜索 do return end TEST [[ ---@class Dog local = {} ---@generic T ---@param type1 T ---@return T function foobar(type1) end local = foobar() ]] TEST [[ ---@class Dog local Dog = {} function Dog:() end ---@generic T ---@param type1 T ---@return T function foobar(type1) return {} end local v1 = foobar(Dog) v1:() ]] TEST [[ ---@class Dog local Dog = {} function Dog:() end ---@class Master local Master = {} ---@generic T ---@param type1 string ---@param type2 T ---@return T function Master:foobar(type1, type2) return {} end local v1 = Master:foobar("", Dog) v1.() ]] TEST [[ ---@class A local ---@generic T ---@param self T ---@return T function m.f(self) end local = m.f() ]] TEST [[ ---@class A local ---@generic T ---@param self T ---@return T function m:f() end local = m.f() ]] TEST [[ ---@class A local ---@generic T ---@param self T ---@return T function .f(self) end local = :f() ]] TEST [[ ---@class A local ---@generic T ---@param self T ---@return T function :f() end local = :f() ]]