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

Fix type generation for types named AttachedClass that are not T::Types::AttachedClassType #2005

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented Aug 29, 2024

Motivation

When defining a class named AttachedClass, Tapioca is incorrectly generating it as if it was the type T.attached_class.

So for the following Ruby code:

class Foo
  class AttachedClass; end

  sig { returns(AttachedClass) }
  def foo; end
end

Tapioca would generate the following RBI which is incorrect:

class Foo
  class AttachedClass; end

  sig { returns(::Foo::T.attached_class) }
  def foo; end
end

Implementation

The gsub on the type name was a workaround until we merged sorbet/sorbet#3380 in sorbet-runtime, this is now unnecessary and is actually broken. We can just remove it.

Tests

See automated tests.

@Morriar Morriar requested a review from a team as a code owner August 29, 2024 17:29
@Morriar Morriar requested review from egiurleo and KaanOzkan August 29, 2024 17:29
…pes::AttachedClassType`

Signed-off-by: Alexandre Terrasa <[email protected]>
@Morriar Morriar force-pushed the at-fix-attached-class branch from d0c3d27 to 6dcabe5 Compare August 29, 2024 17:31
@Morriar Morriar self-assigned this Aug 29, 2024
@Morriar Morriar added the bugfix label Aug 29, 2024
@Morriar Morriar merged commit a0fbec3 into main Aug 29, 2024
30 of 31 checks passed
@Morriar Morriar deleted the at-fix-attached-class branch August 29, 2024 18:36
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.

2 participants