Skip to content

Incorrect types used for overloaded class when passed as argument #3274

@NathanSnail

Description

@NathanSnail

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

When a class which is overloaded as a function, if that class is passed as an argument to another function it should be checked as if it is a function if the argument has a function type.

---@param f function
local function call(f) f() end

---@class foo
---@overload fun()
local something = setmetatable({}, {__call = function () end})

call(something) -- <-- Here something should be treated as `fun()`

Actual Behaviour

The type of the class is treated as foo|fun() which results in a warning because foo does not match function.

Reproduction steps

  1. Create a class with an overload
  2. Pass it to another function which takes a function argument
  3. Observe that a warning is produced

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions