Kotlin Annotation - Kotlin: Type mismatch: inferred type is java.lang.Class<foo> but java.lang.Class<out jet.Annotation> was expected


#1

hi,

given follwing kotlin Annotation:

public Retention(RetentionPolicy.RUNTIME) annotation class foo(val text : String)

and following code to check if a class is annotated by above annotation:

``

  if (javaClass<Bar>().isAnnotationPresent(javaClass<foo>())) {
           // do something here.
  }

if the annotation class (foo) and the code which is using it were located in the same module (maven artifact), the code can compile and run without any issue,

but if I separate them into different modules (maven artifact), then following compile error happens:

Kotlin: Type mismatch: inferred type is java.lang.Class<foo> but java.lang.Class<out jet.Annotation> was expected

Any Idea what could be the issue ?


#2

I've had issues with using annotations across modules before:

http://youtrack.jetbrains.com/issue/KT-3197

I’m guessing this is related. I would file another bug report.


#3

It's a bug, please report it to our issue tracker.


#4

http://youtrack.jetbrains.com/issue/KT-3534