os/mac/xcode: remove unnecessary type assertion

This commit is contained in:
Bo Anderson 2023-09-13 14:26:27 +01:00
parent 4b7eec6104
commit cf08039712
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65

View File

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