Currently i'm getting an error when using vararg w...
# language-proposals
j
Currently i'm getting an error when using vararg with inline classes, so my language proposal is to allow using vararg with inline classes
Copy code
inline class HotelCode(val value: String)
Copy code
suspend fun listHotels(vararg hotelCode: HotelCode) {
^^^ forbidden vararg type HotelCode
this is a decision made to postpone a resolution regarding the design issues that introduces
j
Copy code
This decision doesn't allow declaring vararg parameters that represent array of unboxed inline class values, because it's impossible to associate vararg of inline class type with the corresponding array type. For example, without additional information it's impossible to match vararg v: Foo with FooArray. Therefore, we are going to prohibit vararg parameters for now.
Wouldn't Array<Foo> solve that? Sure you're not going to get it compiled to primitive arrays like FooArray or IntArray does, but that's an acceptable trade-off I'll star that discussion to stay in the loop
l
Then, you'd have a resolution ambiguity on the JVM because of type erasure.
d
And you wouldnt have binary compatibility with a future improvement.