8000 add the class method to Kernel by ptarjan · Pull Request #1050 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add the class method to Kernel #1050

8000 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 6 commits into from
Jun 25, 2019
Merged

add the class method to Kernel #1050

merged 6 commits into from
Jun 25, 2019

Conversation

ptarjan
Copy link
Contributor
@ptarjan ptarjan commented Jun 25, 2019

Somehow this was never in our shims. Pointed out in https://stackoverflow.com/questions/56758793/how-to-call-self-class-from-a-mix-in-module

Motivation

Test plan

See included automated tests.

@ptarjan ptarjan requested a review from a team June 25, 2019 19:48
@ghost ghost requested review from DarkDimius and removed request for a team June 25, 2019 19:48
@jez
Copy link
Collaborator
jez commented Jun 25, 2019

What the heck? Certainly we use .class at Stripe, don't we? Why was this never a problem before?

@ptarjan
Copy link
Contributor Author
ptarjan commented Jun 25, 2019

Maybe they were not in modules? I'll go check

8000
@ptarjan
Copy link
Contributor Author
ptarjan commented Jun 25, 2019

@DarkDimius
Copy link
Collaborator
[1] pry(main)> module M
[1] pry(main)*   include Kernel
[1] pry(main)* end
=> M
[2] pry(main)> class S < BasicObject
[2] pry(main)*   include ::M
[2] pry(main)*   def foo
[2] pry(main)*     self.class
[2] pry(main)*   end
[2] pry(main)* end
=> :foo
[3] pry(main)> S.new.foo
=> S
[4] pry(main)> class F < BasicObject
[4] pry(main)*   def foo
[4] pry(main)*     self.class
[4] pry(main)*   end
[4] pry(main)* end
=> :foo
[5] pry(main)> F.new.foo
NoMethodError: undefined method `class' for #<F:0x00007fb2e9a4f828>
from (pry):18:in `foo'

@ptarjan ptarjan merged commit 2dbd7e4 into master Jun 25, 2019
@ptarjan ptarjan deleted the pt-class-Kernel branch June 25, 2019 21:42
@mvidner mvidner mentioned this pull request Jun 26, 2019
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.

3 participants
0