Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(1308): Handle nullable complex and nested value classes #1314

Conversation

VasilisDrettas-tomtom
Copy link
Contributor

Fix #1308

Problem:
The PR introduced a regression when a function is returning a nullable value class with a property that is not primitive and also in cases of a nested value class where the innermost property is not a primitive. In these cases we should be using the boxed value instead of the unboxed value.

Implementation:
The implementation was adjusted based on the following.

  • When the innermost property of the value class is primitive then use the unboxed value
  • When the innermost property of the value class is NOT primitive then use the boxed value.
  • Added some tests for nested value class as a return type of a suspending functions.
  • Revert the change in JvmMockFactoryHelper.kt as it's not necessary

@Raibaz Raibaz merged commit 79abc96 into mockk:master Oct 18, 2024
19 checks passed
@Raibaz
Copy link
Collaborator

Raibaz commented Oct 18, 2024

Nice, thanks for looking into this!

I'm both amazed and scared at the recursive implementation of innermostBoxedClass, but I think that was the only way to do this correctly.

@TWiStErRob
Copy link

Wow, that looks simple yet complex, nice one! Thanks so much for looking!

@matusekma
Copy link

Hi @Raibaz,
could you please make a release. We would like to update our mockk version but this bug prevents us from doing so. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants