Skip to content

Wrong class detection with inheritance or am I doing something wrong? #3057

Answered by tomlau10
shibotto asked this question in Q&A

You must be logged in to vote

This has been reported in a few duplicated issues:

in short The generic inheritance has not been implemented for the time being: #1505 (comment)

The workaround

---@generic T
---@param self T
---@param name string
---@return T
function Person:new(name)
    self.__index = self
    return setmetatable({ name = name }, self)
end
  • by using @generic to match the param self, and finally return this generic type
    => then this function can return the type based on caller

Or try CppCXY's language server

Or you might try CppCXY's lua language server written in rust, it doesn't has this bug, and it has better generic support also.
See: #3017

I just tried his server, you have to wr…

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@shibotto

Answer selected by shibotto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants