Skip to content

Conversation

@m-koops
Copy link
Contributor

@m-koops m-koops commented Jan 19, 2026

Fixes #577

I took #578 as starting point, but it turned out that the provided tests did not actually fail when eq() is called with an inline value null. In that case the T::class in eq() is then equal to KClass<Void>.
After casting the null value in the tests explicity to ValueClass?/LongValueClass?, the tests started to exhibit the NPE.

I decided to take a slightly different turn in the actual main line fix: I've added the null check to eq().
The eqValueClass() function has only be introduced with release 6.2.0, so I felt it appropriate to reduce the typeParameter of the function to T: Any, so it only accepts non-null values onwards.

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TimvdLippe TimvdLippe merged commit 2431eb6 into mockito:main Jan 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eq() matcher throws NPE when used with nullable value class and null value

2 participants