Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion core/src/main/java/org/jruby/ir/targets/indy/InvokeSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jruby.RubyStruct;
import org.jruby.RubySymbol;
import org.jruby.anno.JRubyMethod;
import org.jruby.internal.runtime.AbstractIRMethod;
import org.jruby.internal.runtime.methods.AliasMethod;
import org.jruby.internal.runtime.methods.AttrReaderMethod;
import org.jruby.internal.runtime.methods.AttrWriterMethod;
Expand Down Expand Up @@ -701,7 +702,27 @@ private void finishBinding(CacheEntry entry, MethodHandle mh, IRubyObject self,

SmartHandle callInfoWrapper;
SmartBinder baseBinder = SmartBinder.from(signature.changeReturn(void.class)).permute("context");
if (flags == 0) {

// if target method takes keywords and we are passing them, set callInfo
boolean acceptsKeywords = true;
DynamicMethod method = entry.method;

NativeCallMethod nativeMethod;
if (method instanceof AbstractIRMethod && ((AbstractIRMethod) method).getRuby2Keywords()) {
// Ruby methods with ruby2_keywords don't use formal keywords
acceptsKeywords = false;
} else if (method instanceof NativeCallMethod && (nativeMethod = (NativeCallMethod) method).getNativeCall() != null) {
// native methods accept keywords only if specified
DynamicMethod.NativeCall nativeCall = nativeMethod.getNativeCall();
JRubyMethod jrubyMethod = nativeCall.getMethod().getAnnotation(JRubyMethod.class);
if (jrubyMethod != null) {
acceptsKeywords = jrubyMethod.keywords();
} else {
acceptsKeywords = false;
}
}

if (flags == 0 || !acceptsKeywords) {
callInfoWrapper = baseBinder.invokeStaticQuiet(LOOKUP, ThreadContext.class, "clearCallInfo");
} else {
callInfoWrapper = baseBinder.append("flags", flags).invokeStaticQuiet(LOOKUP, IRRuntimeHelpers.class, "setCallInfo");
Expand Down
Loading