diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 342fbcc9d8..3cce9ccb3f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -540,23 +540,13 @@ class Formula # Old names for the formula. sig { returns(T::Array[String]) } def oldnames - @oldnames ||= if tap - T.must(tap).formula_oldnames.fetch(name, []) - else - [] - end + @oldnames ||= tap&.formula_oldnames&.dig(name) || [] end # All aliases for the formula. sig { returns(T::Array[String]) } def aliases - @aliases ||= if tap - T.must(tap).alias_reverse_table[full_name].to_a.map do |a| - a.split("/").last - end - else - [] - end + @aliases ||= tap&.alias_reverse_table&.dig(full_name)&.map { _1.split("/").last } || [] end # The {Resource}s for the currently active {SoftwareSpec}.