You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@overload does not cooperate with @class when adding overloads to an inherited class method #3364
Adding an overload to a function inherited from another class should result in both the parent class' overloads and the new overload being suggested as autocomplete and hover tooltip entries.
Actual Behaviour
Adding an overload to a function inherited from another class makes that overload the only one that is recognized for the current class.
Reproduction steps
---@meta---@classParentClassParentClass= {}
---@paramargstring---@returnunknown---@overloadfun(self, arg: "bar"): booleanfunctionParentClass:foo(arg) end---@classChildClass:ParentClass---@fieldfoofun(self, arg: "baz"): numberChildClass= {}
ChildClass:foo(--[[Should suggest both "bar" and "baz", but only suggests "baz" and "bar" raises a param-type-mismatch]])
Redefining the function and adding an @overload there yields the same result.
Additional Notes
Having some way to mark a function redefinition as an overload (with strict checking that it does exist in the class defined as inherited from) would probably help solve this issue.
changed the title [-]`@overload` does not cooperate with `@class` when adding overloads to a class method[/-][+]`@overload` does not cooperate with `@class` when adding overloads to an inherited class method[/+]on Mar 2, 2026
Activity
tomlau10 commentedon Mar 2, 2026
I just found a workaround 🤔 you can write your meta definition like this:
Then
ChildClass.foohas both definition fromParentClass.fooas well as the additional overload[-]`@overload` does not cooperate with `@class` when adding overloads to a class method[/-][+]`@overload` does not cooperate with `@class` when adding overloads to an inherited class method[/+]