From 99607e8ec41df9c2bd100e8b24a8646d0a5267bf Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Fri, 4 Aug 2023 11:26:30 +0800 Subject: [PATCH] development_tools: allow `Symbol`s to be `locate`d Fixes error seen in Homebrew/homebrew-core#138452. `DevelopmentTools.default_compiler` can return a `Symbol` like `:clang`. Make sure its result can be fed to `DevelopmentTools.locate`. Signed-off-by: Ruoyu Zhong --- Library/Homebrew/development_tools.rb | 2 +- Library/Homebrew/extend/os/linux/development_tools.rb | 2 +- Library/Homebrew/extend/os/mac/development_tools.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index 3ad70e3e93..90254d2715 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -6,7 +6,7 @@ require "version" # @private class DevelopmentTools class << self - sig { params(tool: String).returns(T.nilable(Pathname)) } + sig { params(tool: T.any(String, Symbol)).returns(T.nilable(Pathname)) } def locate(tool) # Don't call tools (cc, make, strip, etc.) directly! # Give the name of the binary you look for as a string to this method diff --git a/Library/Homebrew/extend/os/linux/development_tools.rb b/Library/Homebrew/extend/os/linux/development_tools.rb index d26b73f312..c9d04a4830 100644 --- a/Library/Homebrew/extend/os/linux/development_tools.rb +++ b/Library/Homebrew/extend/os/linux/development_tools.rb @@ -3,7 +3,7 @@ class DevelopmentTools class << self - sig { params(tool: String).returns(T.nilable(Pathname)) } + sig { params(tool: T.any(String, Symbol)).returns(T.nilable(Pathname)) } def locate(tool) (@locate ||= {}).fetch(tool) do |key| @locate[key] = if needs_build_formulae? && diff --git a/Library/Homebrew/extend/os/mac/development_tools.rb b/Library/Homebrew/extend/os/mac/development_tools.rb index 0df45d805d..d86403c7d6 100644 --- a/Library/Homebrew/extend/os/mac/development_tools.rb +++ b/Library/Homebrew/extend/os/mac/development_tools.rb @@ -10,7 +10,7 @@ class DevelopmentTools undef installed?, default_compiler, curl_handles_most_https_certificates?, subversion_handles_most_https_certificates? - sig { params(tool: String).returns(T.nilable(Pathname)) } + sig { params(tool: T.any(String, Symbol)).returns(T.nilable(Pathname)) } def locate(tool) (@locate ||= {}).fetch(tool) do |key| @locate[key] = if (located_tool = generic_locate(tool))