How can you deprioritize a constructor overload? I added the new optional constructor:
Copy code
@JvmInline
value class AsyncValue<T>(private inline val getter: suspend () -> T) {
constructor(queryResult: suspend () -> AsyncValue<T>) : this (getter = {
queryResult().getter()
})
}
With this code, the current usage of
AsyncValue { //myCode }
needs to return
AsyncValue
and not
T
. Workaround is to use change all old code from
AsyncValue { }
to
AsyncValue(getter = { })
.
y
Youssef Shoaib [MOD]
07/17/2023, 10:54 AM
I haven't tried this, but instead of using constructors, have 2 different methods named
AsyncValue
and annotate the
T
one with
@OverloadResolutionByLambdaReturnType
Youssef Shoaib [MOD]
07/17/2023, 10:56 AM
Also, I'm very surprised that
inline val
is a thing for value classes. Do you have any more info about that? Does it actually inline the lambda or something? I can't quite tell what's happening there
➕ 1
h
hfhbd
07/17/2023, 11:19 AM
Yeah, using a helper function would a valid workaround.
hfhbd
07/17/2023, 11:20 AM
Honestly, I have no information about inlining the variable too. Guess it needs a class code or bytecode analysis if this modifier has any effect