diff --git a/Library/Homebrew/cask/cask.rbi b/Library/Homebrew/cask/cask.rbi
new file mode 100644
index 0000000000000000000000000000000000000000..2eb7d68e53abe2a36cd01e21a8b8d7815f7b1af4
--- /dev/null
+++ b/Library/Homebrew/cask/cask.rbi
@@ -0,0 +1,7 @@
+# typed: strict
+
+module Cask
+  class Cask
+    def homepage; end
+  end
+end
diff --git a/Library/Homebrew/cask/cmd.rb b/Library/Homebrew/cask/cmd.rb
index 628ce65d916da8db2378527ebda21f4a6aa4bec4..abb3764f1b236ff587135ac55eb9615b365a95c1 100644
--- a/Library/Homebrew/cask/cmd.rb
+++ b/Library/Homebrew/cask/cmd.rb
@@ -167,7 +167,7 @@ module Cask
 
       args = self.class.parser.parse(argv, ignore_invalid_options: true)
 
-      Tap.default_cask_tap.install unless Tap.default_cask_tap.installed?
+      Tap.install_default_cask_tap_if_necessary
 
       command, argv = detect_internal_command(*argv) ||
                       detect_external_command(*argv) ||
diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb
index def392761b4bee5d03a7c898c13d1f7ddd5b543a..16a80ae2c469d8dbb0a323176a9e437daa04e7c8 100644
--- a/Library/Homebrew/cli/named_args.rb
+++ b/Library/Homebrew/cli/named_args.rb
@@ -37,11 +37,20 @@ module Homebrew
         @to_formulae ||= to_formulae_and_casks(only: :formula).freeze
       end
 
+      # Convert named arguments to {Formula} or {Cask} objects.
+      # If both a formula and cask with the same name exist, returns
+      # the formula and prints a warning unless `only` is specified.
+      sig do
+        params(only: T.nilable(Symbol), ignore_unavailable: T.nilable(T::Boolean), method: T.nilable(Symbol))
+          .returns(T::Array[T.any(Formula, Keg, Cask::Cask)])
+      end
       def to_formulae_and_casks(only: nil, ignore_unavailable: nil, method: nil)
         @to_formulae_and_casks ||= {}
-        @to_formulae_and_casks[only] ||= begin
-          to_objects(only: only, ignore_unavailable: ignore_unavailable, method: method).freeze
-        end
+        @to_formulae_and_casks[only] ||= downcased_unique_named.flat_map do |name|
+          load_formula_or_cask(name, only: only, method: method)
+      rescue NoSuchKegError, FormulaUnavailableError, Cask::CaskUnavailableError
+        ignore_unavailable ? [] : raise
+        end.uniq.freeze
       end
 
       def to_formulae_to_casks(only: nil, method: nil)
@@ -88,6 +97,8 @@ module Homebrew
           begin
             return Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent))
           rescue Cask::CaskUnavailableError => e
+            retry if Tap.install_default_cask_tap_if_necessary
+
             raise e if only == :cask
           end
         end
@@ -111,19 +122,6 @@ module Homebrew
         to_formulae_to_casks(only: only, method: :resolve)
       end
 
-      # Convert named arguments to {Formula} or {Cask} objects.
-      # If both a formula and cask exist with the same name, returns the
-      # formula and prints a warning unless `only` is specified.
-      def to_objects(only: nil, ignore_unavailable: nil, method: nil)
-        @to_objects ||= {}
-        @to_objects[only] ||= downcased_unique_named.flat_map do |name|
-          load_formula_or_cask(name, only: only, method: method)
-        rescue NoSuchKegError, FormulaUnavailableError, Cask::CaskUnavailableError
-          ignore_unavailable ? [] : raise
-        end.uniq.freeze
-      end
-      private :to_objects
-
       def to_formulae_paths
         to_paths(only: :formula)
       end
diff --git a/Library/Homebrew/cmd/home.rb b/Library/Homebrew/cmd/home.rb
index 2dfa1c8f4144303e8c86f12192bda3d7712add04..224a366c3850c50a6cbb2b293ace685272dea6ee 100644
--- a/Library/Homebrew/cmd/home.rb
+++ b/Library/Homebrew/cmd/home.rb
@@ -35,7 +35,7 @@ module Homebrew
       formula_or_cask.homepage
     end
 
-    exec_browser(*homepages)
+    exec_browser(*T.unsafe(homepages))
   end
 
   def name_of(formula_or_cask)
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index aaecac87e01f3de769782e0d9691b6215de56809..74c9aca8cd58b2f3d7a2a459822083abd516286c 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -560,10 +560,10 @@ module Homebrew
       end
 
       def check_casktap_git_origin
-        cask_tap = Tap.default_cask_tap
-        return unless cask_tap.installed?
+        default_cask_tap = Tap.default_cask_tap
+        return unless default_cask_tap.installed?
 
-        examine_git_origin(cask_tap.path, cask_tap.remote)
+        examine_git_origin(default_cask_tap.path, default_cask_tap.remote)
       end
 
       sig { returns(T.nilable(String)) }
@@ -921,12 +921,12 @@ module Homebrew
       end
 
       def check_cask_taps
-        default_tap = Tap.default_cask_tap
-        alt_taps = Tap.select { |t| t.cask_dir.exist? && t != default_tap }
+        default_cask_tap = Tap.default_cask_tap
+        alt_taps = Tap.select { |t| t.cask_dir.exist? && t != default_cask_tap }
 
         error_tap_paths = []
 
-        add_info "Homebrew Cask Taps:", ([default_tap, *alt_taps].map do |tap|
+        add_info "Homebrew Cask Taps:", ([default_cask_tap, *alt_taps].map do |tap|
           if tap.path.blank?
             none_string
           else
diff --git a/Library/Homebrew/extend/os/mac/tap.rb b/Library/Homebrew/extend/os/mac/tap.rb
new file mode 100644
index 0000000000000000000000000000000000000000..495901ea68388a0b6de6a418f71279dc6e85ab46
--- /dev/null
+++ b/Library/Homebrew/extend/os/mac/tap.rb
@@ -0,0 +1,11 @@
+# typed: true
+# frozen_string_literal: true
+
+class Tap
+  def self.install_default_cask_tap_if_necessary
+    return false if default_cask_tap.installed?
+
+    default_cask_tap.install
+    true
+  end
+end
diff --git a/Library/Homebrew/extend/os/tap.rb b/Library/Homebrew/extend/os/tap.rb
index 7ad0ad531e869684d458dfdd56d698592c0207f1..b3ec23982faa9af66849f1e77ba30cbb0afbf86e 100644
--- a/Library/Homebrew/extend/os/tap.rb
+++ b/Library/Homebrew/extend/os/tap.rb
@@ -2,3 +2,4 @@
 # frozen_string_literal: true
 
 require "extend/os/linux/tap" if OS.linux?
+require "extend/os/mac/tap" if OS.mac?
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index b2c87dccdc35b0f5106c1e06d115c01871766c1d..d01c104edcf653c0c72971719625c3df3c03547c 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -60,10 +60,16 @@ class Tap
     fetch(match[:user], match[:repo])
   end
 
+  sig { returns(T.attached_class) }
   def self.default_cask_tap
     @default_cask_tap ||= fetch("Homebrew", "cask")
   end
 
+  sig { returns(T::Boolean) }
+  def self.install_default_cask_tap_if_necessary
+    false
+  end
+
   extend Enumerable
 
   # The user name of this {Tap}. Usually, it's the GitHub username of