Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 03026bf5d330
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d493c944104e
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 12, 2018

  1. Copy the full SHA
    f6c28bb View commit details
  2. Copy the full SHA
    d493c94 View commit details
Showing with 4 additions and 5 deletions.
  1. +3 −4 core/src/main/java/org/jruby/RubyModule.java
  2. +1 −1 core/src/main/java/org/jruby/RubyUnboundMethod.java
7 changes: 3 additions & 4 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -158,9 +158,8 @@ public static RubyClass createModuleClass(Ruby runtime, RubyClass moduleClass) {

public void checkValidBindTargetFrom(ThreadContext context, RubyModule originModule) throws RaiseException {
// Module methods can always be transplanted
if (originModule.isModule()) return;

if (!this.hasModuleInHierarchy(originModule)) {
if (!originModule.isModule() &&
!this.hasModuleInHierarchy(originModule)) {
if (originModule instanceof MetaClass) {
throw context.runtime.newTypeError("can't bind singleton method to a different class");
} else {
@@ -2004,7 +2003,7 @@ public IRubyObject defineMethodFromCallable(ThreadContext context, IRubyObject a
} else if (arg1 instanceof AbstractRubyMethod) {
AbstractRubyMethod method = (AbstractRubyMethod)arg1;

checkValidBindTargetFrom(context, (RubyModule)method.owner(context));
checkValidBindTargetFrom(context, (RubyModule) method.owner(context));

newMethod = method.getMethod().dup();
newMethod.setImplementationClass(this);
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyUnboundMethod.java
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ public RubyBoolean op_equal(ThreadContext context, IRubyObject other) {
public RubyMethod bind(ThreadContext context, IRubyObject aReceiver) {
RubyClass receiverClass = aReceiver.getMetaClass();

receiverClass.checkValidBindTargetFrom(context, implementationModule);
receiverClass.checkValidBindTargetFrom(context, (RubyModule) owner(context));

return RubyMethod.newMethod(implementationModule, methodName, receiverClass, originName, method, aReceiver);
}