Skip to content

Conversation

@jesse-shopify
Copy link
Contributor

@jesse-shopify jesse-shopify commented Jan 26, 2026

When translating signatures into RBS on abstract methods, use the following pattern instead of a raise:

def abstract_method = defined?(super) ? super : raise(NotImplementedError, "Abstract method called")

This requires sorbet support:

Questions

  • When sorbet support ships, is it best to bump the minimum sorbet version to match?

@jesse-shopify jesse-shopify self-assigned this Jan 26, 2026
@jesse-shopify jesse-shopify requested a review from a team as a code owner January 26, 2026 21:39
@jesse-shopify jesse-shopify requested review from a team, dejmedus and thomasmarshall January 26, 2026 21:40
@jesse-shopify jesse-shopify force-pushed the rbs-abstract-methods-super branch from d1171aa to 1f9543f Compare January 26, 2026 21:51
visit_scope(node) { super }
end

ABSTRACT_METHOD_BODY = "defined?(super) ? super : raise(NotImplementedError, \"Abstract method called\")"
Copy link
Contributor

Choose a reason for hiding this comment

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

As a follow up, it would be nice to provide the replacement through the translator options:

# does not rewrite abstract methods
SorbetSigsToRBSComments.new(
  translate_abstract_methods: nil
)

# old behavior, uses only raise
SorbetSigsToRBSComments.new(
  translate_abstract_methods: "raise NotImplementedError, \"Abstract method called\""
)

# new behavior, uses defined super
SorbetSigsToRBSComments.new(
  translate_abstract_methods: "defined?(super) ? super : raise(NotImplementedError, \"Abstract method called\")"
)

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