I'm having an issue with my Inline value class.
This instance just wraps a String, eg.,
@JvmInline
value class MyValueClass(private val value: String) {
override fun toString() = value
}
I need the
toString()
override because there are callers in the frameworks I need that call it, and I don't want the extra markup:
MyValueClass(value="Some value")
I have an nullable argument of type MyValueClass:
fun myFunction(currentValue: MyValueClass? = null)
When I pass no value, or even if I explicitly pass
null
, then
myFunction
receives
currentValue
as
"null"
.
Is this an auto-promotion? When I explicitly pass a string value, compilation fails with a Type Mismatch, as I'd expect. But why does a null value silently become "null", instead of a null
MyValueClass
? (Or in bytecode, just a
String?
?