From 9f0efc803b77905292875208dbb68f6630d402b6 Mon Sep 17 00:00:00 2001 From: Kirill Mokevnin Date: Sun, 13 Sep 2026 12:25:12 -0400 Subject: [PATCH] Bind alba's class_eval'd blocks to T.self_type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `nested`, `nested_attribute` and `trait` class_eval their block on a subclass of the resource the macro was called on, so `self` inside the block is that resource class — a type the sig can name. `T.untyped` erases it, and with it every `attribute` declared inside the block: a DSL-typing RBI for the resource class no longer applies, so the block parameter and anything derived from it fall back to untyped. Co-Authored-By: Claude Opus 5 (1M context) --- rbi/annotations/alba.rbi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rbi/annotations/alba.rbi b/rbi/annotations/alba.rbi index 3764ed4..639e031 100644 --- a/rbi/annotations/alba.rbi +++ b/rbi/annotations/alba.rbi @@ -105,7 +105,7 @@ module Alba::Resource::ClassMethods params( name: T.any(String, Symbol), options: T.untyped, - block: T.proc.bind(T.untyped).void, + block: T.proc.bind(T.self_type).void, ).void end def nested(name, **options, &block); end @@ -114,7 +114,7 @@ module Alba::Resource::ClassMethods params( name: T.any(String, Symbol), options: T.untyped, - block: T.proc.bind(T.untyped).void, + block: T.proc.bind(T.self_type).void, ).void end def nested_attribute(name, **options, &block); end @@ -165,7 +165,7 @@ module Alba::Resource::ClassMethods sig { params(key: T.any(String, Symbol)).void } def root_key_for_collection(key); end - sig { params(name: T.any(String, Symbol), block: T.proc.bind(T.untyped).void).void } + sig { params(name: T.any(String, Symbol), block: T.proc.bind(T.self_type).void).void } def trait(name, &block); end sig { params(type: T.any(String, Symbol), root: T::Boolean, cascade: T::Boolean).void }