Skip to content

Commit

Permalink
Always cast return value to return type. Fixes #5204.
Browse files Browse the repository at this point in the history
This issue was discovered by implementing an interface that
returns a JRuby type, like RubyArray. Because the JRuby types
implement IRubyObject, the logic for casting was not used, when at
least the cast should be present in all cases.
  • Loading branch information
headius committed Jun 11, 2018
1 parent 3950c09 commit ff90e42
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -822,12 +822,13 @@ public static void coerceResultAndReturn(SkinnyMethodAdapter mv, Class returnTyp
}
}
} else {
// if the return type is not an IRubyObject implementer, coerce to that type before casting
if (!IRubyObject.class.isAssignableFrom(returnType)) {
mv.ldc(Type.getType(returnType));
mv.invokeinterface(
p(IRubyObject.class), "toJava", sig(Object.class, Class.class));
mv.checkcast(p(returnType));
}
mv.checkcast(p(returnType));
mv.areturn();
}
} else {
Expand Down

0 comments on commit ff90e42

Please sign in to comment.