the ability to typealias extension on sealed subty...
# language-proposals
m
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
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
.
107 Views