Skip to content

Commit b65a584

Browse files
committed
Document the edge case in a FIXME as caused by define_method use
* We should rip out the fix when we update the define_method implementation to convert those blocks to real method scopes.
1 parent c2f66f2 commit b65a584

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,28 @@ public static RubyModule findInstanceMethodContainer(ThreadContext context, Dyna
742742
// - in the rare case where it is not (looks like it can
743743
// happen in some testing frameworks), we have to add
744744
// the method to self itself => its metaclass.
745+
//
746+
// SSS FIXME: Looks like this rare case happens when
747+
// the closure is used in a "define_method &block" scenario
748+
// => in reality the scope is not a closure but an
749+
// instance_method. So, when we fix define_method implementation
750+
// to actually convert blocks to real instance_method scopes,
751+
// we will not have this edge case since the code will then
752+
// be covered by the (scopeType == IRScopeType.INSTANCE_METHOD)
753+
// scenario below. Whenever we get to fixing define_method
754+
// implementation, we should rip out this code here.
755+
//
756+
// Verify that this test runs:
757+
// -------------
758+
// require "minitest/autorun"
759+
//
760+
// describe "A" do
761+
// it "should do something" do
762+
// def foo
763+
// end
764+
// end
765+
// end
766+
// -------------
745767
case MODULE_EVAL : return self instanceof RubyModule ? (RubyModule) self : self.getMetaClass();
746768
case INSTANCE_EVAL: return self.getSingletonClass();
747769
case BINDING_EVAL : ds = ds.getParentScope(); break;

0 commit comments

Comments
 (0)