https://kotlinlang.org logo
#language-proposals
Title
# language-proposals
m

Michael de Kaste

03/03/2023, 12:37 PM
the ability to typealias extension on sealed subtypes
Copy code
sealed interface Range<T : Comparable<T>>{
   interface BoundedLeft<T : Comparable<T>> : Range<T>
}
val range: Range.BoundedLeft<LocalDate>
typealias DateRange = Range<LocalDate>
although the above statement is how we like to use it, the bottom two lines can't work:
Copy code
val daterange: DateRange.BoundedLeft (Unresolved reference: BoundedLeft)
typealias DateRange.BoundedLeft = Range.BoundedLeft<LocalDate> (Redeclaration: DateRange)
i

ilya.gorbunov

03/03/2023, 10:09 PM
The inability to access nested types through a typealias is tracked in https://youtrack.jetbrains.com/issue/KT-34281/Access-nested-classes-including-sealed-class-subclasses-through-typealias, but even if fixed it would not allow to use
DateRange.BoundedLeft
without specifying the type parameter of
BoundedLeft
.
74 Views