Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting Overloads #56

Open
bmalinconico opened this issue Oct 29, 2019 · 4 comments
Open

Supporting Overloads #56

bmalinconico opened this issue Oct 29, 2019 · 4 comments
Labels
enhancement New feature or request on hold This will be looked into at some point, but not yet

Comments

@bmalinconico
Copy link
Contributor

Sorbet now supported overloaded method signatures.

Poking around parlour I do not see a way to do this yet. If we are not yet able to generate multiple sigs per method, I would like to have a chat about options. If they have not been implemented by the time I need them, I'll add them myself if we can agree on an appropriate pattern.

My first instinct is:

@node.create_method('foo', the_rest) do |method|
  method.add_signature(takes_the_same_arguments_less_the_name)
end
@bmalinconico bmalinconico added the enhancement New feature or request label Oct 29, 2019
@AaronC81
Copy link
Owner

I didn't know Sorbet supports overloads now - that's great!

Parlour doesn't support this currently. I'm happy to look at implementing overloads, but we do indeed need to decide on a pattern for implementing them. I'm think the call structure you've proposed is probably the best way of doing it.

It might be worth restructuring some of how Parlour works to make the implementation more elegant - perhaps breaking a Signature object out of the existing Method object, or something like that.

@AaronC81
Copy link
Owner

May I ask if you're currently using overloads in a codebase, @bmalinconico? It seems that they aren't generally available for use in Sorbet yet, and I can't get them to work on sorbet.run.

@bmalinconico
Copy link
Contributor Author

Ah looks like overloads are only allowed in the stdlib and that test file

        constexpr string_view whitelistedTest = "overloads_test.rb"sv;
        if (((file.isPayload() || file.isStdlib()) && owner != Symbols::root() &&
             (owner != Symbols::Object() || sigLoc.data(*this).isStdlib())) ||
            FileOps::getFileName(file.path()) == whitelistedTest) {
            return true;
        }

Hopefully that means it is coming soon

@AaronC81 AaronC81 added the on hold This will be looked into at some point, but not yet label Feb 19, 2020
@bdewater
Copy link

bdewater commented Mar 7, 2024

This is possible outside of stdlib since Sorbet 0.5.11087 (ref sorbet/sorbet#7412).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request on hold This will be looked into at some point, but not yet
Projects
None yet
Development

No branches or pull requests

3 participants