Add and fix test pattern for KFunction involving value class (to fix KT-31141). #4743
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Test patterns were added and modified to fix KT-31141.
This PR change will cover the following 3 x 2 patterns.
boxed
typenon-null object
typenullable object
typeprimitive
typeparameter
orextension receiver
non-null
nullable
This PR does not include the mitigation measures that I introduced earlier.
https://kotlinlang.slack.com/archives/C0BUHC9HD/p1644666394983169
Questions
About nested
value class
This change does not include testing for nested
value class
, as it seemed too much work.As far as I can figure out, it would take up to two levels of nesting to fully cover the validation for nested
value class
.On the other hand, if implement all these tests, I would have a combinatorial explosion as shown in the sample code below.
In this PR, we have tested up to
Z0
/S0_nonNull
/S0_nullable
.This means that implementing all the combinations shown above will increase the amount of code by about 7 times, and even up to 1-level nesting will increase it by about 3 times.
How should I handle the tests for nested
value class
?Which version the mitigation will be merged into
It may be too early to tell, but if I create a PR about mitigation measures, which version will that merge into?
This mitigation is important for the
value class
support of libraries that depend onkotlin-reflect
.For this reason, I would be happy to merge the proposed mitigation into
kotlin-reflect 1.5.x
.