From 143f900ab4fd89b2e87f2ca2eb9456dac182f855 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Sun, 19 Aug 2018 23:40:44 -0700 Subject: [StubSpecification] Comment why we override #stub --- lib/bundler/stub_specification.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index 08b7507d86..deaa7905c9 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -77,8 +77,13 @@ module Bundler stub.raw_require_paths end + # @note + # Cannot be an attr_reader that returns @stub, because the stub can pull it's `to_spec` + # from `Gem.loaded_specs`, which can end up being self. + # #_remote_specification has logic to handle this case, so delegate to that in that situation, + # because otherwise we can end up with a stack overflow when calling #missing_extensions? def stub - if !@_remote_specification && @stub.instance_variable_get(:@data) && Gem.loaded_specs[name].equal?(self) + if @_remote_specification.nil? && @stub.instance_variable_get(:@data) && Gem.loaded_specs[name].equal?(self) _remote_specification end @stub -- cgit v1.2.1