diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 3a575f491d..9402bf5d6e 100755 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -95,21 +95,17 @@ module OS # directory or nil if Xcode.app is not installed. sig { returns(T.nilable(Pathname)) } def self.prefix - return @prefix if defined?(@prefix) + @prefix ||= begin + dir = MacOS.active_developer_dir - @prefix = T.let(@prefix, T.nilable(Pathname)) - @prefix ||= - begin - dir = MacOS.active_developer_dir - - if dir.empty? || dir == CLT::PKG_PATH || !File.directory?(dir) - path = bundle_path - path/"Contents/Developer" if path - else - # Use cleanpath to avoid pathological trailing slash - Pathname.new(dir).cleanpath - end + if dir.empty? || dir == CLT::PKG_PATH || !File.directory?(dir) + path = bundle_path + path/"Contents/Developer" if path + else + # Use cleanpath to avoid pathological trailing slash + Pathname.new(dir).cleanpath end + end end sig { returns(Pathname) }