Skip to content

Commit

Permalink
🐞 fix: Add primitive type check for upCast()
Browse files Browse the repository at this point in the history
  • Loading branch information
caoccao committed Oct 30, 2024
1 parent b183156 commit 99e40bf
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,12 @@ public static boolean upCast(
TypeDescription fromType,
TypeDescription toType,
Consumer<StackManipulation> stackManipulationConsumer) {
StackManipulation stackManipulation = PrimitiveWideningDelegate.forPrimitive(fromType).widenTo(toType);
if (stackManipulation.isValid() && stackManipulation != StackManipulation.Trivial.INSTANCE) {
stackManipulationConsumer.accept(stackManipulation);
if (fromType.isPrimitive() && toType.isPrimitive()) {
StackManipulation stackManipulation = PrimitiveWideningDelegate.forPrimitive(fromType).widenTo(toType);
if (stackManipulation.isValid() && stackManipulation != StackManipulation.Trivial.INSTANCE) {
stackManipulationConsumer.accept(stackManipulation);
return true;
}
}
return false;
}
Expand Down

0 comments on commit 99e40bf

Please sign in to comment.