diff --git a/.licenses/bundler/rubocop.dep.yml b/.licenses/bundler/rubocop.dep.yml index ea0a87b40672b..df50883b80f63 100644 --- a/.licenses/bundler/rubocop.dep.yml +++ b/.licenses/bundler/rubocop.dep.yml @@ -1,6 +1,6 @@ --- name: rubocop -version: 1.87.0 +version: 1.88.0 type: bundler summary: Automatic Ruby code style checking tool. homepage: https://github.com/rubocop/rubocop diff --git a/.licenses/bundler/sorbet-runtime.dep.yml b/.licenses/bundler/sorbet-runtime.dep.yml index 0eb7c5a09af04..bf09955062946 100644 --- a/.licenses/bundler/sorbet-runtime.dep.yml +++ b/.licenses/bundler/sorbet-runtime.dep.yml @@ -1,6 +1,6 @@ --- name: sorbet-runtime -version: 0.6.13296 +version: 0.6.13308 type: bundler summary: Sorbet runtime homepage: https://sorbet.org diff --git a/.licenses/bundler/sorbet-static-and-runtime.dep.yml b/.licenses/bundler/sorbet-static-and-runtime.dep.yml index 411cadfde58f2..64cbb60e665e6 100644 --- a/.licenses/bundler/sorbet-static-and-runtime.dep.yml +++ b/.licenses/bundler/sorbet-static-and-runtime.dep.yml @@ -1,6 +1,6 @@ --- name: sorbet-static-and-runtime -version: 0.6.13296 +version: 0.6.13308 type: bundler summary: A Typechecker for Ruby homepage: https://sorbet.org diff --git a/.licenses/bundler/sorbet-static.dep.yml b/.licenses/bundler/sorbet-static.dep.yml index 033d28fcb7e58..8d2c1f91cafd2 100644 --- a/.licenses/bundler/sorbet-static.dep.yml +++ b/.licenses/bundler/sorbet-static.dep.yml @@ -1,6 +1,6 @@ --- name: sorbet-static -version: 0.6.13296 +version: 0.6.13308 type: bundler summary: A Typechecker for Ruby homepage: https://sorbet.org diff --git a/.licenses/bundler/sorbet.dep.yml b/.licenses/bundler/sorbet.dep.yml index 83cb2b179826e..3ccd1bc07be12 100644 --- a/.licenses/bundler/sorbet.dep.yml +++ b/.licenses/bundler/sorbet.dep.yml @@ -1,6 +1,6 @@ --- name: sorbet -version: 0.6.13296 +version: 0.6.13308 type: bundler summary: A Typechecker for Ruby homepage: https://sorbet.org diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index c2c675fef3cc7..cf441fb888b9c 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -19,7 +19,7 @@ GEM erubi (1.13.1) hana (1.3.7) io-console (0.8.2) - json (2.19.9) + json (2.20.0) json_schemer (2.5.0) bigdecimal hana (~> 1.3) @@ -89,7 +89,7 @@ GEM rspec-support (3.13.7) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.87.0) + rubocop (1.88.0) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -140,15 +140,15 @@ GEM simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) simpleidn (0.2.3) - sorbet (0.6.13296) - sorbet-static (= 0.6.13296) - sorbet-runtime (0.6.13296) - sorbet-static (0.6.13296-aarch64-linux) - sorbet-static (0.6.13296-universal-darwin) - sorbet-static (0.6.13296-x86_64-linux) - sorbet-static-and-runtime (0.6.13296) - sorbet (= 0.6.13296) - sorbet-runtime (= 0.6.13296) + sorbet (0.6.13308) + sorbet-static (= 0.6.13308) + sorbet-runtime (0.6.13308) + sorbet-static (0.6.13308-aarch64-linux) + sorbet-static (0.6.13308-universal-darwin) + sorbet-static (0.6.13308-x86_64-linux) + sorbet-static-and-runtime (0.6.13308) + sorbet (= 0.6.13308) + sorbet-runtime (= 0.6.13308) spoom (1.7.16) erubi (>= 1.10.0) prism (>= 0.28.0) diff --git a/Library/Homebrew/cmd/update_report/reporter.rb b/Library/Homebrew/cmd/update_report/reporter.rb index b8b2d0bd95ac5..cc255daec80a8 100644 --- a/Library/Homebrew/cmd/update_report/reporter.rb +++ b/Library/Homebrew/cmd/update_report/reporter.rb @@ -253,7 +253,7 @@ def migrate_tap_migration ohai "Installing #{new_name}..." begin - system HOMEBREW_BREW_FILE, "install", "--overwrite", new_full_name + system HOMEBREW_BREW_FILE.to_s, "install", "--overwrite", new_full_name # Rescue any possible exception types. rescue Exception => e # rubocop:disable Lint/RescueException if Homebrew::EnvConfig.developer? @@ -281,11 +281,11 @@ def migrate_tap_migration if new_tap.installed? && (HOMEBREW_PREFIX/"Caskroom").directory? ohai migration_message ohai "brew unlink #{name}" - system HOMEBREW_BREW_FILE, "unlink", name + system HOMEBREW_BREW_FILE.to_s, "unlink", name ohai "brew cleanup" - system HOMEBREW_BREW_FILE, "cleanup" + system HOMEBREW_BREW_FILE.to_s, "cleanup" ohai "brew install --cask #{new_full_name}" - system HOMEBREW_BREW_FILE, "install", "--cask", new_full_name + system HOMEBREW_BREW_FILE.to_s, "install", "--cask", new_full_name ohai migration_message, <<~EOS The existing keg has been unlinked. Please uninstall the formula when convenient by running: diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index c7ee2f16fde6e..b2887294d68db 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -519,7 +519,7 @@ def run_cask_audit(cask, old_contents, audit_exceptions = []) if args.no_audit? ohai "Skipping `brew audit`" else - system HOMEBREW_BREW_FILE, "audit", "--cask", "--online", cask.full_name, + system HOMEBREW_BREW_FILE.to_s, "audit", "--cask", "--online", cask.full_name, "--except=#{audit_exceptions.join(",")}" failed_audit = !$CHILD_STATUS.success? end @@ -549,7 +549,7 @@ def run_cask_style(cask, old_contents) if args.no_style? ohai "Skipping `brew style --fix`" else - system HOMEBREW_BREW_FILE, "style", "--fix", sourcefile_path.to_s + system HOMEBREW_BREW_FILE.to_s, "style", "--fix", sourcefile_path.to_s failed_style = !$CHILD_STATUS.success? end return unless failed_style diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index cb9bc6fc02890..e3ec86c77a6ad 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -812,10 +812,10 @@ def run_audit(formula, alias_rename, skip_synced_versions: false) if args.no_audit? ohai "Skipping `brew audit`" elsif audit_args.present? - system HOMEBREW_BREW_FILE, "audit", *audit_args, formula.full_name + system HOMEBREW_BREW_FILE.to_s, "audit", *audit_args, formula.full_name failed_audit = !$CHILD_STATUS.success? else - system HOMEBREW_BREW_FILE, "audit", formula.full_name + system HOMEBREW_BREW_FILE.to_s, "audit", formula.full_name failed_audit = !$CHILD_STATUS.success? end failed_audit diff --git a/Library/Homebrew/extend/os/linux/sandbox.rb b/Library/Homebrew/extend/os/linux/sandbox.rb index de8927e1abcee..579eb52e1b299 100644 --- a/Library/Homebrew/extend/os/linux/sandbox.rb +++ b/Library/Homebrew/extend/os/linux/sandbox.rb @@ -252,7 +252,7 @@ def configure! end ohai "Configuring Bubblewrap..." - command = [HOMEBREW_BREW_FILE, "setup-sandbox"] + command = [HOMEBREW_BREW_FILE.to_s, "setup-sandbox"] command.unshift("sudo") unless Process.euid.zero? raise ErrorDuringExecution.new(command, status: $CHILD_STATUS || 1) unless system(*command) diff --git a/Library/Homebrew/homebrew.rb b/Library/Homebrew/homebrew.rb index 37a15829625f9..067c1bdd58663 100644 --- a/Library/Homebrew/homebrew.rb +++ b/Library/Homebrew/homebrew.rb @@ -68,7 +68,7 @@ def self._system(cmd, argv0 = nil, *args, **options, &_block) def self.system(cmd, argv0 = nil, *args, **options) if verbose? out = (options[:out] == :err) ? $stderr : $stdout - out.puts "#{cmd} #{args * " "}".gsub(RUBY_PATH, "ruby") + out.puts "#{cmd} #{args * " "}".gsub(RUBY_PATH.to_s, "ruby") .gsub($LOAD_PATH.join(File::PATH_SEPARATOR).to_s, "$LOAD_PATH") end _system(cmd, argv0, *args, **options) diff --git a/Library/Homebrew/sorbet/rbi/gems/rubocop@1.87.0.rbi b/Library/Homebrew/sorbet/rbi/gems/rubocop@1.88.0.rbi similarity index 99% rename from Library/Homebrew/sorbet/rbi/gems/rubocop@1.87.0.rbi rename to Library/Homebrew/sorbet/rbi/gems/rubocop@1.88.0.rbi index 04a86302a80a3..5a3af566f92aa 100644 --- a/Library/Homebrew/sorbet/rbi/gems/rubocop@1.87.0.rbi +++ b/Library/Homebrew/sorbet/rbi/gems/rubocop@1.88.0.rbi @@ -843,6 +843,7 @@ class RuboCop::Cop::Base def file_name_matches_any?(file, parameter, default_result); end def find_message(range, message); end def find_severity(_range, severity); end + def matches_absolute_include_pattern?(patterns, file); end def range_for_original(range); end def range_from_node_or_range(node_or_range); end def reset_investigation; end @@ -1492,8 +1493,6 @@ RuboCop::Cop::Lint::DataDefineOverride::MSG = T.let(T.unsafe(nil), String) RuboCop::Cop::Lint::DataDefineOverride::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array) -RuboCop::Cop::Lint::Debugger::BLOCK_TYPES = T.let(T.unsafe(nil), Array) - RuboCop::Cop::Lint::Debugger::MSG = T.let(T.unsafe(nil), String) RuboCop::Cop::Lint::DeprecatedClassMethods::DIR_ENV_FILE_CONSTANTS = T.let(T.unsafe(nil), Array) @@ -1860,6 +1859,8 @@ RuboCop::Cop::Lint::RedundantWithObject::MSG_WITH_OBJECT = T.let(T.unsafe(nil), RuboCop::Cop::Lint::RefinementImportMethods::MSG = T.let(T.unsafe(nil), String) +RuboCop::Cop::Lint::RefinementImportMethods::MSG_REMOVED = T.let(T.unsafe(nil), String) + RuboCop::Cop::Lint::RefinementImportMethods::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array) RuboCop::Cop::Lint::RegexpAsCondition::MSG = T.let(T.unsafe(nil), String) diff --git a/Library/Homebrew/test/rubocop_spec.rb b/Library/Homebrew/test/rubocop_spec.rb index b174475d73e48..20ebd9dbc733c 100644 --- a/Library/Homebrew/test/rubocop_spec.rb +++ b/Library/Homebrew/test/rubocop_spec.rb @@ -20,7 +20,7 @@ end it "loads all Formula cops without errors" do - stdout, stderr, status = Open3.capture3(RUBY_PATH, "-W0", "-S", "rubocop", TEST_FIXTURE_DIR/"testball.rb") + stdout, stderr, status = Open3.capture3(RUBY_PATH.to_s, "-W0", "-S", "rubocop", TEST_FIXTURE_DIR/"testball.rb") expect(stderr).to be_empty expect(stdout).to include("no offenses detected") expect(status).to be_a_success diff --git a/Library/Homebrew/test/sandbox_linux_spec.rb b/Library/Homebrew/test/sandbox_linux_spec.rb index 70ed7bdf7b12c..60b94f8b587bb 100644 --- a/Library/Homebrew/test/sandbox_linux_spec.rb +++ b/Library/Homebrew/test/sandbox_linux_spec.rb @@ -214,7 +214,7 @@ def executable_candidate_paths = test_executable_candidate_paths expect(sandbox_class).not_to receive(:ensure_sandbox_installed!) expect(sandbox_class).to receive(:ohai).with("Configuring Bubblewrap...").ordered expect(sandbox_class).to receive(:system) - .with("sudo", HOMEBREW_BREW_FILE, "setup-sandbox").and_return(true).ordered + .with("sudo", HOMEBREW_BREW_FILE.to_s, "setup-sandbox").and_return(true).ordered sandbox_class.configure! end @@ -237,7 +237,7 @@ def executable_candidate_paths = test_executable_candidate_paths .with(install_from_tests: true) expect(sandbox_class).to receive(:ohai).with("Configuring Bubblewrap...").ordered expect(sandbox_class).to receive(:system) - .with(HOMEBREW_BREW_FILE, "setup-sandbox").and_return(true).ordered + .with(HOMEBREW_BREW_FILE.to_s, "setup-sandbox").and_return(true).ordered sandbox_class.configure! end @@ -247,7 +247,7 @@ def executable_candidate_paths = test_executable_candidate_paths allow(Process).to receive(:euid).and_return(0) allow(sandbox_class).to receive(:ohai) expect(sandbox_class).to receive(:system) - .with(HOMEBREW_BREW_FILE, "setup-sandbox").and_return(false) + .with(HOMEBREW_BREW_FILE.to_s, "setup-sandbox").and_return(false) expect { sandbox_class.configure! }.to raise_error(ErrorDuringExecution) end diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index 456e7af362c7b..e3b30f57e6605 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -53,8 +53,8 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/hana-1.3.7/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/io-console-0.8.2") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/io-console-0.8.2/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/json-2.19.9") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json-2.19.9/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/json-2.20.0") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json-2.20.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/regexp_parser-2.12.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simpleidn-0.2.3/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json_schemer-2.5.0/lib") @@ -95,14 +95,14 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-3.13.2/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-github-3.0.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-retry-0.6.2/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-runtime-0.6.13296/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-runtime-0.6.13308/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-sorbet-1.9.2/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec_junit_formatter-0.6.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-ast-1.49.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-progressbar-1.13.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-emoji-4.2.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-3.2.0/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.87.0/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.88.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-md-2.0.4/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.26.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-3.10.2/lib") @@ -116,9 +116,9 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov_json_formatter-0.1.4/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-0.22.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-cobertura-3.2.0/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.6.13296-universal-darwin/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-0.6.13296/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-and-runtime-0.6.13296/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.6.13308-universal-darwin/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-0.6.13308/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-and-runtime-0.6.13308/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/thor-1.5.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/spoom-1.7.16/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/stackprof-0.2.28") diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_set.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_set.rb deleted file mode 100644 index ec77601278900..0000000000000 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_set.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true -# typed: true - -module T::Types - class TypedSet < TypedEnumerable - def underlying_class - Set - end - - # overrides Base - def name - "T::Set[#{type.name}]" - end - - # overrides Base - def recursively_valid?(obj) - return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set - return false unless Object.const_defined?(:Set) # Set is not loaded yet - obj.is_a?(Set) && super - end - - # overrides Base - def valid?(obj) - return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set - return false unless Object.const_defined?(:Set) # Set is not loaded yet - obj.is_a?(Set) - end - - def new(...) - # Fine for this to blow up, because hopefully if they're trying to make a - # Set, they don't mind putting (or already have put) a `require 'set'` in - # their program directly. - Set.new(...) - end - - class Untyped < TypedSet - def initialize - super(T::Types::Untyped::Private::INSTANCE) - end - - def valid?(obj) - return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set - return false unless Object.const_defined?(:Set) # Set is not loaded yet - obj.is_a?(Set) - end - end - end -end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/sorbet-runtime.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/sorbet-runtime.rb similarity index 95% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/sorbet-runtime.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/sorbet-runtime.rb index 524c81b91eff7..8661390e9d081 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/sorbet-runtime.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/sorbet-runtime.rb @@ -51,7 +51,6 @@ module T::Private::Types; end require_relative 'types/types/typed_enumerator' require_relative 'types/types/typed_enumerator_chain' require_relative 'types/types/typed_enumerator_lazy' -require_relative 'types/types/typed_hash' require_relative 'types/types/typed_range' require_relative 'types/types/typed_set' require_relative 'types/types/union' @@ -87,6 +86,10 @@ module T::Private::Types; end require_relative 'types/boolean' # Depends on types/utils +# typed_hash must load after untyped + utils so TypedHash::Untyped::Private::INSTANCE +# (a frozen, shared T::Hash[T.untyped, T.untyped]) can be built at load time, the same +# way TypedArray::Untyped::Private::INSTANCE is. +require_relative 'types/types/typed_hash' require_relative 'types/types/typed_array' require_relative 'types/types/typed_module' require_relative 'types/types/typed_class' diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/_types.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/_types.rb similarity index 90% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/_types.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/_types.rb index 08390db18b512..6335db1bb0c8c 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/_types.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/_types.rb @@ -134,6 +134,18 @@ def self.type_parameter(name) def self.cast(value, type, checked: true) return value unless checked + # Happy paths for the two dominant type shapes at inline-cast sites, + # duplicated from Private::Casts.cast to skip its call frame: Module + # literals (e.g. `T.cast(x, Foo)`) and the SimplePairUnion that + # `T.nilable(SomeModule)` produces. Failures and other type shapes take + # the full path below. + case type + when ::Module + return value if value.is_a?(type) + when T::Private::Types::SimplePairUnion + return value if type.valid?(value) + end + Private::Casts.cast(value, type, "T.cast") end @@ -149,6 +161,14 @@ def self.cast(value, type, checked: true) def self.let(value, type, checked: true) return value unless checked + # Happy paths for Module literals and T.nilable; see T.cast. + case type + when ::Module + return value if value.is_a?(type) + when T::Private::Types::SimplePairUnion + return value if type.valid?(value) + end + Private::Casts.cast(value, type, "T.let") end @@ -168,6 +188,14 @@ def self.let(value, type, checked: true) def self.bind(value, type, checked: true) return value unless checked + # Happy paths for Module literals and T.nilable; see T.cast. + case type + when ::Module + return value if value.is_a?(type) + when T::Private::Types::SimplePairUnion + return value if type.valid?(value) + end + Private::Casts.cast(value, type, "T.bind") end @@ -178,6 +206,14 @@ def self.bind(value, type, checked: true) def self.assert_type!(value, type, checked: true) return value unless checked + # Happy paths for Module literals and T.nilable; see T.cast. + case type + when ::Module + return value if value.is_a?(type) + when T::Private::Types::SimplePairUnion + return value if type.valid?(value) + end + Private::Casts.cast(value, type, "T.assert_type!") end @@ -293,7 +329,7 @@ def self.[](type) module Hash def self.[](keys, values) if keys.is_a?(T::Types::Untyped) && values.is_a?(T::Types::Untyped) - T::Types::TypedHash::Untyped.new + T::Types::TypedHash::Untyped::Private::INSTANCE else T::Types::TypedHash.new(keys: keys, values: values) end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/abstract_utils.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/abstract_utils.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/abstract_utils.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/abstract_utils.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/boolean.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/boolean.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/boolean.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/boolean.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/compatibility_patches.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/compatibility_patches.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/compatibility_patches.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/compatibility_patches.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/configuration.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/configuration.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/configuration.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/configuration.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/def_mods.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/def_mods.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/def_mods.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/def_mods.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/enum.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/enum.rb similarity index 80% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/enum.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/enum.rb index 4b74074cb81f8..000553b819d5b 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/enum.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/enum.rb @@ -48,18 +48,22 @@ class T::Enum private_constant :SerializedVal ### Enum class methods ### - sig { returns(T::Array[T.attached_class]) } + # WithoutRuntime on the hot accessors below installs no method wrapper at all + # (not even the one-time wrap a `checked(:never)` sig still pays on first + # call). Their bodies are type-safe by construction, so the wrapper validated + # nothing useful; Sorbet still reads these sigs statically. The + # override/overridable annotations remain as static-only signal. + T::Sig::WithoutRuntime.sig { returns(T::Array[T.attached_class]) } def self.values if @values.nil? - raise "Attempting to access values of #{self.class} before it has been initialized." \ - " Enums are not initialized until the 'enums do' block they are defined in has finished running." + raise(UNBOUND_VALUES_MESSAGE % self.class) end @values end # This exists for compatibility with the interface of `Hash` & mostly to support # the HashEachMethods Rubocop. - sig { params(blk: T.nilable(T.proc.params(arg0: T.attached_class).void)).returns(T.any(T::Enumerator[T.attached_class], T::Array[T.attached_class])) } + T::Sig::WithoutRuntime.sig { params(blk: T.nilable(T.proc.params(arg0: T.attached_class).void)).returns(T.any(T::Enumerator[T.attached_class], T::Array[T.attached_class])) } def self.each_value(&blk) if blk values.each(&blk) @@ -72,11 +76,10 @@ def self.each_value(&blk) # # Note: It would have been nice to make this method final before people started overriding it. # Note: Failed CriticalMethodsNoRuntimeTypingTest - sig { params(serialized_val: SerializedVal).returns(T.nilable(T.attached_class)).checked(:never) } + T::Sig::WithoutRuntime.sig { params(serialized_val: SerializedVal).returns(T.nilable(T.attached_class)) } def self.try_deserialize(serialized_val) if @mapping.nil? - raise "Attempting to access serialization map of #{self.class} before it has been initialized." \ - " Enums are not initialized until the 'enums do' block they are defined in has finished running." + raise(UNBOUND_SERIALIZATION_MAP_MESSAGE % self.class) end @mapping[serialized_val] end @@ -88,7 +91,7 @@ def self.try_deserialize(serialized_val) # # @return [self] # @raise [KeyError] if serialized value does not match any instance. - sig { overridable.params(serialized_val: SerializedVal).returns(T.attached_class).checked(:never) } + T::Sig::WithoutRuntime.sig { overridable.params(serialized_val: SerializedVal).returns(T.attached_class) } def self.from_serialized(serialized_val) res = try_deserialize(serialized_val) if res.nil? @@ -99,17 +102,16 @@ def self.from_serialized(serialized_val) # Note: It would have been nice to make this method final before people started overriding it. # @return [Boolean] Does the given serialized value correspond with any of this enum's values. - sig { overridable.params(serialized_val: SerializedVal).returns(T::Boolean).checked(:never) } + T::Sig::WithoutRuntime.sig { overridable.params(serialized_val: SerializedVal).returns(T::Boolean) } def self.has_serialized?(serialized_val) if @mapping.nil? - raise "Attempting to access serialization map of #{self.class} before it has been initialized." \ - " Enums are not initialized until the 'enums do' block they are defined in has finished running." + raise(UNBOUND_SERIALIZATION_MAP_MESSAGE % self.class) end @mapping.include?(serialized_val) end # Note: Failed CriticalMethodsNoRuntimeTypingTest - sig { override.params(instance: T.nilable(T::Enum)).returns(SerializedVal).checked(:never) } + T::Sig::WithoutRuntime.sig { override.params(instance: T.nilable(T::Enum)).returns(SerializedVal) } def self.serialize(instance) # This is needed otherwise if a Chalk::ODM::Document with a property of the shape # T::Hash[T.nilable(MyEnum), Integer] and a value that looks like {nil => 0} is @@ -126,7 +128,7 @@ def self.serialize(instance) end # Note: Failed CriticalMethodsNoRuntimeTypingTest - sig { override.params(mongo_value: SerializedVal).returns(T.attached_class).checked(:never) } + T::Sig::WithoutRuntime.sig { override.params(mongo_value: SerializedVal).returns(T.attached_class) } def self.deserialize(mongo_value) if self == T::Enum raise "Cannot call T::Enum.deserialize directly. You must call on a specific child class." @@ -146,10 +148,28 @@ def clone self end + # Format strings (`%s` is the class) for the "accessed before initialized" + # errors, so the various raise sites can't drift from each other. + UNBOUND_VALUE_MESSAGE = "Attempting to access Enum value on %s before it has been initialized." \ + " Enums are not initialized until the 'enums do' block they are defined in has finished running." + private_constant :UNBOUND_VALUE_MESSAGE + + UNBOUND_VALUES_MESSAGE = "Attempting to access values of %s before it has been initialized." \ + " Enums are not initialized until the 'enums do' block they are defined in has finished running." + private_constant :UNBOUND_VALUES_MESSAGE + + UNBOUND_SERIALIZATION_MAP_MESSAGE = "Attempting to access serialization map of %s before it has been initialized." \ + " Enums are not initialized until the 'enums do' block they are defined in has finished running." + private_constant :UNBOUND_SERIALIZATION_MAP_MESSAGE + # Note: Failed CriticalMethodsNoRuntimeTypingTest - sig { returns(SerializedVal).checked(:never) } + T::Sig::WithoutRuntime.sig { returns(SerializedVal) } def serialize - assert_bound! + # Same check and message as assert_bound!, open-coded to avoid the extra + # method frame on this hot path. + if @const_name.nil? + raise(UNBOUND_VALUE_MESSAGE % self.class) + end @serialized_val end @@ -165,17 +185,20 @@ def as_json(*args) serialized_val.as_json(*args) end - sig { returns(String) } + # `to_s` keeps delegating to `inspect` rather than `alias_method :to_s, + # :inspect` so a subclass that overrides `inspect` still has its `to_s` + # reflect the override. + T::Sig::WithoutRuntime.sig { returns(String) } def to_s inspect end - sig { returns(String) } + T::Sig::WithoutRuntime.sig { returns(String) } def inspect "#<#{self.class.name}::#{@const_name || '__UNINITIALIZED__'}>" end - sig { params(other: BasicObject).returns(T.nilable(Integer)) } + T::Sig::WithoutRuntime.sig { params(other: BasicObject).returns(T.nilable(Integer)) } def <=>(other) case other when self.class @@ -292,11 +315,10 @@ def initialize(serialized_val=UNSET) self.class._register_instance(self) end - sig { returns(NilClass).checked(:never) } + T::Sig::WithoutRuntime.sig { returns(NilClass) } private def assert_bound! if @const_name.nil? - raise "Attempting to access Enum value on #{self.class} before it has been initialized." \ - " Enums are not initialized until the 'enums do' block they are defined in has finished running." + raise(UNBOUND_VALUE_MESSAGE % self.class) end end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/generic.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/generic.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/generic.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/generic.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/helpers.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/helpers.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/helpers.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/helpers.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/data.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/data.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/data.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/data.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/declare.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/declare.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/declare.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/declare.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/hooks.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/hooks.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/hooks.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/hooks.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/validate.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/validate.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/abstract/validate.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/abstract/validate.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/caller_utils.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/caller_utils.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/caller_utils.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/caller_utils.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/casts.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/casts.rb similarity index 56% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/casts.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/casts.rb index f664500f8251c..f87f547f95aa2 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/casts.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/casts.rb @@ -5,8 +5,29 @@ module T::Private module Casts def self.cast(value, type, cast_method) begin - coerced_type = T::Utils::Private.coerce_and_check_module_types(type, value, true) - return value unless coerced_type + # Every caller (T.cast/let/bind/assert_type! in _types.rb) inlines the + # value check for the two dominant shapes -- a Module literal and the + # SimplePairUnion that `T.nilable(SomeModule)` produces -- and only + # falls through to here when that check already failed. So skip + # straight to coercing: re-checking `value.is_a?(type)` / + # `type.valid?(value)` here would always be false. + case type + when ::Module + coerced_type = T::Types::Simple::Private::Pool.type_for_module(type) + when T::Types::Base + # Mirrors the T::Types::Base branch of coerce_and_check_module_types, + # kept inline to avoid its call frame for every already-coerced type. + coerced_type = + case type + when T::Private::Types::TypeAlias + type.aliased_type + else + type + end + else + coerced_type = T::Utils::Private.coerce_and_check_module_types(type, value, true) + return value unless coerced_type + end error = coerced_type.error_message_for_obj(value) return value unless error diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/class_utils.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/class_utils.rb similarity index 67% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/class_utils.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/class_utils.rb index 2db67fa0a1eb9..ef8a4914bb091 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/class_utils.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/class_utils.rb @@ -44,9 +44,10 @@ def self.def_with_visibility(mod, name, visibility, method=nil, &block) end if block && block.arity < 0 && respond_to?(:ruby2_keywords, true) - m = instance_method(name) - has_rest = m.parameters.any? { |type, _| type == :rest } - has_keywords = m.parameters.any? { |type, _| %i[keyrest keyreq key].include?(type) } + # Fetch .parameters once: each call builds a fresh array. + parameters = instance_method(name).parameters + has_rest = parameters.any? { |kind, _| kind == :rest } + has_keywords = parameters.any? { |kind, _| kind == :keyrest || kind == :keyreq || kind == :key } ruby2_keywords(name) if has_rest && !has_keywords end end @@ -67,18 +68,23 @@ def self.replace_method(original_method, mod, name, &blk) original_visibility = visibility_method_name(mod, name) original_owner = original_method.owner - mod.ancestors.each do |ancestor| - break if ancestor == mod - if ancestor == original_owner - # If we get here, that means the method we're trying to replace exists on a *prepended* - # mixin, which means in order to supersede it, we'd need to create a method on a new - # module that we'd prepend before `ancestor`. The problem with that approach is there'd - # be no way to remove that new module after prepending it, so we'd be left with these - # empty anonymous modules in the ancestor chain after calling `restore`. - # - # That's not necessarily a deal breaker, but for now, we're keeping it as unsupported. - raise "You're trying to replace `#{name}` on `#{mod}`, but that method exists in a " \ - "prepended module (#{ancestor}), which we don't currently support." + # In the common case the method is owned by `mod` itself, in which case the loop below + # would always `break` before the raise could match (`mod` precedes any non-prepended + # ancestor in its own ancestor chain), so skip computing `mod.ancestors` entirely. + if original_owner != mod + mod.ancestors.each do |ancestor| + break if ancestor == mod + if ancestor == original_owner + # If we get here, that means the method we're trying to replace exists on a *prepended* + # mixin, which means in order to supersede it, we'd need to create a method on a new + # module that we'd prepend before `ancestor`. The problem with that approach is there'd + # be no way to remove that new module after prepending it, so we'd be left with these + # empty anonymous modules in the ancestor chain after calling `restore`. + # + # That's not necessarily a deal breaker, but for now, we're keeping it as unsupported. + raise "You're trying to replace `#{name}` on `#{mod}`, but that method exists in a " \ + "prepended module (#{ancestor}), which we don't currently support." + end end end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/decl_state.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/decl_state.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/decl_state.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/decl_state.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/final.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/final.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/final.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/final.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/_methods.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/_methods.rb similarity index 99% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/_methods.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/_methods.rb index b4be841095d7f..c2bdcff3290c5 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/_methods.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/_methods.rb @@ -299,11 +299,14 @@ def self.add_module_with_final_method(mod, method_name) # Only public because it needs to get called below inside the replace_method blocks below. def self._on_method_added(hook_mod, mod, method_name) - if T::Private::DeclState.current.skip_on_method_added + # The thread-local DeclState object is stable for the duration of this call + # (nothing reassigns `DeclState.current=`), so fetch it once. + decl_state = T::Private::DeclState.current + if decl_state.skip_on_method_added return end - current_declaration = T::Private::DeclState.current.consume! + current_declaration = decl_state.consume! if T::Private::Final.final_module?(mod) && (current_declaration.nil? || !current_declaration.final) raise "#{mod} was declared as final but its method `#{method_name}` was not declared as final" diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/call_validation.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/call_validation.rb similarity index 82% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/call_validation.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/call_validation.rb index a5a6d14cba9b0..87ae59d44adea 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/call_validation.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/call_validation.rb @@ -72,8 +72,16 @@ def #{method_name}(...) end def self.create_validator_method(mod, original_method, method_sig, original_visibility) + # Wrapper-shape decisions must read the parameters of the method actually being wrapped, not + # `method_sig.parameters` (captured at sig-build time). The two diverge when a sig'd method is + # re-wrapped over a different implementation: a stub redefined as `def m(*args, **kwargs, &blk)` + # then re-validated against the original fixed-arity sig would otherwise pick a fixed-arity wrapper, + # which binds args to named positionals and forwards them without the `ruby2_keywords` flag, turning + # a trailing `key: val` into a positional hash. Reading from `original_method` costs one array per + # wrap, off the hot path. + parameters = original_method.parameters has_fixed_arity = method_sig.kwarg_types.empty? && method_sig.rest_type.nil? && method_sig.keyrest_type.nil? && - original_method.parameters.all? { |(kind, _name)| kind == :req || kind == :block } + parameters.all? { |(kind, _name)| kind == :req || kind == :block } # nil implies block_type.nil? # true implies !block_type.nil? and block_type.valid?(nil) @@ -83,6 +91,29 @@ def self.create_validator_method(mod, original_method, method_sig, original_visi ok_for_fast_path = has_fixed_arity && can_skip_block_type && !method_sig.bind && method_sig.arg_types.length < 5 && is_allowed_to_have_fast_path + # Like `ok_for_fast_path`, but for the specialized wrappers below, each of + # which supports exactly one extra call shape (kwargs, a required block, or + # optional positional args) on top of what the fast/medium wrappers support. + ok_for_specialized_path = !ok_for_fast_path && !method_sig.bind && method_sig.rest_type.nil? && + method_sig.keyrest_type.nil? && method_sig.arg_types.length < 5 && is_allowed_to_have_fast_path + + # Restricted to methods with no positional args. The kwargs wrapper's `|**kwargs, &blk|` declares a + # keyword-rest, which would capture a bare `key: val` hash that a method with a positional parameter + # expects to receive positionally, starving that parameter. All-kwargs methods have no such parameter, + # so the wrapper matches a direct call. (Most kwargs-shaped sigs take only kwargs.) + kwargs_path = ok_for_specialized_path && can_skip_block_type && !method_sig.kwarg_types.empty? && + method_sig.arg_types.empty? && + parameters.all? { |(kind, _name)| kind == :key || kind == :keyreq || kind == :block } + + required_block_path = ok_for_specialized_path && !can_skip_block_type && has_fixed_arity + + # At least one param is `:opt` here (otherwise `ok_for_fast_path` would hold). The wrapper forwards + # through a `ruby2_keywords`-flagged `|*args, &blk|` splat (see below), not named optional parameters: + # named params have no `*rest` for `def_with_visibility` to flag, so a trailing `key: val` that Ruby + # packs into an optional positional would lose the keyword flag the slow path preserves. + optional_args_path = ok_for_specialized_path && can_skip_block_type && method_sig.kwarg_types.empty? && + parameters.all? { |(kind, _name)| kind == :req || kind == :opt || kind == :block } + all_args_are_simple = ok_for_fast_path && method_sig.arg_types.all? { |_name, type| type.is_a?(T::Types::Simple) } effective_return_type = method_sig.effective_return_type @@ -115,6 +146,12 @@ def self.create_validator_method(mod, original_method, method_sig, original_visi create_validator_method_skip_return_medium(mod, original_method, method_sig, original_visibility) elsif ok_for_fast_path create_validator_method_medium(mod, original_method, method_sig, original_visibility) + elsif kwargs_path + create_validator_method_kwargs(mod, original_method, method_sig, original_visibility) + elsif required_block_path + create_validator_method_with_block(mod, original_method, method_sig, original_visibility) + elsif optional_args_path + create_validator_method_optional_args(mod, original_method, method_sig, original_visibility) elsif can_skip_block_type # The Ruby VM already validates that any block passed to a method # must be either `nil` or a `Proc` object, so there's no need to also diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/call_validation_2_7.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/call_validation_2_7.rb similarity index 58% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/call_validation_2_7.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/call_validation_2_7.rb index 50f8ef67ecf87..8e9f0cedaa96e 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/call_validation_2_7.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/call_validation_2_7.rb @@ -1726,4 +1726,1030 @@ def self.create_validator_procedure_medium4(mod, original_method, method_sig, or end end + def self.create_validator_method_kwargs(mod, original_method, method_sig, original_visibility) + return_type = method_sig.effective_return_type + return_type = nil if return_type.is_a?(T::Private::Types::Void) + create_validator_method_kwargs0(mod, original_method, method_sig, original_visibility, return_type, method_sig.kwarg_types) + end + + def self.create_validator_method_kwargs0(mod, original_method, method_sig, original_visibility, return_type, kwarg_types) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |**kwargs, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + # NOTE: like `validate_call`, we don't validate for missing or extra + # kwargs; the `bind_call` below takes care of that. + kwargs.each do |name, val| + type = kwarg_types[name] + next unless type + next if type.valid?(val) + CallValidation.report_error( + method_sig, + type.error_message_for_obj(val), + 'Parameter', + name, + type, + val, + caller_offset: 1 + ) + end + return_value = original_method.bind_call(self, **kwargs, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_with_block(mod, original_method, method_sig, original_visibility) + return_type = method_sig.effective_return_type + return_type = nil if return_type.is_a?(T::Private::Types::Void) + block_type = method_sig.block_type + # trampoline to reduce stack frame size + arg_types = method_sig.arg_types + case arg_types.length + when 0 + create_validator_method_with_block0(mod, original_method, method_sig, original_visibility, return_type, block_type) + when 1 + create_validator_method_with_block1(mod, original_method, method_sig, original_visibility, return_type, block_type, + arg_types[0][1]) + when 2 + create_validator_method_with_block2(mod, original_method, method_sig, original_visibility, return_type, block_type, + arg_types[0][1], + arg_types[1][1]) + when 3 + create_validator_method_with_block3(mod, original_method, method_sig, original_visibility, return_type, block_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1]) + when 4 + create_validator_method_with_block4(mod, original_method, method_sig, original_visibility, return_type, block_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1], + arg_types[3][1]) + else + raise 'should not happen' + end + end + + def self.create_validator_method_with_block0(mod, original_method, method_sig, original_visibility, return_type, block_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |&blk| + # This method is a manually sped-up version of more general code in `validate_call` + if blk.nil? + CallValidation.report_error( + method_sig, + block_type.error_message_for_obj(blk), + 'Block parameter', + method_sig.block_name, + block_type, + blk, + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_with_block1(mod, original_method, method_sig, original_visibility, return_type, block_type, arg0_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |arg0, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(arg0) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(arg0), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + arg0, + caller_offset: -1 + ) + end + if blk.nil? + CallValidation.report_error( + method_sig, + block_type.error_message_for_obj(blk), + 'Block parameter', + method_sig.block_name, + block_type, + blk, + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, arg0, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_with_block2(mod, original_method, method_sig, original_visibility, return_type, block_type, arg0_type, arg1_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |arg0, arg1, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(arg0) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(arg0), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + arg0, + caller_offset: -1 + ) + end + unless arg1_type.valid?(arg1) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(arg1), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + arg1, + caller_offset: -1 + ) + end + if blk.nil? + CallValidation.report_error( + method_sig, + block_type.error_message_for_obj(blk), + 'Block parameter', + method_sig.block_name, + block_type, + blk, + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, arg0, arg1, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_with_block3(mod, original_method, method_sig, original_visibility, return_type, block_type, arg0_type, arg1_type, arg2_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |arg0, arg1, arg2, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(arg0) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(arg0), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + arg0, + caller_offset: -1 + ) + end + unless arg1_type.valid?(arg1) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(arg1), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + arg1, + caller_offset: -1 + ) + end + unless arg2_type.valid?(arg2) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(arg2), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + arg2, + caller_offset: -1 + ) + end + if blk.nil? + CallValidation.report_error( + method_sig, + block_type.error_message_for_obj(blk), + 'Block parameter', + method_sig.block_name, + block_type, + blk, + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, arg0, arg1, arg2, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_with_block4(mod, original_method, method_sig, original_visibility, return_type, block_type, arg0_type, arg1_type, arg2_type, arg3_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |arg0, arg1, arg2, arg3, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(arg0) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(arg0), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + arg0, + caller_offset: -1 + ) + end + unless arg1_type.valid?(arg1) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(arg1), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + arg1, + caller_offset: -1 + ) + end + unless arg2_type.valid?(arg2) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(arg2), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + arg2, + caller_offset: -1 + ) + end + unless arg3_type.valid?(arg3) + CallValidation.report_error( + method_sig, + method_sig.arg_types[3][1].error_message_for_obj(arg3), + 'Parameter', + method_sig.arg_types[3][0], + arg3_type, + arg3, + caller_offset: -1 + ) + end + if blk.nil? + CallValidation.report_error( + method_sig, + block_type.error_message_for_obj(blk), + 'Block parameter', + method_sig.block_name, + block_type, + blk, + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, arg0, arg1, arg2, arg3, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args(mod, original_method, method_sig, original_visibility) + return_type = method_sig.effective_return_type + return_type = nil if return_type.is_a?(T::Private::Types::Void) + # trampoline to reduce stack frame size + arg_types = method_sig.arg_types + case [method_sig.req_arg_count, arg_types.length] + when [0, 1] + create_validator_method_optional_args0_1(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1]) + when [0, 2] + create_validator_method_optional_args0_2(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1]) + when [1, 2] + create_validator_method_optional_args1_2(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1]) + when [0, 3] + create_validator_method_optional_args0_3(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1]) + when [1, 3] + create_validator_method_optional_args1_3(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1]) + when [2, 3] + create_validator_method_optional_args2_3(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1]) + when [0, 4] + create_validator_method_optional_args0_4(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1], + arg_types[3][1]) + when [1, 4] + create_validator_method_optional_args1_4(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1], + arg_types[3][1]) + when [2, 4] + create_validator_method_optional_args2_4(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1], + arg_types[3][1]) + when [3, 4] + create_validator_method_optional_args3_4(mod, original_method, method_sig, original_visibility, return_type, + arg_types[0][1], + arg_types[1][1], + arg_types[2][1], + arg_types[3][1]) + else + raise 'should not happen' + end + end + + def self.create_validator_method_optional_args0_1(mod, original_method, method_sig, original_visibility, return_type, arg0_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless args.empty? || arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args0_2(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless args.empty? || arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless args.length <= 1 || arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args1_2(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless args.length <= 1 || arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args0_3(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type, arg2_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless args.empty? || arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless args.length <= 1 || arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + unless args.length <= 2 || arg2_type.valid?(args[2]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(args[2]), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + args[2], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args1_3(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type, arg2_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless args.length <= 1 || arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + unless args.length <= 2 || arg2_type.valid?(args[2]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(args[2]), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + args[2], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args2_3(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type, arg2_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + unless args.length <= 2 || arg2_type.valid?(args[2]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(args[2]), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + args[2], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args0_4(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type, arg2_type, arg3_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless args.empty? || arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless args.length <= 1 || arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + unless args.length <= 2 || arg2_type.valid?(args[2]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(args[2]), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + args[2], + caller_offset: -1 + ) + end + unless args.length <= 3 || arg3_type.valid?(args[3]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[3][1].error_message_for_obj(args[3]), + 'Parameter', + method_sig.arg_types[3][0], + arg3_type, + args[3], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args1_4(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type, arg2_type, arg3_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless args.length <= 1 || arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + unless args.length <= 2 || arg2_type.valid?(args[2]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(args[2]), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + args[2], + caller_offset: -1 + ) + end + unless args.length <= 3 || arg3_type.valid?(args[3]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[3][1].error_message_for_obj(args[3]), + 'Parameter', + method_sig.arg_types[3][0], + arg3_type, + args[3], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args2_4(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type, arg2_type, arg3_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + unless args.length <= 2 || arg2_type.valid?(args[2]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(args[2]), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + args[2], + caller_offset: -1 + ) + end + unless args.length <= 3 || arg3_type.valid?(args[3]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[3][1].error_message_for_obj(args[3]), + 'Parameter', + method_sig.arg_types[3][0], + arg3_type, + args[3], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + + def self.create_validator_method_optional_args3_4(mod, original_method, method_sig, original_visibility, return_type, arg0_type, arg1_type, arg2_type, arg3_type) + T::Private::ClassUtils.def_with_visibility(mod, method_sig.method_name, original_visibility) do |*args, &blk| + # This method is a manually sped-up version of more general code in `validate_call` + unless arg0_type.valid?(args[0]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[0][1].error_message_for_obj(args[0]), + 'Parameter', + method_sig.arg_types[0][0], + arg0_type, + args[0], + caller_offset: -1 + ) + end + unless arg1_type.valid?(args[1]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[1][1].error_message_for_obj(args[1]), + 'Parameter', + method_sig.arg_types[1][0], + arg1_type, + args[1], + caller_offset: -1 + ) + end + unless arg2_type.valid?(args[2]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[2][1].error_message_for_obj(args[2]), + 'Parameter', + method_sig.arg_types[2][0], + arg2_type, + args[2], + caller_offset: -1 + ) + end + unless args.length <= 3 || arg3_type.valid?(args[3]) + CallValidation.report_error( + method_sig, + method_sig.arg_types[3][1].error_message_for_obj(args[3]), + 'Parameter', + method_sig.arg_types[3][0], + arg3_type, + args[3], + caller_offset: -1 + ) + end + return_value = original_method.bind_call(self, *args, &blk) + if return_type.nil? + T::Private::Types::Void::VOID + else + unless return_type.valid?(return_value) + message = method_sig.effective_return_type.error_message_for_obj(return_value) + if message + CallValidation.report_error( + method_sig, + message, + 'Return value', + nil, + method_sig.effective_return_type, + return_value, + caller_offset: -1 + ) + end + end + return_value + end + end + end + end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/decl_builder.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/decl_builder.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/decl_builder.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/decl_builder.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/modes.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/modes.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/modes.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/modes.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/signature.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/signature.rb similarity index 97% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/signature.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/signature.rb index fdace9af2747d..3d6a29d771f3e 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/signature.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/signature.rb @@ -80,7 +80,8 @@ def initialize(method:, method_name:, raw_arg_types:, raw_return_type:, bind:, m # If sig params are declared but there is a single parameter with a missing name # **and** the method ends with a "=", assume it is a writer method generated # by attr_writer or attr_accessor - writer_method = !(raw_arg_types.size == 1 && raw_arg_types.key?(nil)) && parameters == UNNAMED_REQUIRED_PARAMETERS && method_name[-1] == "=" + # (Checks are ordered so that the common, non-writer case short-circuits without allocating.) + writer_method = method_name.end_with?("=") && parameters == UNNAMED_REQUIRED_PARAMETERS && !(raw_arg_types.size == 1 && raw_arg_types.key?(nil)) # For writer methods, map the single parameter to the method name without the "=" at the end parameters = [[:req, method_name[0...-1].to_sym]] if writer_method is_name_missing = parameters.any? { |_, name| !raw_arg_types.key?(name) } diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/signature_validation.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/signature_validation.rb similarity index 88% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/signature_validation.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/signature_validation.rb index 60771879b078d..bb5842484d31a 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/methods/signature_validation.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/methods/signature_validation.rb @@ -67,7 +67,9 @@ def self.validate(signature) super_method = signature.method.super_method if super_method && super_method.owner != signature.method.owner - Methods.maybe_run_sig_block_for_method(super_method) + # No need to run the sig block for super_method explicitly: + # signature_for_method forces it internally (via signature_for_key -> + # maybe_run_sig_block_for_key on the identical registry key). super_signature = Methods.signature_for_method(super_method) # If the super_method has any kwargs we can't build a @@ -200,7 +202,10 @@ def self.validate_override_shape(signature, super_signature) "#{base_override_loc_str(signature, super_signature)}" end - if signature.keyrest_type.nil? + # The kwarg_types.empty? guard is an exact implication (an empty super + # kwarg set can never yield missing kwargs) that skips two fresh + # `.keys` arrays plus the Array#- for the common kwarg-free method. + if signature.keyrest_type.nil? && !super_signature.kwarg_types.empty? # O(nm), but n and m are tiny here missing_kwargs = super_signature.kwarg_names - signature.kwarg_names if !missing_kwargs.empty? @@ -216,12 +221,15 @@ def self.validate_override_shape(signature, super_signature) "#{base_override_loc_str(signature, super_signature)}" end - # O(nm), but n and m are tiny here - extra_req_kwargs = signature.req_kwarg_names - super_signature.req_kwarg_names - if !extra_req_kwargs.empty? - raise "Your definition of `#{method_name}` has extra required keyword arg(s) " \ - "#{extra_req_kwargs} relative to the method it #{mode_verb}, making it incompatible: " \ - "#{base_override_loc_str(signature, super_signature)}" + # Guard on the minuend: an empty req_kwarg_names can never yield extras. + if !signature.req_kwarg_names.empty? + # O(nm), but n and m are tiny here + extra_req_kwargs = signature.req_kwarg_names - super_signature.req_kwarg_names + if !extra_req_kwargs.empty? + raise "Your definition of `#{method_name}` has extra required keyword arg(s) " \ + "#{extra_req_kwargs} relative to the method it #{mode_verb}, making it incompatible: " \ + "#{base_override_loc_str(signature, super_signature)}" + end end if super_signature.block_name && !signature.block_name @@ -231,16 +239,33 @@ def self.validate_override_shape(signature, super_signature) end end + # Evaluation order matters: check_tests? must only run for a :tests-checked + # sig (it side-effectfully arms the @wrapped_tests_with_validation trapdoor + # in RuntimeLevels). + private_class_method def self.check_level_active?(sig) + sig.check_level == :always || (sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?) + end + def self.validate_override_types(signature, super_signature) return if signature.override_allow_incompatible == true return if super_signature.mode == Modes.untyped - return unless [signature, super_signature].all? do |sig| - sig.check_level == :always || (sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?) - end + return unless check_level_active?(signature) && check_level_active?(super_signature) mode_noun = super_signature.mode == Modes.abstract ? 'implementation' : 'override' # arg types must be contravariant - super_signature.arg_types.zip(signature.arg_types).each_with_index do |((_super_name, super_type), (name, type)), index| + # + # An index loop avoids allocating a pair array per positional arg. + # Iterating to super's length is deliberate: extra override positionals + # go unchecked, and when the override has a rest param and fewer named + # args than the base, the missing positions are checked as nil name/type. + super_arg_types = super_signature.arg_types + arg_types = signature.arg_types + index = 0 + while index < super_arg_types.length + super_type = super_arg_types.fetch(index)[1] + pair = arg_types[index] + name = pair && pair[0] + type = pair && pair[1] if !super_type.subtype_of?(type) raise "Incompatible type for arg ##{index + 1} (`#{name}`) in signature for #{mode_noun} of method " \ "`#{signature.method_name}`:\n" \ @@ -248,6 +273,7 @@ def self.validate_override_types(signature, super_signature) "* #{mode_noun.capitalize}: `#{type}` (in #{signature.method_desc})\n" \ "(The types must be contravariant.)" end + index += 1 end # kwarg types must be contravariant diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/mixins/mixins.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/mixins/mixins.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/mixins/mixins.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/mixins/mixins.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/retry.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/retry.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/retry.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/retry.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/runtime_levels.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/runtime_levels.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/runtime_levels.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/runtime_levels.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/sealed.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/sealed.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/sealed.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/sealed.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/not_typed.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/not_typed.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/not_typed.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/not_typed.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/simple_pair_union.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/simple_pair_union.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/simple_pair_union.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/simple_pair_union.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/string_holder.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/string_holder.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/string_holder.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/string_holder.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/type_alias.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/type_alias.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/type_alias.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/type_alias.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/void.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/void.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/private/types/void.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/private/types/void.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/_props.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/_props.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/_props.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/_props.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/constructor.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/constructor.rb similarity index 91% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/constructor.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/constructor.rb index ae7fa87a14d63..7e53ae4a3ba40 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/constructor.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/constructor.rb @@ -20,10 +20,10 @@ def construct_props_without_defaults(instance, hash) # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator # and therefore allocates for each entry. result = 0 - props_without_defaults&.each_pair do |p, setter_proc| + props_without_defaults&.each_pair do |p, bound_setter| begin val = hash[p] - instance.instance_exec(val, &setter_proc) + bound_setter.call(instance, val) if val || hash.key?(p) result += 1 end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/custom_type.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/custom_type.rb similarity index 88% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/custom_type.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/custom_type.rb index d680af98e71ee..4466ebbc241b1 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/custom_type.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/custom_type.rb @@ -62,9 +62,15 @@ def self.scalar_type?(val) # We don't need to check for val's included modules in # T::Configuration.scalar_types, because T::Configuration.scalar_types # are all classes. + # + # `name` rather than `to_s`: identical for real classes, but returns the + # cached frozen string (Ruby 3.2+) where to_s allocates per call. + # Anonymous classes yield nil, and `include?(nil)` is false (an + # anonymous class can never be a registered scalar type). + scalar_types = T::Configuration.scalar_types klass = val.class until klass.nil? - return true if T::Configuration.scalar_types.include?(klass.to_s) + return true if scalar_types.include?(klass.name) klass = klass.superclass end false diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/decorator.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/decorator.rb similarity index 90% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/decorator.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/decorator.rb index 4e82dc9a19286..c4e2db7aa22ac 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/decorator.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/decorator.rb @@ -71,7 +71,12 @@ def add_prop_definition(name, rules) raise ArgumentError.new("Attempted to redefine prop #{name.inspect} on class #{@class} that's already defined without specifying :override => true: #{prop_rules(name)}") end - @props = @props.merge(name => rules.freeze).freeze + # dup/store/freeze rather than @props.merge(name => rules.freeze).freeze: + # merge would allocate a temporary single-entry Hash and re-insert every + # existing entry. The published hash stays frozen between adds. + new_props = @props.dup + new_props[name] = rules.freeze + @props = new_props.freeze end # Heads up! @@ -126,7 +131,7 @@ def validate_prop_value(prop, val) # preexisting behavior). # # Note this path is NOT used by generated setters on instances, - # which are defined using `setter_proc` directly. + # which are defined using the 1-arity `:setter_proc` directly. # # checked(:never) - O(prop accesses) sig do @@ -140,7 +145,9 @@ def validate_prop_value(prop, val) .checked(:never) end def prop_set(instance, prop, val, rules=prop_rules(prop)) - instance.instance_exec(val, &rules.fetch(:setter_proc)) + # The 2-arity bound proc does the same validation/assignment as the + # 1-arity setter proc without instance_exec's per-call self-rebinding. + rules.fetch(:_bound_setter_proc).call(instance, val) end alias_method :set, :prop_set @@ -182,7 +189,7 @@ def prop_get(instance, prop, rules=prop_rules(prop)) if !val.nil? val elsif (d = rules[:ifunset]) - T::Props::Utils.deep_clone_object(d) + T::Props::Utils.deep_clone(d) else nil end @@ -421,11 +428,20 @@ def prop_defined(name, cls, rules={}) end end - setter_proc, value_validate_proc = T::Props::Private::SetterFactory.build_setter_proc(@class, name, rules) + setter_proc, value_validate_proc, bound_setter_proc = T::Props::Private::SetterFactory.build_setter_proc(@class, name, rules) setter_proc.freeze value_validate_proc.freeze - rules[:setter_proc] = setter_proc + bound_setter_proc.freeze rules[:value_validate_proc] = value_validate_proc + # :setter_proc is a pre-existing rules key and is preserved as-is: the + # 1-arity, self-bound proc used only to define the generated `name=` + # instance setter via `define_method(&proc)` (its fast path). The net-new + # :_bound_setter_proc is the 2-arity (instance, val) equivalent that every + # other write goes through without instance_exec's per-call self-rebinding; + # it is underscore-prefixed (like :_tnilable) so external code that replays + # rules hashes back into prop() filters it out as internal. + rules[:setter_proc] = setter_proc + rules[:_bound_setter_proc] = bound_setter_proc validate_overrides(name, rules) add_prop_definition(name, rules) @@ -644,12 +660,25 @@ def model_inherited(child) T::Props::Plugin::Private.apply_class_methods(mod, child) end - props.each do |name, rules| + parent_props = props + # Return before child.decorator below: forcing decorator creation for a + # prop-less parent would defeat any decorator_class override (see the NB). + return if parent_props.empty? + + # NB: Calling `child.decorator` here is a time bomb that's going to give someone a really bad + # time. Any class that defines props and also overrides the `decorator_class` method is going + # to reach this line before its override take effect, turning it into a no-op. + child_decorator = child.decorator + + # Computed once for all props: the owner comparison cannot change inside + # the loop below (it only defines prop accessors on child), and each + # Object#method call allocates a fresh Method. + clobber_getters = child_decorator.method(:prop_get).owner != method(:prop_get).owner + clobber_setters = child_decorator.method(:prop_set).owner != method(:prop_set).owner + + parent_props.each do |name, rules| copied_rules = rules.dup - # NB: Calling `child.decorator` here is a time bomb that's going to give someone a really bad - # time. Any class that defines props and also overrides the `decorator_class` method is going - # to reach this line before its override take effect, turning it into a no-op. - child.decorator.add_prop_definition(name, copied_rules) + child_decorator.add_prop_definition(name, copied_rules) # It's a bit tricky to support `prop_get` hooks added by plugins without # sacrificing the `attr_reader` fast path or clobbering customized getters @@ -660,13 +689,13 @@ def model_inherited(child) # (b) it's safe because the getter was defined by this file. # unless rules[:without_accessors] - if clobber_getter?(child, name) + if clobber_getters && child.instance_method(name).source_location&.first == __FILE__ child.send(:define_method, name) do T.unsafe(self.class).decorator.prop_get(self, name, rules) end end - if !rules[:immutable] && clobber_setter?(child, name) + if !rules[:immutable] && clobber_setters && child.instance_method("#{name}=").source_location&.first == __FILE__ child.send(:define_method, "#{name}=") do |val| T.unsafe(self.class).decorator.prop_set(self, name, val, rules) end @@ -721,18 +750,6 @@ def model_inherited(child) result end - sig { params(child: DecoratedClassType, prop: Symbol).returns(T::Boolean).checked(:never) } - private def clobber_getter?(child, prop) - !!(child.decorator.method(:prop_get).owner != method(:prop_get).owner && - child.instance_method(prop).source_location&.first == __FILE__) - end - - sig { params(child: DecoratedClassType, prop: Symbol).returns(T::Boolean).checked(:never) } - private def clobber_setter?(child, prop) - !!(child.decorator.method(:prop_set).owner != method(:prop_set).owner && - child.instance_method("#{prop}=").source_location&.first == __FILE__) - end - sig { params(mod: T::Module[T.anything]).void.checked(:never) } def plugin(mod) decorated_class.plugins << mod diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/errors.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/errors.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/errors.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/errors.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/generated_code_validation.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/generated_code_validation.rb similarity index 94% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/generated_code_validation.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/generated_code_validation.rb index 4155e293ad08c..f8da0927cac6f 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/generated_code_validation.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/generated_code_validation.rb @@ -119,7 +119,7 @@ def self.validate_serialize(source) private_class_method def self.validate_deserialize_ivar_set(clause) # %s = if val.nil? - # found -= 1 unless hash.key?(%s) + # found -= 1 unless hash.key?(%s.freeze) # %s # else # %s @@ -143,7 +143,13 @@ def self.validate_serialize(source) receiver, method, arg = found_condition.children assert_equal(s(:lvar, :hash), receiver) assert_equal(:key?, method) - assert_equal(:str, arg.type) + # hash.key?(%s.freeze), where `.freeze` on a string + # literal is side-effect-free (and avoids a per-call allocation) + assert_equal(:send, arg.type) + arg_receiver, arg_method, *arg_rest = arg.children + assert_equal(:str, arg_receiver.type) + assert_equal(:freeze, arg_method) + assert_equal([], arg_rest) assert_equal(nil, found_if_body) assert_equal(s(:op_asgn, s(:lvasgn, :found), :-, s(:int, 1)), found_else_body) @@ -262,7 +268,7 @@ def self.validate_serialize(source) @whitelisted_methods_for_serialize ||= { lvar: %i{dup map transform_values transform_keys each_with_object nil? []= serialize}, ivar: %i[dup map transform_values transform_keys each_with_object serialize], - const: %i[checked_serialize deep_clone_object], + const: %i[checked_serialize deep_clone deep_clone_object], } end @@ -270,7 +276,7 @@ def self.validate_serialize(source) private_class_method def self.whitelisted_methods_for_deserialize @whitelisted_methods_for_deserialize ||= { lvar: %i{dup map transform_values transform_keys each_with_object nil? []= to_f}, - const: %i[deserialize from_hash deep_clone_object], + const: %i[deserialize from_hash deep_clone deep_clone_object], } end end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/has_lazily_specialized_methods.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/has_lazily_specialized_methods.rb similarity index 74% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/has_lazily_specialized_methods.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/has_lazily_specialized_methods.rb index 20c0bbb3dad1c..8d7dead2d4f51 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/has_lazily_specialized_methods.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/has_lazily_specialized_methods.rb @@ -59,13 +59,23 @@ module DecoratorMethods raise SourceEvaluationDisabled.new end - source = lazily_defined_methods.fetch(name).call + blk = lazily_defined_methods[name] + # A concurrent first call can have already evaluated and removed + # this entry; the specialized method is installed, so the + # placeholder's retry dispatch will reach it directly. + return if blk.nil? + + source = blk.call cls = decorated_class T::Configuration.without_ruby_warnings do cls.class_eval(source.to_s) end cls.send(:private, name) + # Removing the entry records that no placeholder is installed, so a + # later prop addition (possible, if unusual: props added after first + # use) re-enqueues a fresh placeholder instead of being skipped. + lazily_defined_methods.delete(name) end sig { params(name: Symbol).void } @@ -74,15 +84,31 @@ module DecoratorMethods raise SourceEvaluationDisabled.new end - lazily_defined_vm_methods.fetch(name).call + blk = lazily_defined_vm_methods[name] + # See eval_lazily_defined_method!. + return if blk.nil? + + blk.call cls = decorated_class cls.send(:private, name) + lazily_defined_vm_methods.delete(name) end sig { params(name: Symbol, blk: T.proc.returns(String)).void } private def enqueue_lazy_method_definition!(name, &blk) - lazily_defined_methods[name] = blk + methods = lazily_defined_methods + if methods.key?(name) + # The placeholder installed below is already in place (every prop + # addition lands here, so this is hit from the second prop of a + # class onward, and again for every prop re-added to a subclass). + # It reads the generator from the hash at call time, so updating + # the entry suffices; skipping the re-install avoids 2-4 method + # table writes (and their cache invalidations) per addition. + methods[name] = blk + return + end + methods[name] = blk cls = decorated_class if cls.method_defined?(name) || cls.private_method_defined?(name) @@ -102,7 +128,13 @@ module DecoratorMethods sig { params(name: Symbol, blk: T.untyped).void } private def enqueue_lazy_vm_method_definition!(name, &blk) - lazily_defined_vm_methods[name] = blk + methods = lazily_defined_vm_methods + if methods.key?(name) + # See enqueue_lazy_method_definition!. + methods[name] = blk + return + end + methods[name] = blk cls = decorated_class cls.send(:define_method, name) do |*args| diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/optional.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/optional.rb similarity index 96% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/optional.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/optional.rb index acf9eda67f711..ee869e4b8b15b 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/optional.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/optional.rb @@ -47,7 +47,7 @@ def compute_derived_rules(rules) attr_reader :props_with_defaults # checked(:never) - O(runtime object construction) - sig { returns(T::Hash[Symbol, T::Props::Private::SetterFactory::SetterProc]).checked(:never) } + sig { returns(T::Hash[Symbol, T::Props::Private::SetterFactory::BoundSetterProc]).checked(:never) } attr_reader :props_without_defaults def add_prop_definition(prop, rules) @@ -62,7 +62,7 @@ def add_prop_definition(prop, rules) rules[DEFAULT_SETTER_RULE_KEY] = default_setter else @props_without_defaults ||= {} - @props_without_defaults[prop] = rules.fetch(:setter_proc) + @props_without_defaults[prop] = rules.fetch(:_bound_setter_proc) props_with_defaults&.delete(prop) # Handle potential override end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/plugin.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/plugin.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/plugin.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/plugin.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/pretty_printable.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/pretty_printable.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/pretty_printable.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/pretty_printable.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/apply_default.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/apply_default.rb similarity index 80% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/apply_default.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/apply_default.rb index c311c63740244..8873811c38b9a 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/apply_default.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/apply_default.rb @@ -9,14 +9,14 @@ class ApplyDefault abstract! # checked(:never) - O(object construction x prop count) - sig { returns(SetterFactory::SetterProc).checked(:never) } - attr_reader :setter_proc + sig { returns(SetterFactory::BoundSetterProc).checked(:never) } + attr_reader :bound_setter_proc # checked(:never) - We do this with `T.let` instead - sig { params(accessor_key: Symbol, setter_proc: SetterFactory::SetterProc).void.checked(:never) } - def initialize(accessor_key, setter_proc) + sig { params(accessor_key: Symbol, bound_setter_proc: SetterFactory::BoundSetterProc).void.checked(:never) } + def initialize(accessor_key, bound_setter_proc) @accessor_key = T.let(accessor_key, Symbol) - @setter_proc = T.let(setter_proc, SetterFactory::SetterProc) + @bound_setter_proc = T.let(bound_setter_proc, SetterFactory::BoundSetterProc) end # checked(:never) - O(object construction x prop count) @@ -33,30 +33,30 @@ def set_default(instance); end sig { params(cls: T::Module[T.anything], rules: T::Hash[Symbol, T.untyped]).returns(T.nilable(ApplyDefault)).checked(:never) } def self.for(cls, rules) accessor_key = rules.fetch(:accessor_key) - setter = rules.fetch(:setter_proc) + bound_setter = rules.fetch(:_bound_setter_proc) if rules.key?(:factory) - ApplyDefaultFactory.new(cls, rules.fetch(:factory), accessor_key, setter) + ApplyDefaultFactory.new(cls, rules.fetch(:factory), accessor_key, bound_setter) elsif rules.key?(:default) default = rules.fetch(:default) case default when *NO_CLONE_TYPES - return ApplyPrimitiveDefault.new(default, accessor_key, setter) + return ApplyPrimitiveDefault.new(default, accessor_key, bound_setter) when String if default.frozen? - return ApplyPrimitiveDefault.new(default, accessor_key, setter) + return ApplyPrimitiveDefault.new(default, accessor_key, bound_setter) end when Array if default.empty? && default.class == Array - return ApplyEmptyArrayDefault.new(accessor_key, setter) + return ApplyEmptyArrayDefault.new(accessor_key, bound_setter) end when Hash if default.empty? && default.default.nil? && T.unsafe(default).default_proc.nil? && default.class == Hash - return ApplyEmptyHashDefault.new(accessor_key, setter) + return ApplyEmptyHashDefault.new(accessor_key, bound_setter) end end - ApplyComplexDefault.new(default, accessor_key, setter) + ApplyComplexDefault.new(default, accessor_key, bound_setter) else nil end @@ -67,16 +67,16 @@ class ApplyFixedDefault < ApplyDefault abstract! # checked(:never) - We do this with `T.let` instead - sig { params(default: BasicObject, accessor_key: Symbol, setter_proc: SetterFactory::SetterProc).void.checked(:never) } - def initialize(default, accessor_key, setter_proc) + sig { params(default: BasicObject, accessor_key: Symbol, bound_setter_proc: SetterFactory::BoundSetterProc).void.checked(:never) } + def initialize(default, accessor_key, bound_setter_proc) # FIXME: Ideally we'd check here that the default is actually a valid # value for this field, but existing code relies on the fact that we don't. # # :( # - # setter_proc.call(default) + # bound_setter_proc.call(instance, default) @default = T.let(default, BasicObject) - super(accessor_key, setter_proc) + super(accessor_key, bound_setter_proc) end # checked(:never) - O(object construction x prop count) @@ -96,7 +96,7 @@ class ApplyComplexDefault < ApplyFixedDefault # checked(:never) - O(object construction x prop count) sig { override.returns(T.untyped).checked(:never) } def default - T::Props::Utils.deep_clone_object(@default) + T::Props::Utils.deep_clone(@default) end end @@ -141,15 +141,15 @@ class ApplyDefaultFactory < ApplyDefault cls: T::Module[T.anything], factory: T.any(Proc, Method), accessor_key: Symbol, - setter_proc: SetterFactory::SetterProc, + bound_setter_proc: SetterFactory::BoundSetterProc, ) .void .checked(:never) end - def initialize(cls, factory, accessor_key, setter_proc) + def initialize(cls, factory, accessor_key, bound_setter_proc) @class = T.let(cls, T::Module[T.anything]) @factory = T.let(factory, T.any(Proc, Method)) - super(accessor_key, setter_proc) + super(accessor_key, bound_setter_proc) end # checked(:never) - O(object construction x prop count) @@ -157,7 +157,7 @@ def initialize(cls, factory, accessor_key, setter_proc) def set_default(instance) # Use the actual setter to validate the factory returns a legitimate # value every time - instance.instance_exec(default, &@setter_proc) + @bound_setter_proc.call(instance, default) end # checked(:never) - O(object construction x prop count) diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/deserializer_generator.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/deserializer_generator.rb similarity index 92% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/deserializer_generator.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/deserializer_generator.rb index 728f141f6ad98..2b378942fde9b 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/deserializer_generator.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/deserializer_generator.rb @@ -81,10 +81,16 @@ def self.generate(props, defaults) raise_on_nil_write: !!rules[:raise_on_nil_write], ) + # The `.freeze` on the `hash.key?` argument matters: when this source + # is eval'd lazily (without a frozen-string-literal prefix, unlike + # `eagerly_define_lazy_methods!`), a bare literal here would allocate + # a new String on every call for each nil/missing prop. `"str".freeze` + # compiles to a no-allocation VM instruction (opt_str_freeze). The + # `hash[...]` read doesn't need it because of opt_aref_with. <<~RUBY val = hash[#{hash_key.inspect}] #{ivar_name} = if val.nil? - found -= 1 unless hash.key?(#{hash_key.inspect}) + found -= 1 unless hash.key?(#{hash_key.inspect}.freeze) #{nil_handler} else #{transformed_val} diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/parser.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/parser.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/parser.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/parser.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/serde_transform.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/serde_transform.rb similarity index 96% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/serde_transform.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/serde_transform.rb index e43e098ec9c6a..cbd44116efaad 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/serde_transform.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/serde_transform.rb @@ -88,7 +88,7 @@ def self.generate(type, mode, varname) # string comparisons. nil else - "T::Props::Utils.deep_clone_object(#{varname})" + "T::Props::Utils.deep_clone(#{varname})" end when T::Types::Union non_nil_type = T::Utils.unwrap_nilable(type) @@ -110,10 +110,10 @@ def self.generate(type, mode, varname) # this union to have no specific serde transform (the only reason # why Float has a special case is because round tripping through # JSON might normalize Floats to Integers) - "T::Props::Utils.deep_clone_object(#{varname})" + "T::Props::Utils.deep_clone(#{varname})" end when T::Types::Intersection - dynamic_fallback = "T::Props::Utils.deep_clone_object(#{varname})" + dynamic_fallback = "T::Props::Utils.deep_clone(#{varname})" # Transformations for any members of the intersection type where we # know what we need to do and did not have to fall back to the @@ -147,7 +147,7 @@ def self.generate(type, mode, varname) when T::Types::Enum generate(T::Utils.lift_enum(type), mode, varname) else - "T::Props::Utils.deep_clone_object(#{varname})" + "T::Props::Utils.deep_clone(#{varname})" end end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/serializer_generator.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/serializer_generator.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/serializer_generator.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/serializer_generator.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/setter_factory.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/setter_factory.rb similarity index 74% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/setter_factory.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/setter_factory.rb index e52996759261e..214179e9a90e8 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/private/setter_factory.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/private/setter_factory.rb @@ -8,6 +8,10 @@ module SetterFactory SetterProc = T.type_alias { T.proc.params(val: T.untyped).void } ValueValidationProc = T.type_alias { T.proc.params(val: T.untyped).void } + # Same validation/assignment as SetterProc, but takes the instance + # explicitly so per-prop construction/prop_set paths skip the + # self-rebinding instance_exec dispatch. + BoundSetterProc = T.type_alias { T.proc.params(instance: T.untyped, val: T.untyped).void } ValidateProc = T.type_alias { T.proc.params(prop: Symbol, value: T.untyped).void } sig do @@ -16,7 +20,7 @@ module SetterFactory prop: Symbol, rules: T::Hash[Symbol, T.untyped] ) - .returns([SetterProc, ValueValidationProc]) + .returns([SetterProc, ValueValidationProc, BoundSetterProc]) .checked(:never) end def self.build_setter_proc(klass, prop, rules) @@ -56,7 +60,7 @@ def self.build_setter_proc(klass, prop, rules) non_nil_type: T::Module[T.anything], klass: T.all(T::Module[T.anything], T::Props::ClassMethods), ) - .returns([SetterProc, ValueValidationProc]) + .returns([SetterProc, ValueValidationProc, BoundSetterProc]) end private_class_method def self.simple_non_nil_proc(prop, accessor_key, non_nil_type, klass) [ @@ -81,6 +85,19 @@ def self.build_setter_proc(klass, prop, rules) ) end end, + # The ivar set is unconditional, exactly as above: the value must + # still be set when call_validation_error_handler does not raise. + proc do |instance, val| + unless val.is_a?(non_nil_type) + T::Props::Private::SetterFactory.raise_pretty_error( + klass, + prop, + T::Utils.coerce(non_nil_type), + val, + ) + end + instance.instance_variable_set(accessor_key, val) + end, ] end @@ -92,7 +109,7 @@ def self.build_setter_proc(klass, prop, rules) klass: T.all(T::Module[T.anything], T::Props::ClassMethods), validate: T.nilable(ValidateProc) ) - .returns([SetterProc, ValueValidationProc]) + .returns([SetterProc, ValueValidationProc, BoundSetterProc]) end private_class_method def self.non_nil_proc(prop, accessor_key, non_nil_type, klass, validate) [ @@ -131,6 +148,21 @@ def self.build_setter_proc(klass, prop, rules) ) end end, + # The ivar set is unconditional, exactly as above: the value must + # still be set when call_validation_error_handler does not raise. + proc do |instance, val| + if non_nil_type.recursively_valid?(val) + validate&.call(prop, val) + else + T::Props::Private::SetterFactory.raise_pretty_error( + klass, + prop, + non_nil_type, + val, + ) + end + instance.instance_variable_set(accessor_key, val) + end, ] end @@ -141,7 +173,7 @@ def self.build_setter_proc(klass, prop, rules) non_nil_type: T::Module[T.anything], klass: T.all(T::Module[T.anything], T::Props::ClassMethods), ) - .returns([SetterProc, ValueValidationProc]) + .returns([SetterProc, ValueValidationProc, BoundSetterProc]) end private_class_method def self.simple_nilable_proc(prop, accessor_key, non_nil_type, klass) [ @@ -166,6 +198,19 @@ def self.build_setter_proc(klass, prop, rules) ) end end, + # The ivar set is unconditional, exactly as above: the value must + # still be set when call_validation_error_handler does not raise. + proc do |instance, val| + unless val.nil? || val.is_a?(non_nil_type) + T::Props::Private::SetterFactory.raise_pretty_error( + klass, + prop, + T::Utils.coerce(non_nil_type), + val, + ) + end + instance.instance_variable_set(accessor_key, val) + end, ] end @@ -177,7 +222,7 @@ def self.build_setter_proc(klass, prop, rules) klass: T.all(T::Module[T.anything], T::Props::ClassMethods), validate: T.nilable(ValidateProc), ) - .returns([SetterProc, ValueValidationProc]) + .returns([SetterProc, ValueValidationProc, BoundSetterProc]) end private_class_method def self.nilable_proc(prop, accessor_key, non_nil_type, klass, validate) [ @@ -220,6 +265,24 @@ def self.build_setter_proc(klass, prop, rules) ) end end, + # Branch structure (including the set-after-soft-error in the + # invalid arm) replicated exactly from the first proc above. + proc do |instance, val| + if val.nil? + instance.instance_variable_set(accessor_key, nil) + elsif non_nil_type.recursively_valid?(val) + validate&.call(prop, val) + instance.instance_variable_set(accessor_key, val) + else + T::Props::Private::SetterFactory.raise_pretty_error( + klass, + prop, + non_nil_type, + val, + ) + instance.instance_variable_set(accessor_key, val) + end + end, ] end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/serializable.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/serializable.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/serializable.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/serializable.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/type_validation.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/type_validation.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/type_validation.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/type_validation.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/utils.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/utils.rb similarity index 60% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/utils.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/utils.rb index a9048f56edf6e..0b0d5ba9fb82b 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/utils.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/utils.rb @@ -5,20 +5,48 @@ module T::Props::Utils # Deep copy an object. The object must consist of Ruby primitive # types and Hashes and Arrays. def self.deep_clone_object(what, freeze: false) + freeze ? deep_clone_freeze(what) : deep_clone(what) + end + + # deep_clone_object with freeze: false. Kept kwarg-free, with String (the + # most common serialized scalar) tested first: this is what generated + # serializers/deserializers emit for dynamic fallbacks, so it runs per + # element of every untyped container prop. + def self.deep_clone(what) + case what + when String + what.clone + when true, false, Symbol, NilClass, Numeric + what + when Array + what.map { |v| deep_clone(v) } + when Hash + h = what.class.new + what.each_pair do |k, v| + h[k] = deep_clone(v) + end + h + when Regexp + what.dup + when T::Enum + what + else + what.clone + end + end + + # deep_clone_object with freeze: true. + def self.deep_clone_freeze(what) result = case what - when true - true - when false - false - when Symbol, NilClass, Numeric + when true, false, Symbol, NilClass, Numeric what when Array - what.map { |v| deep_clone_object(v, freeze: freeze) } + what.map { |v| deep_clone_freeze(v) } when Hash h = what.class.new - what.each do |k, v| - k.freeze if freeze - h[k] = deep_clone_object(v, freeze: freeze) + what.each_pair do |k, v| + k.freeze + h[k] = deep_clone_freeze(v) end h when Regexp @@ -28,7 +56,7 @@ def self.deep_clone_object(what, freeze: false) else what.clone end - freeze ? result.freeze : result + result.freeze end # The prop_rules indicate whether we should check for reading a nil value for the prop/field. diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/weak_constructor.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/weak_constructor.rb similarity index 83% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/weak_constructor.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/weak_constructor.rb index 0611ac93cce0c..3279c602678b7 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/props/weak_constructor.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/props/weak_constructor.rb @@ -5,9 +5,14 @@ module T::Props::WeakConstructor include T::Props::Optional extend T::Sig + # Shared default so zero-arg construction doesn't allocate a fresh Hash; + # the construct_props_* methods only ever read from `hash`. + EMPTY_HASH = T.let({}.freeze, T::Hash[Symbol, T.untyped]) + private_constant :EMPTY_HASH + # checked(:never) - O(runtime object construction) sig { params(hash: T::Hash[Symbol, T.untyped]).void.checked(:never) } - def initialize(hash={}) + def initialize(hash=EMPTY_HASH) decorator = self.class.decorator hash_keys_matching_props = decorator.construct_props_with_defaults(self, hash) + @@ -33,9 +38,9 @@ def construct_props_without_defaults(instance, hash) # Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator # and therefore allocates for each entry. result = 0 - props_without_defaults&.each_pair do |p, setter_proc| + props_without_defaults&.each_pair do |p, bound_setter| if hash.key?(p) - instance.instance_exec(hash[p], &setter_proc) + bound_setter.call(instance, hash[p]) result += 1 end end @@ -56,7 +61,7 @@ def construct_props_with_defaults(instance, hash) result = 0 props_with_defaults&.each_pair do |p, default_struct| if hash.key?(p) - instance.instance_exec(hash[p], &default_struct.setter_proc) + default_struct.bound_setter_proc.call(instance, hash[p]) result += 1 else default_struct.set_default(instance) diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/sig.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/sig.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/sig.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/sig.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/struct.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/struct.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/struct.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/struct.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/syntax.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/syntax.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/syntax.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/syntax.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/anything.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/anything.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/anything.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/anything.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/attached_class.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/attached_class.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/attached_class.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/attached_class.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/base.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/base.rb similarity index 87% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/base.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/base.rb index ad647e6c2fc2a..49ceccdcd6325 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/base.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/base.rb @@ -52,6 +52,16 @@ def recursively_valid?(obj) def subtype_of?(t2) t1 = self + # Fast path over the isSubType mirror below: the dominant pair during + # override validation is two plain Simples, which match none of the + # branches in the walk. instance_of? (never + # is_a?) so that any hypothetical Simple subclass takes the full walk, + # and the raw subtype_of_single? result is returned unmodified + # (Module#<= yields nil for unrelated modules, which callers observe). + if t1.instance_of?(T::Types::Simple) && t2.instance_of?(T::Types::Simple) + return subtype_of_single?(t2) + end + if t2.is_a?(T::Private::Types::TypeAlias) t2 = t2.aliased_type end @@ -181,7 +191,10 @@ def hash def ==(other) case other when T::Types::Base - other.name == self.name + # Performance fast path: pooled and memoized type instances (e.g. the + # results of repeated T.nilable(X) calls) are the same object, so they + # can compare equal without computing and comparing their names. + other.equal?(self) || other.name == self.name else false end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/class_of.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/class_of.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/class_of.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/class_of.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/enum.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/enum.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/enum.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/enum.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/fixed_array.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/fixed_array.rb similarity index 81% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/fixed_array.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/fixed_array.rb index e3340b4379da1..a370395fe9b64 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/fixed_array.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/fixed_array.rb @@ -26,13 +26,15 @@ def name # overrides Base def recursively_valid?(obj) - if obj.is_a?(Array) && obj.length == types.length - i = 0 - while i < types.length - if !types.fetch(i).recursively_valid?(obj[i]) + element_types = types + length = element_types.length + if obj.is_a?(Array) && obj.length == length + index = 0 + while index < length + if !element_types.fetch(index).recursively_valid?(obj[index]) return false end - i += 1 + index += 1 end true else @@ -42,13 +44,15 @@ def recursively_valid?(obj) # overrides Base def valid?(obj) - if obj.is_a?(Array) && obj.length == types.length - i = 0 - while i < types.length - if !types.fetch(i).valid?(obj[i]) + element_types = types + length = element_types.length + if obj.is_a?(Array) && obj.length == length + index = 0 + while index < length + if !element_types.fetch(index).valid?(obj[index]) return false end - i += 1 + index += 1 end true else diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/fixed_hash.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/fixed_hash.rb similarity index 75% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/fixed_hash.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/fixed_hash.rb index 6e6a21c53a1f1..a4da1605b5641 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/fixed_hash.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/fixed_hash.rb @@ -26,16 +26,30 @@ def name # overrides Base def recursively_valid?(obj) return false unless obj.is_a?(Hash) - return false if types.any? { |key, type| !type.recursively_valid?(obj[key]) } - return false if obj.any? { |key, _| !types[key] } + field_types = types + field_types.each_pair do |key, type| + return false unless type.recursively_valid?(obj[key]) + end + # Pigeonhole: more entries than declared keys guarantees an undeclared key. + return false if obj.size > field_types.size + obj.each_key do |key| + return false unless field_types.key?(key) + end true end # overrides Base def valid?(obj) return false unless obj.is_a?(Hash) - return false if types.any? { |key, type| !type.valid?(obj[key]) } - return false if obj.any? { |key, _| !types[key] } + field_types = types + field_types.each_pair do |key, type| + return false unless type.valid?(obj[key]) + end + # Pigeonhole: more entries than declared keys guarantees an undeclared key. + return false if obj.size > field_types.size + obj.each_key do |key| + return false unless field_types.key?(key) + end true end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/intersection.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/intersection.rb similarity index 73% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/intersection.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/intersection.rb index 19a4ad904e016..c6b5ba33b47c8 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/intersection.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/intersection.rb @@ -32,12 +32,24 @@ def name # overrides Base def recursively_valid?(obj) - types.all? { |type| type.recursively_valid?(obj) } + members = types + index = 0 + while index < members.length + return false unless members.fetch(index).recursively_valid?(obj) + index += 1 + end + true end # overrides Base def valid?(obj) - types.all? { |type| type.valid?(obj) } + members = types + index = 0 + while index < members.length + return false unless members.fetch(index).valid?(obj) + index += 1 + end + true end # overrides Base diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/noreturn.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/noreturn.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/noreturn.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/noreturn.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/proc.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/proc.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/proc.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/proc.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/self_type.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/self_type.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/self_type.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/self_type.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/simple.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/simple.rb similarity index 93% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/simple.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/simple.rb index ff328ed3d2800..5678353a25448 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/simple.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/simple.rb @@ -31,6 +31,14 @@ def name # rubocop:enable Performance/BindCall end + # overrides Base + # + # Identical to valid?; defined directly so the leaf-type hot path (every + # element check in a typed collection walk) skips the Base delegator frame. + def recursively_valid?(obj) + obj.is_a?(@raw_type) + end + # overrides Base def valid?(obj) obj.is_a?(@raw_type) @@ -93,7 +101,7 @@ def self.type_for_module(mod) type = if mod == ::Array TypedArray::Untyped::Private::INSTANCE elsif mod == ::Hash - TypedHash::Untyped.new + TypedHash::Untyped::Private::INSTANCE elsif mod == ::Enumerable TypedEnumerable::Untyped.new elsif mod == ::Enumerator diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/t_enum.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/t_enum.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/t_enum.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/t_enum.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_member.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_member.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_member.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_member.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_parameter.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_parameter.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_parameter.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_parameter.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_template.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_template.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_template.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_template.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_variable.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_variable.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/type_variable.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/type_variable.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_array.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_array.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_array.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_array.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_class.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_class.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_class.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_class.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerable.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerable.rb similarity index 96% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerable.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerable.rb index e45bbbf47ffa6..a02a0ee19f0b0 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerable.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerable.rb @@ -38,10 +38,12 @@ def recursively_valid?(obj) return false unless obj.is_a?(Enumerable) case obj when Array - it = 0 - while it < obj.count - return false unless type.recursively_valid?(obj[it]) - it += 1 + element_type = type + length = obj.count + index = 0 + while index < length + return false unless element_type.recursively_valid?(obj[index]) + index += 1 end true when Hash diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerator.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerator.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerator.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerator.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerator_chain.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerator_chain.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerator_chain.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerator_chain.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerator_lazy.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerator_lazy.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_enumerator_lazy.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_enumerator_lazy.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_hash.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_hash.rb similarity index 69% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_hash.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_hash.rb index 787322e09ea69..b2dfe87aef907 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_hash.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_hash.rb @@ -47,12 +47,23 @@ def new(...) class Untyped < TypedHash def initialize - super(keys: T.untyped, values: T.untyped) + # Use the INSTANCE constant directly (rather than `T.untyped`) so this + # can be built at load time, mirroring TypedArray::Untyped. + super(keys: T::Types::Untyped::Private::INSTANCE, values: T::Types::Untyped::Private::INSTANCE) end def valid?(obj) obj.is_a?(Hash) end + + def freeze + build_type # force lazy initialization before freezing the object + super + end + + module Private + INSTANCE = Untyped.new.freeze + end end end end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_module.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_module.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_module.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_module.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_range.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_range.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/typed_range.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_range.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_set.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_set.rb new file mode 100644 index 0000000000000..38873ff77b614 --- /dev/null +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/typed_set.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +# typed: true + +module T::Types + class TypedSet < TypedEnumerable + # We can reference `Set` directly without a load guard: as of Ruby 3.2 it + # ships as a default-autoloaded constant (Ruby registers `autoload :Set, + # "set"`), so the first reference here transparently loads it. Ruby 3.3 -- + # the most recently supported release -- keeps this behavior, and Ruby 3.1 + # and earlier (which required an explicit `require "set"`) are past EOL. + def underlying_class + Set + end + + # overrides Base + def name + "T::Set[#{type.name}]" + end + + # overrides Base + def recursively_valid?(obj) + obj.is_a?(Set) && super + end + + # overrides Base + def valid?(obj) + obj.is_a?(Set) + end + + def new(...) + Set.new(...) + end + + class Untyped < TypedSet + def initialize + super(T::Types::Untyped::Private::INSTANCE) + end + + def valid?(obj) + obj.is_a?(Set) + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/union.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/union.rb similarity index 59% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/union.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/union.rb index cef3df1314ece..dcb7345e3e8a2 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/union.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/union.rb @@ -11,15 +11,30 @@ def initialize(types) end def types - @types ||= @inner_types.flat_map do |type| - type = T::Utils.coerce(type) - if type.is_a?(Union) - # Simplify nested unions (mostly so `name` returns a nicer value) - type.types - else - type + @types ||= begin + flattened = @inner_types.flat_map do |type| + type = T::Utils.coerce(type) + if type.is_a?(Union) + # Simplify nested unions (mostly so `name` returns a nicer value) + type.types + else + type + end + end.uniq + # When every member is a plain Simple (whose valid? is exactly + # `obj.is_a?(raw_type)`), precompute the members' raw modules so + # valid? can skip per-member dispatch. instance_of? (the is_a? only + # narrows for static checking) so that any Simple subclass overriding + # valid? would be excluded. Note this snapshots the members at build + # time. + member_modules = [] + all_simple = flattened.all? do |type| + type.is_a?(T::Types::Simple) && type.instance_of?(T::Types::Simple) && + member_modules << type.raw_type end - end.uniq + @member_modules = all_simple ? member_modules.freeze : false + flattened + end end def build_type @@ -58,12 +73,52 @@ def name # overrides Base def recursively_valid?(obj) - types.any? { |type| type.recursively_valid?(obj) } + member_modules = @member_modules + if member_modules.nil? + # Force the lazy types builder, which also computes @member_modules + types + member_modules = @member_modules + end + index = 0 + if member_modules + # For an all-Simple union, recursively_valid? and valid? coincide + # (Simple's recursively_valid? is exactly `obj.is_a?(raw_type)`). + while index < member_modules.length + return true if obj.is_a?(member_modules[index]) + index += 1 + end + else + members = types + while index < members.length + return true if members.fetch(index).recursively_valid?(obj) + index += 1 + end + end + false end # overrides Base def valid?(obj) - types.any? { |type| type.valid?(obj) } + member_modules = @member_modules + if member_modules.nil? + # Force the lazy types builder, which also computes @member_modules + types + member_modules = @member_modules + end + index = 0 + if member_modules + while index < member_modules.length + return true if obj.is_a?(member_modules[index]) + index += 1 + end + else + members = types + while index < members.length + return true if members.fetch(index).valid?(obj) + index += 1 + end + end + false end # overrides Base @@ -109,9 +164,13 @@ def self.union_of_types(type_a, type_b, types=EMPTY_ARRAY) end begin - if type_b == T::Utils::Nilable::NIL_TYPE + # The `equal?` checks are an identity fast path: NIL_TYPE is the pooled + # `coerce(NilClass)` instance, so it hits on every normal `T.nilable` call. + # The `==` fallbacks preserve semantics for hand-constructed + # `Simple.new(NilClass)` instances that bypass the pool. + if type_b.equal?(T::Utils::Nilable::NIL_TYPE) || type_b == T::Utils::Nilable::NIL_TYPE type_a.to_nilable - elsif type_a == T::Utils::Nilable::NIL_TYPE + elsif type_a.equal?(T::Utils::Nilable::NIL_TYPE) || type_a == T::Utils::Nilable::NIL_TYPE type_b.to_nilable else T::Private::Types::SimplePairUnion.new(type_a, type_b) diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/untyped.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/untyped.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/types/untyped.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/types/untyped.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/utils.rb b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/utils.rb similarity index 93% rename from Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/utils.rb rename to Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/utils.rb index 81f6c75667c1c..0313d2f78f9aa 100644 --- a/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13296/lib/types/utils.rb +++ b/Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/sorbet-runtime-0.6.13308/lib/types/utils.rb @@ -3,6 +3,13 @@ module T::Utils module Private + # NOTE: the Module and SimplePairUnion branches of this method are inlined + # for speed in several hot paths. The `T.cast` / `T.let` / `T.bind` / + # `T.assert_type!` happy paths in `_types.rb` inline the value check and + # return early on success; `T::Private::Casts.cast` is only reached after + # that check has already failed, so it reproduces the coercion branches but + # skips the (now always-false) value check. If you change the behavior + # here, update those callers too. def self.coerce_and_check_module_types(val, check_val, check_module_type) # rubocop:disable Style/CaseLikeIf if val.is_a?(T::Types::Base) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 4c8b970724298..f9bee8c61abb3 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -78,10 +78,10 @@ GEM yell (~> 2.0) zeitwerk (~> 2.5) http_parser.rb (0.8.1) - i18n (1.14.8) + i18n (1.15.2) concurrent-ruby (~> 1.0) io-console (0.8.2) - io-event (1.16.1) + io-event (1.16.4) irb (1.18.0) pp (>= 0.6.0) prism (>= 1.3.0) @@ -211,7 +211,7 @@ GEM google-protobuf (~> 4.31) sass-embedded (1.101.0-x86_64-linux-musl) google-protobuf (~> 4.31) - sorbet-runtime (0.6.13296) + sorbet-runtime (0.6.13316) stringio (3.2.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3)