https://kotlinlang.org logo
q

Quantum64

01/09/2023, 8:55 AM
I am confused about why this is an error:
Copy code
interface A : A.B {
    interface B {
    }
}
The error is "There's a cycle in the inheritance hierarchy for this type", however, this doesn't make sense because a nested interface's type isn't dependent on the outer interface's type at all. Can anyone provide some insight? Additionally, why would the above be disallowed when the following is allowed?
Copy code
interface A : Iterable<A.B> {
    interface B {
    }
}
c

CLOVIS

01/09/2023, 1:52 PM
In the second case, it's because generics are erased, so
A.B
has no impact on
A
. No idea why the first one is forbidden, though.
s

Stephan Schröder

01/09/2023, 6:25 PM
maybe it's a rough edge of Kotlin's type system 🤷‍♂️
c

CLOVIS

01/09/2023, 6:51 PM
It may be worth reporting as a bug
e

ephemient

01/10/2023, 12:48 AM
I believe this isn't representable in Java either
17 Views