Annotation not check

i user system annotation on my base abstract fun, i found it not check

for example:

@LayoutRes abstract fun getLayout(): Int

 override fun getLayout(): Int = 5  //not check

```java
public abstract @LayoutRes int getLayoutResID();

override fun getLayoutResID(): Int {
        return 5
    }   //it is check

how to use annotation for return param type?
1 Like

You need to add the annotation:

abstract class TestAnnotation {
    @LayoutRes abstract fun getLayoutResID(): Int
}

class TryAnnotation : TestAnnotation() {
    @LayoutRes
    override fun getLayoutResID(): Int {
        return 5
    }
}

While typing out the example I noticed that using Android Studio’s override feature to automatically implement the missing method of the parent abstract class the @LayoutRes annotation was not generated. You may want to try using Jetbrain’s bugtracker to report this, since it was the only missing piece.