TEST [[ ---@class ---@class B : ]] TEST [[ ---@class ---@type B| ]] TEST [[ ---@class Class local ?> ---@type Class local x ]] TEST [[ ---@class Class local ---@type Class local ?> ]] TEST [[ ---@class A local mt = {} function mt:() end ---@type A local obj obj:() ]] TEST [[ ---@class A local = {} function mt:cast() end ---@type A local :cast() ]] TEST [[ ---@type A local ?> ---@class A local ]] TEST [[ ---@type A local obj obj:() ---@class A local mt function mt:() end ]] TEST [[ ---@type A local obj obj:() local mt = {} mt.__index = mt function mt:() end ---@class A local obj = setmetatable({}, mt) ]] TEST [[ ---@alias A ---@type ]] TEST [[ ---@class ---@param a ]] TEST [[ ---@param f function t(?>) end ]] TEST [[ ---@overload fun(y: boolean) ---@param x number ---@param y boolean ---@param z string function (x, y, z) end print() ]] TEST [[ local function f() return 1 end ---@class Class local ---@type Class local ?> = f() ]] TEST [[ ---@class Class ---@field string ---@field id integer local mt = {} mt. ]] TEST [[ ---@alias string ---@type ]] TEST [[ ---@class X ---@field string ---@class Y:X ---@type Y local y y. ]] TEST [[ ---@class local function unit:pants() end ---@see ]] TEST [[ ---@class loli local unit function unit:() end ---@see loli# ]] TEST [[ ---@class AAAA ---@field a AAAA AAAA = {}; function AAAA:() end AAAA.a. ]] TEST [[ ---@class Cat local ---hahaha ---@class Dog local m2 ---@type Cat local ?> ]] TEST [[ ---@class Cat local --hahaha ---@class Dog local m2 ---@type Cat local ?> ]] TEST [[ ---@class Cat local ---hahaha ---@class Dog local m2 ---@type Cat local ?> ]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@generic T ---@param arg1 T ---@return T function Generic(arg1) print(arg1) end local v1 = Generic(Foo) print(v1.) ]] TEST [[ ---@class Foo local Foo = {} function Foo:bar1() end ---@generic T ---@param arg1 T ---@return T function Generic(arg1) print(arg1) end local v1 = Generic("Foo") print(v1.) ]] TEST [[ ---@class Foo local Foo = {} function Foo:bar1() end ---@generic T ---@param arg1 `T` ---@return T function Generic(arg1) print(arg1) end local v1 = Generic(Foo) print(v1.) ]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@generic T ---@param arg1 `T` ---@return T function Generic(arg1) print(arg1) end local v1 = Generic("Foo") print(v1.) ]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@type table local v1 print(v1[1].) ]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@class Foo2 local Foo2 = {} function Foo2:bar1() end ---@type Foo2 local v1 print(v1[1].) ]] --TODO 得扩展 simple 的信息才能识别这种情况了 --TEST [[ -----@class Foo --local Foo = {} --function Foo:bar1() end -- -----@class Foo2 --local Foo2 = {} --function Foo2:() end -- -----@type Foo2 --local v1 --print(v1.) --]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@type table local v1 local ipairs = ipairs for i, v in ipairs(v1) do print(v.) end ]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@type table local v1 for k, v in pairs(v1) do print(k.) print(v.bar1) end ]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@type table> local v1 for i, v in ipairs(v1) do local v2 = v[1] print(v2.) end ]] TEST [[ ---@class Foo local Foo = {} function Foo:() end ---@type table> local v1 print(v1[1][1].) ]] TEST [[ ---@class X ---@class Y ---@field string ---@class Z:X, Y ---@type Z local z z. ]]