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: d183f8daf790
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 53a43caf7fb3
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Nov 6, 2014

  1. Add Method#super_method

    cheald committed Nov 6, 2014
    Copy the full SHA
    b4ff008 View commit details

Commits on Nov 7, 2014

  1. Merge branch 'super_method' of github.com:cheald/jruby into cheald-su…

    …per_method
    
    Conflicts:
    	core/src/main/java/org/jruby/RubyMethod.java
    headius committed Nov 7, 2014
    Copy the full SHA
    7359d48 View commit details
  2. Copy the full SHA
    53a43ca View commit details
Showing with 34 additions and 1 deletion.
  1. +21 −0 core/src/main/java/org/jruby/RubyMethod.java
  2. +8 −1 core/src/main/java/org/jruby/RubyModule.java
  3. +5 −0 core/src/main/java/org/jruby/RubyUnboundMethod.java
21 changes: 21 additions & 0 deletions core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
@@ -36,11 +36,13 @@
import org.jruby.anno.JRubyClass;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.internal.runtime.methods.ProcMethod;
import org.jruby.internal.runtime.methods.UndefinedMethod;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.CompiledBlockCallback19;
import org.jruby.runtime.CompiledBlockLight19;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.PositionAware;
import org.jruby.runtime.ThreadContext;
@@ -304,5 +306,24 @@ public IRubyObject parameters(ThreadContext context) {
public IRubyObject curry(ThreadContext context, IRubyObject[] args) {
return to_proc(context, null).callMethod(context, "curry", args);
}

@JRubyMethod
public IRubyObject super_method(ThreadContext context) {
RubyModule superClass = Helpers.findImplementerIfNecessary(receiver.getMetaClass(), implementationModule).getSuperClass();
return super_method(context, receiver, superClass);
}

protected IRubyObject super_method(ThreadContext context, IRubyObject receiver, RubyModule superClass) {
if (superClass == null) return context.runtime.getNil();

DynamicMethod newMethod = superClass.searchMethod(methodName);
if (newMethod == UndefinedMethod.INSTANCE) return context.runtime.getNil();

if (receiver == null) {
return RubyUnboundMethod.newUnboundMethod(superClass, methodName, superClass, originName, newMethod);
} else {
return newMethod(superClass, methodName, superClass, originName, newMethod, receiver);
}
}
}

9 changes: 8 additions & 1 deletion core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -1860,7 +1860,14 @@ public boolean equals(Object other) {
@JRubyMethod(name = "==", required = 1)
@Override
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
return super.op_equal(context, other);
if(!(other instanceof RubyModule))
return context.runtime.getFalse();
RubyModule otherModule = (RubyModule)other;
if(otherModule.isIncluded()) {
return context.runtime.newBoolean(otherModule.isSame(this));
} else {
return context.runtime.newBoolean(isSame(otherModule));
}
}

/** rb_mod_freeze
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/RubyUnboundMethod.java
Original file line number Diff line number Diff line change
@@ -135,4 +135,9 @@ public IRubyObject name19(ThreadContext context) {
public IRubyObject owner(ThreadContext context) {
return implementationModule;
}

@JRubyMethod
public IRubyObject super_method(ThreadContext context ) {
return super_method(context, null, implementationModule.getSuperClass());
}
}