Skip to content

Commit

Permalink
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -821,7 +821,14 @@ public static RubyModule findInstanceMethodContainer(ThreadContext context, Dyna
case MODULE_BODY:
case CLASS_BODY:
case METACLASS_BODY:
return (RubyModule) self;
// This is a similar scenario as the FIXME above that was added
// in b65a5842ecf56ca32edc2a17800968f021b6a064. At that time,
// I was wondering if it would affect this site here and looks
// like it does.
//
// Verify that the test in GH issue 4014 runs when ripping out
// this special instanceof check below.
return self instanceof RubyModule ? (RubyModule) self : self.getMetaClass();

case INSTANCE_METHOD:
case SCRIPT_BODY:

5 comments on commit 6bb13ef

@JasonLunn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not include the test provided in #4014 as a regression check?

@subbuss
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test depends on activesupport. Without reducing it to a standalone test, it is hard to include it in jruby's test suite.

@JasonLunn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this instead:

module DefinesMethod
  def def_meth &block
    define_method :foo, &block
  end
end

class RegressionTest
  extend DefinesMethod
  def_meth do
    def bar
      puts 'Success'
    end
  end
end

RegressionTest.new.foo

@subbuss
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 That is great! Thank you. :)

@subbuss
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now added in d9203da

Please sign in to comment.