Siddhartha Juluru
08/17/2022, 5:16 PMfun <P : Enum<P>> BaseConstraints<out Any, P>.validEnum(
init: Unit.() -> Unit
) {
this.rules.add(ValidEnum())
}
and it is only valid when I do validEnum<Status> { } (where Status is my enum) but not when I do validEnum<Status?> { } . I can make it accept the latter by doing
fun <P : Enum<P>> BaseConstraints<out Any, P?>.validEnum(
init: Unit.() -> Unit
) {
this.rules.add(ValidEnum())
}
but then I am unable to do validEnum<Status> { }Siddhartha Juluru
08/17/2022, 10:54 PM@JvmName("validEnumAnyP")
fun <P: Enum<P>> BaseConstraints<out Any, P>.validEnum(
init: Unit.() -> Unit
) = this.rules.add(ValidEnum())
@JvmName("validEnumAnyP?")
fun <P: Enum<P>> BaseConstraints<out Any, P?>.validEnum(
init: Unit.() -> Unit
) = this.rules.add(ValidEnum())Youssef Shoaib [MOD]
08/18/2022, 2:35 AMfun <P: Enum<P & Any>?> I think, since then both Status and Status? extend Enum<Status>?Siddhartha Juluru
08/18/2022, 1:12 PMP & Any is as if doing P: AnyYoussef Shoaib [MOD]
08/18/2022, 1:21 PMEnum<T> requires T : Enum<T>, and NOT T : Enum<T>?, But we would like to make our P here nullable within the type parameters, and so we simply make it possibly nullable, but we ensure to only pass the non-nullable kind to Enum so that it compiles correctly.Siddhartha Juluru
08/18/2022, 1:27 PM