Skip to content

Commit 4992a5a

Browse files
committedMay 22, 2018
Pass host through to super calls properly.
1 parent 106dc09 commit 4992a5a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed
 

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

+12-8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.jruby.runtime.ThreadContext;
6868
import org.jruby.runtime.Visibility;
6969
import org.jruby.runtime.builtin.IRubyObject;
70+
import org.jruby.runtime.callsite.CacheEntry;
7071
import org.jruby.runtime.callsite.CachingCallSite;
7172
import org.jruby.runtime.callsite.FunctionalCachingCallSite;
7273
import org.jruby.runtime.callsite.NormalCachingCallSite;
@@ -1074,11 +1075,12 @@ public static IRubyObject instanceSuperSplatArgs(ThreadContext context, IRubyObj
10741075

10751076
@Interp
10761077
public static IRubyObject instanceSuper(ThreadContext context, IRubyObject self, String id, RubyModule definingModule, IRubyObject[] args, Block block) {
1077-
RubyClass superClass = definingModule.getMethodLocation().getSuperClass();
1078-
DynamicMethod method = superClass != null ? superClass.searchMethod(id) : UndefinedMethod.INSTANCE;
1078+
RubyClass superClass = definingModule.getSuperClass();
1079+
CacheEntry entry = superClass != null ? superClass.searchWithCache(id) : CacheEntry.NULL_CACHE;
1080+
DynamicMethod method = entry.method;
10791081
IRubyObject rVal = method.isUndefined() ?
10801082
Helpers.callMethodMissing(context, self, method.getVisibility(), id, CallType.SUPER, args, block)
1081-
: method.call(context, self, superClass, id, args, block);
1083+
: method.call(context, self, entry.host, id, args, block);
10821084
return rVal;
10831085
}
10841086

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

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

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

11091112
Helpers.checkSuperDisabledOrOutOfMethod(context, klazz, methodName);
11101113
RubyClass superClass = klazz.getSuperClass();
1111-
DynamicMethod method = superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE;
1114+
CacheEntry entry = superClass != null ? superClass.searchWithCache(methodName) : CacheEntry.NULL_CACHE;
1115+
DynamicMethod method = entry.method;
11121116

11131117
IRubyObject rVal;
11141118
if (method.isUndefined()) {
11151119
rVal = Helpers.callMethodMissing(context, self, method.getVisibility(), methodName, CallType.SUPER, args, block);
11161120
} else {
1117-
rVal = method.call(context, self, superClass, methodName, args, block);
1121+
rVal = method.call(context, self, entry.host, methodName, args, block);
11181122
}
11191123

11201124
return rVal;

0 commit comments

Comments
 (0)
Please sign in to comment.