Conversation
| val isReturnNullable = kFunction.returnType.isMarkedNullable | ||
| val isPrimitive = resultType.innermostBoxedClass.java.isPrimitive | ||
| // Use boxedClass (one level) instead of innermostBoxedClass (recursive) to avoid infinite loops (issue #1103) | ||
| val isPrimitive = resultType.boxedClass.java.isPrimitive |
There was a problem hiding this comment.
The usage of innermostBoxedClass was introduced in this commit to allow mocking complex value classes and fix #1308, so using boxedClass directly will likely cause a regression on it.
How about using a hybrid approach and recursively calling boxedClass with a limit on the number of recursions?
There was a problem hiding this comment.
I see, I would've expected some tests to be broken if my change would cause a regression. I'll look into the hybrid approach, thanks!
There was a problem hiding this comment.
I have added a recursion limit of 10. Do you think this is enough for all cases?
|
I believe this is causing another issue now: When I try to add a Otherwise the current code in master will cause verification to fail this test case: Where: |
|
Perhaps we just need to use the |
|
I was able to reproduce the issue. The problem occurs during verification with exact value matching when the return type is nullable. I've implemented a fix and will a open a new PR:
The innermostBoxedClass approach is better because it has built-in recursion protection while still properly handling both nullable and nested value classes. This resolves issues #1103, #1308, and #1475 together. All value class tests pass with this fix. Thank you for the issue report and suggested solution 🎉 |
The issue here was that
innermostBoxedClassis recursive and was causing an infinite loop for nullable value classes, which are not inlined in JVM bytecode (they remain boxed), so it kept trying to unwrap something that shouldn't be unwrapped.Also added a check to skip the boxedClass call entirely for nullable return types, since nullable value classes are not inlined and should be treated as regular boxed types.
Added 2 tests for this usecase and all tests pass using
gradle checkLink to issue: #1103