8000 Mark methods on root private by jez · Pull Request #2478 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Mark methods on root private #2478

< 8000 summary id="button-c074befdd9062e52" class="btn btn-sm btn-primary m-0 ml-0 ml-md-2" > 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

Merged
merged 4 commits into from
Jan 14, 2020
Merged

Mark methods on root private #2478

merged 4 commits into from
Jan 14, 2020

Conversation

jez
Copy link
Collaborator
@jez jez commented Jan 14, 2020

Motivation

def foo; end
class A; end

A.new.foo
❯ ruby foo.rb
Traceback (most recent call last):
foo.rb:4:in `<main>': private method `foo' called for #<A:0x00007fc22a04edd8> (NoMethodError)
Did you mean?  for

Stripe's codebase has a lot of methods defined on root. These show up as
completion results for nearly every method completion, because nearly everthing
is an Object.

One day, this will also help us properly support raising an error when trying
to call a private method when not allowed.

Test plan

See included automated tests.

@jez jez requested a review from a team January 14, 2020 20:57
@ghost ghost requested review from DarkDimius and removed request for a team January 14, 2020 20:57
// all methods at definition time are public, but their visibility may be changed later
method->symbol.data(ctx)->setPublic();

auto implicitlyPrivate = ctx.owner.data(ctx)->enclosingClass(ctx) == core::Symbols::root();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a symbol table exp file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jez jez force-pushed the jez-implicitly-private-object branch from 252f8ab to af9a7d8 Compare January 14, 2020 22:19
@jez jez requested review from a team, ptarjan and DarkDimius and removed request for a team and ptarjan January 14, 2020 22:19
@jez jez merged commit a048591 into master Jan 14, 2020
@jez jez deleted the jez-implicitly-private-object branch January 14, 2020 22:51
jez added a commit that referenced this pull request Jan 16, 2020
jez added a commit that referenced this pull request Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0