diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 5533a1cd6d2d8..aa8a5393c3283 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -540,23 +540,13 @@ def oldname # 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}.