It’s hard to describe that problem with words, so I’ll just send an example
ˋˋˋkt
interface A
interface B
interface C
class X: A, B
class Y: A, B, C
fun f(p: X)
fun f(p: Y)
ˋˋˋ
The behaviour of both definitions of ˋfˋ is exactly the same. ˋfˋ should take in any type that implements A and B.
but this is very bad obviously.
The only solution to that problem:
ˋˋˋkt
interface AB: A, B
class X: AB
class Y: AB, C
fun f(p: AB)
ˋˋˋ
This works perfectly fine, but you can’t always do that. If you can’t modify the declaration of ˋXˋ (if it is in a library for example), then you are going to have problems. The only solution to that problem is to add syntax specifically for that.
Example:
ˋˋˋ
class X: A, B
class Y: A, B, C
fun f(p: A | B)
ˋˋˋ
With this, one could also do: ˋtypealias AB = A | Bˋ.
Also not sure if ˋA | Bˋ is the best syntax for that.
Maybe ˋA + Bˋ or ˋA & Bˋ is better?