0

I'm using the Vertx Service Gen annotation processor with Kotlin kapt.

Before the annotation processor kick in, my kapt failed with following exception message all over the place:

error: scoping construct cannot be annotated with type-use annotation: @org.jetbrains.annotations.NotNull

Example of such is as following:

e: C:\Users\...\build\tmp\kapt3\stubs\main\com\_masked_\objects\User.java:10: error: scoping construct cannot be annotated with type-use annotation: @org.jetbrains.annotations.NotNull
    public abstract java.lang.String getUserName();

e: C:\Users\...\build\tmp\kapt3\stubs\main\com\_masked_\objects\User.java:13: error: scoping construct cannot be annotated with type-use annotation: @org.jetbrains.annotations.NotNull
    public abstract java.lang.String getUrlKey();
                             ^
e: C:\Users\...\build\tmp\kapt3\stubs\main\com\_masked_\objects\User.java:16: error: scoping construct cannot be annotated with type-use annotation: @org.jetbrains.annotations.NotNull
    public abstract com._.objects.File getAvatar();
                                       ^
...

The source code generated by kapt:

public abstract interface User {
    public static final com._.objects.User.Companion Companion = null;

    @org.jetbrains.annotations.NotNull()
    public abstract java.lang.String getUserName(); // line 10

    @org.jetbrains.annotations.NotNull()
    public abstract java.lang.String getUrlKey(); // line 13

    @org.jetbrains.annotations.NotNull()
    public abstract com._.objects.File getAvatar(); // line 16
...
}

Its source kotlin file looks like:

interface User {

    val userName: String
    val urlKey: String
    val avatar: File
    val signature: String

}

Through reading this thread, I kinda understand the situation right now, but how do I resolve this issue?

Jubin Justifies
  • 397
  • 4
  • 12
wusatosi
  • 617
  • 5
  • 13
  • This seem to be a kapt bug (not sure), kapt youtrack thread: https://youtrack.jetbrains.com/issue/KT-35721 – wusatosi Dec 27 '19 at 09:24

1 Answers1

2

This is a kapt bug, issue tracker link

The workaround kotlin team provide is adding implementation("org.jetbrains:annotations:15.0") to gradle bulid file.

wusatosi
  • 617
  • 5
  • 13