Skip to content

Ruby: Add type row for extends calls #15311

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hmac
Copy link
Contributor

@hmac hmac commented Jan 12, 2024

A call to extend M adds all the instance methods of module M as class
methods to the receiver. For example:

module A
  def f; end
end

class B
  extend A
end

B.f # => targets A.f

To model this, we generate a typeModel row of the form

A, B!,

which can be interpreted as "the class B is an instance of the module
A". This is not strictly true, but means that class method calls on B
which are defined in A will be dispatched correctly.

A call to `extend M` adds all the instance methods of module `M` as class
methods to the receiver. For example:

```rb
module A
  def f; end
end

class B
  extend A
end

B.f # => targets A.f
```

To model this, we generate a `typeModel` row of the form

```
A, B!,
```

which can be interpreted as "the class `B` is an instance of the module
`A`". This is not strictly true, but means that class method calls on `B`
which are defined in `A` will be dispatched correctly.
@github-actions github-actions bot added the Ruby label Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant