MethodHandles: Fix MethodType::IsConvertible() error.
Conversions between non-numeric primitives and their boxed equivalents
were being rejected.
Test: m test-art-host-run-test-956-methodhandles
Bug: 30550796
Change-Id: I4ee255be3a4549246548185e362789561382ba1b
diff --git a/runtime/method_handles.cc b/runtime/method_handles.cc
index f1adc32..3c22d7f 100644
--- a/runtime/method_handles.cc
+++ b/runtime/method_handles.cc
@@ -141,7 +141,14 @@
}
Primitive::Type unboxed_type;
if (GetUnboxedPrimitiveType(from, &unboxed_type)) {
- return Primitive::IsWidenable(unboxed_type, to_primitive);
+ if (unboxed_type == to_primitive) {
+ // Straightforward unboxing conversion such as Boolean => boolean.
+ return true;
+ } else {
+ // Check if widening operations for numeric primitives would work,
+ // such as Byte => byte => long.
+ return Primitive::IsWidenable(unboxed_type, to_primitive);
+ }
}
}