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

Do not report duplicate for shim or annotations classes redefining the superclass #1912

Merged
merged 1 commit into from
May 30, 2024

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented May 30, 2024

Motivation

Sometimes we want to use shims to define the parent class that Tapioca may have missed. (Example 1, 2)

Consider this file generated by Tapioca for a gem:

# sorbet/rbi/gems/foo@1.0.0.rbi
class Foo
end

The user knows that Foo actually inherits from Baz and wants to fix this in a shim:

# sorbet/rbi/shims/foo.rbi
class Foo < Bar
end

Tapioca check-shims command will report a useless duplicated shims, yet this redefinition should be allowed:

          Duplicated RBI for ::Foo:
           * sorbet/rbi/shims/foo.rbi:1:0-2:3
           * sorbet/rbi/gems/foo@1.0.0.rbi:1:0-2:3

Implementation

Before reporting a shim class as a duplicate, we should check if it redefines the super class compared to the definitions we can find in the generated files.

Tests

See automated tests.

…e parent class

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar marked this pull request as ready for review May 30, 2024 16:19
@Morriar Morriar requested a review from a team as a code owner May 30, 2024 16:19
@Morriar Morriar self-assigned this May 30, 2024
@Morriar Morriar added the bugfix label May 30, 2024
Copy link
Contributor

@amomchilov amomchilov left a comment

Choose a reason for hiding this comment

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

Love it

Copy link

@ipvalverde ipvalverde left a comment

Choose a reason for hiding this comment

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

Thanks for this solution!

@Morriar Morriar merged commit d7a9777 into main May 30, 2024
32 checks passed
@Morriar Morriar deleted the at-fix-check-shims branch May 30, 2024 17:45
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.

None yet

3 participants