Skip to content

Conversation

@Morriar
Copy link
Contributor

@Morriar Morriar commented Dec 17, 2024

Following the discussion in #2139 (comment).

@ParadoxV5
Copy link
Contributor

class refers to the class itself. From my understanding,

class A
  X: class # A
end
class B < A
  # B::X is of type B
end

I’ve always considered instance and self to be different:

SUBJECT = Object.new
SUBJECT.extend Comparable # i.e., SUBJECT.singleton_class.include Comparable
class Object
  def dup: () -> instance # Object
  def itself: () -> self # Object
end
SUBJECT: Object & Comparable
# SUBJECT.dup    -> Object
# SUBJECT.itself -> Object & Comparable

@soutaro
Copy link
Member

soutaro commented Jan 24, 2025

Thanks. Looks good.

I found the biggest difference is when the class is generic. When the type is C[Integer], self is C[Integer], instance is C[untyped].

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

👍

@soutaro soutaro enabled auto-merge January 24, 2025 03:23
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
auto-merge was automatically disabled January 24, 2025 14:54

Head branch was pushed to by a user without write access

@Morriar
Copy link
Contributor Author

Morriar commented Jan 24, 2025

Rebased on master 👍

@soutaro soutaro added this pull request to the merge queue Jan 25, 2025
Merged via the queue into ruby:master with commit e5a4329 Jan 25, 2025
19 checks passed
@ksss ksss mentioned this pull request Feb 24, 2025
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