Any plans for intersection types? My understanding...
# language-evolution
y
Any plans for intersection types? My understanding is that the type system already uses them, no? Are there some rough edges that need to be improved before they can be made denotable? There's a few tricks btw to get them to show up, mostly involving using
InlineOnly
.
c
Aren't they already denotable?
Copy code
fun <T> foo(t: T) where T : Car, T : Motorized = TODO()
y
Well, that's one of the tricks I'm on about. You can't however return it easily, or introduce it explicitly in the middle of a calculation, or, God forbid, have an intersection of type parameters
Example from the forum, with my attempt to resolve it, and the commentor's more complex use case underneath
c
Ah, true, we have
T & Any
too.
y
The denotability is the main issue. Right now, you can implicitly make them up, although again with some tricks. However, it's really hard to have them as return types, and you get errors really quickly when using them with generics (although
InlineOnly
, if you get it by shadowing stdlib's annotations, fixes that)