https://kotlinlang.org logo
#k2-early-adopters
Title
# k2-early-adopters
r

Robert Jaros

11/15/2023, 5:55 PM
I'm using 1.9.20
This is the stacktrace https://pastebin.com/7SzG9qUC
Does it look like a known issue?
d

dmitriy.novozhilov

11/15/2023, 6:04 PM
Could you please check it with 2.0.0-Beta1, which was released today?
r

Robert Jaros

11/15/2023, 6:34 PM
It doesn't crash with 2.0.0-Beta1. It still doesn't compile but there is a normal error message.
Still I'm not sure how to address this issue. The compiler doesn't allow default values in my expect declarations:
Copy code
Default argument values inside expect declaration 'KVServiceManager' are not allowed for methods actualized via fake override. Possible fix is to remove default argument values in members
d

dmitriy.novozhilov

11/15/2023, 6:38 PM
cc @bobko
r

Robert Jaros

11/15/2023, 6:38 PM
But I can't have default values in my actuals as well:
Copy code
The following declaration is incompatible because actual function cannot have default argument values, they should be declared in the expected function
Any way to fix this other then dropping default values (which seems to work but I don't like this at all 😉) ?
b

bobko

11/15/2023, 7:01 PM
> Default argument values inside expect declaration 'KVServiceManager' are not allowed for methods actualized via fake override. Possible fix is to remove default argument values in members... @Robert Jaros can you please post the full compilation message? The compilation message mentions members at the end (the members are enumerated on new lines). I'm interested in the member names It's this issue: https://youtrack.jetbrains.com/issue/KT-62036
🙏 1
r

Robert Jaros

11/15/2023, 7:04 PM
Copy code
e: file:///home/rjaros/git/kvision/kvision-modules/kvision-server-javalin/src/jsMain/kotlin/io/kvision/remote/KVServiceManager.kt:29:95 Default argument values inside expect declaration 'KVServiceManager' are not allowed for methods actualized via fake override. Possible fix is to remove default argument values in members:
    expect fun <reified RET> bind(noinline function: suspend T.() -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR, reified RET> bind(noinline function: suspend T.(PAR) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified RET> bind(noinline function: suspend T.(PAR1, PAR2) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified PAR4, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified PAR4, reified PAR5, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, PAR5) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified PAR4, reified PAR5, reified PAR6, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, PAR5, PAR6) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1 : Any, reified PAR2 : Any> bind(noinline function: suspend T.(ReceiveChannel<PAR1>, SendChannel<PAR2>) -> Unit, route: String? = ...): Unit

    expect fun <reified PAR : Any> bind(noinline function: suspend T.(SendChannel<PAR>) -> Unit, route: String? = ...): Unit

    expect fun <reified RET> bindTabulatorRemote(noinline function: suspend T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?, String?) -> RemoteData<RET>, route: String? = ...): Unit
And the other one - for JVM target:
Copy code
e: file:///home/rjaros/git/kvision/kvision-modules/kvision-server-javalin/src/jvmMain/kotlin/io/kvision/remote/KVServiceManager.kt:58:5 Default argument values inside expect declaration 'KVServiceManager' are not allowed for methods actualized via fake override. Possible fix is to remove default argument values in members:
    expect fun <reified RET> bind(noinline function: suspend T.() -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR, reified RET> bind(noinline function: suspend T.(PAR) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified RET> bind(noinline function: suspend T.(PAR1, PAR2) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified PAR4, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified PAR4, reified PAR5, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, PAR5) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1, reified PAR2, reified PAR3, reified PAR4, reified PAR5, reified PAR6, reified RET> bind(noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, PAR5, PAR6) -> RET, method: HttpMethod = ..., route: String? = ...): Unit

    expect fun <reified PAR1 : Any, reified PAR2 : Any> bind(noinline function: suspend T.(ReceiveChannel<PAR1>, SendChannel<PAR2>) -> Unit, route: String? = ...): Unit

    expect fun <reified PAR : Any> bind(noinline function: suspend T.(SendChannel<PAR>) -> Unit, route: String? = ...): Unit

    expect fun <reified RET> bindTabulatorRemote(noinline function: suspend T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?, String?) -> RemoteData<RET>, route: String? = ...): Unit
Not sure if both are identical
b

bobko

11/15/2023, 7:22 PM
Minimized example:
Copy code
// COMMON
expect open class KVServiceManager {
    protected inline fun bind(route: String? = null)
}

// PLATFORM
open class KVServiceBinder {
    internal inline fun bind(route: String?) {}
}
actual open class KVServiceManager : KVServiceBinder()
I confirm that it's exactly what we prohibited in https://youtrack.jetbrains.com/issue/KT-62036 because it wasn't properly supported. Right now, I can only advise a workaround to declare an overload with substituted default args (the workaround is mentioned in the issue). If we see that this prohibition breaks a lot of code we might want to reconsider, so thanks for letting us know. But until then we'd like to keep it prohibited (expect/actual classes is a Beta feature, that's why we can do that)
r

Robert Jaros

11/15/2023, 7:41 PM
Thanks for the explanation. I should be able to deal with this issue now.