From 91452ceecfa9a1ae9df72a9054eeea88703d5517 Mon Sep 17 00:00:00 2001 From: Patrick Linnane Date: Sat, 10 Oct 2026 09:51:16 -0700 Subject: [PATCH] Extend `T::Generic` in Tapioca DSL compilers Signed-off-by: Patrick Linnane --- Library/Homebrew/sorbet/tapioca/compilers/api_structs.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/args.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/cask/caveats.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/cask/config.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/cask/dsl.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/env_config.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/forwardables.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/on_system.rb | 2 ++ .../sorbet/tapioca/compilers/rspec_dynamic_matchers.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/rubocop.rb | 2 ++ .../sorbet/tapioca/compilers/rubocop_cask_ast_stanza.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/subcommand_args.rb | 2 ++ Library/Homebrew/sorbet/tapioca/compilers/tty.rb | 2 ++ .../test/sorbet/tapioca/compilers/subcommand_args_spec.rb | 3 --- Library/Homebrew/test/sorbet/tapioca/config_spec.rb | 3 --- 15 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/sorbet/tapioca/compilers/api_structs.rb b/Library/Homebrew/sorbet/tapioca/compilers/api_structs.rb index 6a214b70b7a0c..ab67ba06a700a 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/api_structs.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/api_structs.rb @@ -8,6 +8,8 @@ module Tapioca module Compilers class ApiStructs < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T.class_of(T::Struct) } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/args.rb b/Library/Homebrew/sorbet/tapioca/compilers/args.rb index 826d11614779b..24dd74a6d9467 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/args.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/args.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class Args < Tapioca::Dsl::Compiler + extend T::Generic + GLOBAL_OPTIONS = T.let( Homebrew::CLI::Parser.global_options.map do |short_option, long_option, _| [short_option, long_option].map { "#{Homebrew::CLI::Parser.option_to_name(it)}?" } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/cask/caveats.rb b/Library/Homebrew/sorbet/tapioca/compilers/cask/caveats.rb index ef93568f939f8..1b8f217efec30 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/cask/caveats.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/cask/caveats.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class CaskCaveats < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/cask/config.rb b/Library/Homebrew/sorbet/tapioca/compilers/cask/config.rb index a93ed11dce6bb..2eb5bcb8e535d 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/cask/config.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/cask/config.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class CaskConfig < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/cask/dsl.rb b/Library/Homebrew/sorbet/tapioca/compilers/cask/dsl.rb index f0c9cd8f1f718..2c325ebcecef9 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/cask/dsl.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/cask/dsl.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class CaskDsl < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/env_config.rb b/Library/Homebrew/sorbet/tapioca/compilers/env_config.rb index bb0a3bf4d9e07..b742ce0632dea 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/env_config.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/env_config.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class EnvConfig < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/forwardables.rb b/Library/Homebrew/sorbet/tapioca/compilers/forwardables.rb index 0f79c54a74718..43cfc0b42b731 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/forwardables.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/forwardables.rb @@ -8,6 +8,8 @@ module Tapioca module Compilers class Forwardables < Tapioca::Dsl::Compiler + extend T::Generic + FORWARDABLE_FILENAME = "forwardable.rb" ARRAY_METHODS = ["to_a", "to_ary"].freeze HASH_METHODS = ["to_h", "to_hash"].freeze diff --git a/Library/Homebrew/sorbet/tapioca/compilers/on_system.rb b/Library/Homebrew/sorbet/tapioca/compilers/on_system.rb index a90b1b6f64d53..f5917463129da 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/on_system.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/on_system.rb @@ -9,6 +9,8 @@ module Tapioca module Compilers class OnSystem < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/rspec_dynamic_matchers.rb b/Library/Homebrew/sorbet/tapioca/compilers/rspec_dynamic_matchers.rb index 3b7f1235ee999..8fdb2c9725e98 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/rspec_dynamic_matchers.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/rspec_dynamic_matchers.rb @@ -6,6 +6,8 @@ module Tapioca module Compilers class RspecDynamicMatchers < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/rubocop.rb b/Library/Homebrew/sorbet/tapioca/compilers/rubocop.rb index 572e732e000b2..f17d8cf8dda12 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/rubocop.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/rubocop.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class RuboCop < Tapioca::Dsl::Compiler + extend T::Generic + # This should be a module whose singleton class contains RuboCop::AST::NodePattern::Macros, # but I don't know how to express that in Sorbet. ConstantType = type_member { { fixed: T::Module[T.anything] } } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/rubocop_cask_ast_stanza.rb b/Library/Homebrew/sorbet/tapioca/compilers/rubocop_cask_ast_stanza.rb index 00ec8e8142a6b..a4382b2f68620 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/rubocop_cask_ast_stanza.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/rubocop_cask_ast_stanza.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class Stanza < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/subcommand_args.rb b/Library/Homebrew/sorbet/tapioca/compilers/subcommand_args.rb index c375003fc6ec3..1de11eb622b0b 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/subcommand_args.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/subcommand_args.rb @@ -8,6 +8,8 @@ module Tapioca module Compilers class SubcommandArgs < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T.class_of(Homebrew::AbstractSubcommand) } } sig { override.returns(T::Enumerable[T.class_of(Homebrew::AbstractSubcommand)]) } diff --git a/Library/Homebrew/sorbet/tapioca/compilers/tty.rb b/Library/Homebrew/sorbet/tapioca/compilers/tty.rb index 4c9be2dff3dc7..4d41e63659401 100644 --- a/Library/Homebrew/sorbet/tapioca/compilers/tty.rb +++ b/Library/Homebrew/sorbet/tapioca/compilers/tty.rb @@ -7,6 +7,8 @@ module Tapioca module Compilers class Tty < Tapioca::Dsl::Compiler + extend T::Generic + ConstantType = type_member { { fixed: T::Module[T.anything] } } sig { override.returns(T::Enumerable[T::Module[T.anything]]) } diff --git a/Library/Homebrew/test/sorbet/tapioca/compilers/subcommand_args_spec.rb b/Library/Homebrew/test/sorbet/tapioca/compilers/subcommand_args_spec.rb index 1c4bbdd60ff24..19dc087d22bfc 100644 --- a/Library/Homebrew/test/sorbet/tapioca/compilers/subcommand_args_spec.rb +++ b/Library/Homebrew/test/sorbet/tapioca/compilers/subcommand_args_spec.rb @@ -4,9 +4,6 @@ require "bundler" require "tapioca/dsl" -# Tapioca's CLI applies this through its RBS rewriter before loading custom compilers. -Tapioca::Dsl::Compiler.extend(T::Generic) - require "abstract_command" require "abstract_subcommand" require "sorbet/tapioca/compilers/args" diff --git a/Library/Homebrew/test/sorbet/tapioca/config_spec.rb b/Library/Homebrew/test/sorbet/tapioca/config_spec.rb index 493e46be19b5f..80721b630646e 100644 --- a/Library/Homebrew/test/sorbet/tapioca/config_spec.rb +++ b/Library/Homebrew/test/sorbet/tapioca/config_spec.rb @@ -4,9 +4,6 @@ require "bundler" require "tapioca/dsl" -# Tapioca's CLI applies this through its RBS rewriter before loading custom compilers. -Tapioca::Dsl::Compiler.extend(T::Generic) - require "sorbet/tapioca/compilers/cask/config" require "yaml"