Skip to content

Commit

Permalink
Pass host through to super calls properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed May 22, 2018
1 parent 106dc09 commit 4992a5a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Expand Up @@ -67,6 +67,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CacheEntry;
import org.jruby.runtime.callsite.CachingCallSite;
import org.jruby.runtime.callsite.FunctionalCachingCallSite;
import org.jruby.runtime.callsite.NormalCachingCallSite;
Expand Down Expand Up @@ -1074,11 +1075,12 @@ public static IRubyObject instanceSuperSplatArgs(ThreadContext context, IRubyObj

@Interp
public static IRubyObject instanceSuper(ThreadContext context, IRubyObject self, String id, RubyModule definingModule, IRubyObject[] args, Block block) {
RubyClass superClass = definingModule.getMethodLocation().getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(id) : UndefinedMethod.INSTANCE;
RubyClass superClass = definingModule.getSuperClass();
CacheEntry entry = superClass != null ? superClass.searchWithCache(id) : CacheEntry.NULL_CACHE;
DynamicMethod method = entry.method;
IRubyObject rVal = method.isUndefined() ?
Helpers.callMethodMissing(context, self, method.getVisibility(), id, CallType.SUPER, args, block)
: method.call(context, self, superClass, id, args, block);
: method.call(context, self, entry.host, id, args, block);
return rVal;
}

Expand All @@ -1090,10 +1092,11 @@ public static IRubyObject classSuperSplatArgs(ThreadContext context, IRubyObject
@Interp
public static IRubyObject classSuper(ThreadContext context, IRubyObject self, String id, RubyModule definingModule, IRubyObject[] args, Block block) {
RubyClass superClass = definingModule.getMetaClass().getMethodLocation().getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(id) : UndefinedMethod.INSTANCE;
CacheEntry entry = superClass != null ? superClass.searchWithCache(id) : CacheEntry.NULL_CACHE;
DynamicMethod method = entry.method;
IRubyObject rVal = method.isUndefined() ?
Helpers.callMethodMissing(context, self, method.getVisibility(), id, CallType.SUPER, args, block)
: method.call(context, self, superClass, id, args, block);
: method.call(context, self, entry.host, id, args, block);
return rVal;
}

Expand All @@ -1103,18 +1106,19 @@ public static IRubyObject unresolvedSuperSplatArgs(ThreadContext context, IRubyO

public static IRubyObject unresolvedSuper(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
// We have to rely on the frame stack to find the implementation class
RubyModule klazz = context.getFrameKlazz().getMethodLocation();
RubyModule klazz = context.getFrameKlazz();
String methodName = context.getCurrentFrame().getName();

Helpers.checkSuperDisabledOrOutOfMethod(context, klazz, methodName);
RubyClass superClass = klazz.getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE;
CacheEntry entry = superClass != null ? superClass.searchWithCache(methodName) : CacheEntry.NULL_CACHE;
DynamicMethod method = entry.method;

IRubyObject rVal;
if (method.isUndefined()) {
rVal = Helpers.callMethodMissing(context, self, method.getVisibility(), methodName, CallType.SUPER, args, block);
} else {
rVal = method.call(context, self, superClass, methodName, args, block);
rVal = method.call(context, self, entry.host, methodName, args, block);
}

return rVal;
Expand Down

0 comments on commit 4992a5a

Please sign in to comment.