activesupport: bind ActiveSupport::Concern block DSLs to T.untyped - #423
Merged
amomchilov merged 1 commit intoSep 11, 2026
Merged
Conversation
`included`, `prepended`, and `class_methods` class_eval their block on the including class (or the generated ClassMethods module), so `self` inside the block is never the concern module itself. Without a binding Sorbet types `self` as `T.class_of(TheConcern)` and reports 7003 for every DSL call in an `included do … end` body. `T.untyped` is the honest binding — a concern cannot know its includer — and matches the existing `Testing::Declarative#test` and `SetupAndTeardown#setup`/`#teardown` annotations in this file.
frewsxcv
marked this pull request as ready for review
September 11, 2026 19:45
amomchilov
approved these changes
Sep 11, 2026
amomchilov
left a comment
Contributor
There was a problem hiding this comment.
Too bad that proc binds can't be generic. T.untyped is the best we can do here, for now.
Thanks!
Contributor
Author
|
@amomchilov Hmm is there something that needs to happen in order for the build in CI to get kicked off? |
Contributor
|
@frewsxcv I forgot to push the button :) Started. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds annotations for
ActiveSupport::Concern#included,#prepended, and#class_methodsbinding the block'sselftoT.untyped.These methods
class_evaltheir block on the including class (or the generatedClassMethodsmodule), soselfinside the block is never the concern module. Without a binding, Sorbet typesselfasT.class_of(TheConcern)and reports 7003 on every DSL call in anincluded do … endbody (scope,validates,has_many,class_attribute, …), which pushes concern modules toward# typed: false.T.untypedis the honest binding since a concern can't know its includer, and it matches the existingTesting::Declarative#testandSetupAndTeardown#setup/#teardownannotations in this file.Version guards:
class_methodssince 4.2,prependedsince 6.1.repo check index,rubocop,runtime activesupport, andstatic activesupportall pass locally.