I was working on a simple project with Kotlin in IntelliJ IDEA, when I encountered an odd compile-time error by the IDE, which read:
Type argument is not within its bounds.
This was being shown for a type argument that was within its bounds!
It took a while to produce an MRU for the error, and here it is:
fun interface I { fun f() }
annotation class A<T : I>
@A<C>
class C : I { override fun f() {} }
In this code, as you can see, C
is a subtype of I
, but the IDE still shows a compile-time error at the C
in the @A<C>
line, which says:
Type argument is not within its bounds.
Expected: I
Found: C
This is clearly a bug.
The weird part is, the bug goes away if I
is not a fun interface
and is just a simple interface
. Very strange.
My question is, what do I do now? Is this a bug or is my code wrong?