https://kotlinlang.org logo
#compiler
Title
# compiler
r

Rob Elliot

10/08/2021, 2:36 PM
Anyone know why you can’t have bounds on type alias parameters? I was trying to do this:
typealias Fact<T : Any> = Pair<FactName, T>
in order to ensure that you can’t put null in it, but no dice.
e

Emil Kantis

10/08/2021, 10:15 PM
I think they introduced
<T & Any>
in 1.6.0 preview for this use case, https://youtrack.jetbrains.com/issue/KT-26245
f

Fudge

10/10/2021, 4:09 AM
T & Any
wouldn't matter here because
typealias Fact<T & Any>
is not valid kotlin.
T & Any
is a type just like
MutableList<T>
is.