diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 134b4045fd00827c1bc4f4bca5fff8fbceddaeb9..bc698b717d11a61e2cdb5a1b74682d23ff66757e 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -119,6 +119,16 @@ class Formula
     @pin = FormulaPin.new(self)
   end
 
+  # @private
+  def set_active_spec(spec_sym)
+    spec = send(spec_sym)
+    raise FormulaSpecificationError, "#{spec_sym} spec is not available for #{full_name}" unless spec
+    @active_spec = spec
+    @active_spec_sym = spec_sym
+    validate_attributes!
+    @build = active_spec.build
+  end
+
   private
 
   def set_spec(name)