diff --git a/Library/Homebrew/cask/dsl/conflicts_with.rb b/Library/Homebrew/cask/dsl/conflicts_with.rb index d5de4edeb9..f49f3a0620 100644 --- a/Library/Homebrew/cask/dsl/conflicts_with.rb +++ b/Library/Homebrew/cask/dsl/conflicts_with.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "delegate" + require "extend/hash_validator" using HashValidator @@ -8,7 +10,7 @@ module Cask # Class corresponding to the `conflicts_with` stanza. # # @api private - class ConflictsWith < DelegateClass(Hash) + class ConflictsWith < SimpleDelegator VALID_KEYS = [ :formula, :cask, @@ -18,12 +20,13 @@ module Cask :java, ].freeze - def initialize(**pairs) - pairs.assert_valid_keys!(*VALID_KEYS) + def initialize(**options) + options.assert_valid_keys!(*VALID_KEYS) - super(pairs.transform_values { |v| Set.new(Array(v)) }) + conflicts = options.transform_values { |v| Set.new(Array(v)) } + conflicts.default = Set.new - self.default = Set.new + super(conflicts) end def to_json(generator) diff --git a/Library/Homebrew/cask/dsl/depends_on.rb b/Library/Homebrew/cask/dsl/depends_on.rb index e8beba968d..a3721b0530 100644 --- a/Library/Homebrew/cask/dsl/depends_on.rb +++ b/Library/Homebrew/cask/dsl/depends_on.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "delegate" + require "requirements/macos_requirement" module Cask @@ -7,7 +9,7 @@ module Cask # Class corresponding to the `depends_on` stanza. # # @api private - class DependsOn < DelegateClass(Hash) + class DependsOn < SimpleDelegator VALID_KEYS = Set.new([ :formula, :cask, diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb index 6a39871b13..07d79190d5 100644 --- a/Library/Homebrew/dependencies.rb +++ b/Library/Homebrew/dependencies.rb @@ -6,7 +6,7 @@ require "cask_dependent" # A collection of dependencies. # # @api private -class Dependencies < DelegateClass(Array) +class Dependencies < SimpleDelegator def initialize(*args) super(args) end @@ -41,7 +41,7 @@ end # A collection of requirements. # # @api private -class Requirements < DelegateClass(Set) +class Requirements < SimpleDelegator def initialize(*args) super(Set.new(args)) end diff --git a/Library/Homebrew/sorbet/rbi/utils/user.rbi b/Library/Homebrew/sorbet/rbi/utils/user.rbi index 49e9f1b3f4..ef1997fafd 100644 --- a/Library/Homebrew/sorbet/rbi/utils/user.rbi +++ b/Library/Homebrew/sorbet/rbi/utils/user.rbi @@ -1,9 +1,11 @@ # typed: strict -class User < String - def gui? - end +class User < SimpleDelegator + include Kernel - def self.current - end + sig { returns(T::Boolean) } + def gui?; end + + sig { returns(T.nilable(T.attached_class)) } + def self.current; end end diff --git a/Library/Homebrew/utils/user.rb b/Library/Homebrew/utils/user.rb index 0d5b94fb34..d40a7b6072 100644 --- a/Library/Homebrew/utils/user.rb +++ b/Library/Homebrew/utils/user.rb @@ -8,7 +8,7 @@ require "system_command" # A system user. # # @api private -class User < DelegateClass(String) +class User < SimpleDelegator # Return whether the user has an active GUI session. def gui? out, _, status = system_command "who"