Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why it is complaining `declaration has type inferred from a platform call` in Kotlin?

Tags:

android

kotlin

Why it is complaining declaration has type inferred from a platform call when the method which is in java is annotated with NotNull annotation. I would expect this warning in case if the java method is not annotated with NotNull annotation code in Kotlin

 override fun getOverlay() =  createDefaultOverlay(context)

and code in java

   @NonNull
    public static RecyclerView createRecyclerView(@NonNull Context context) {}
like image 931
I.S Avatar asked Oct 31 '25 11:10

I.S


1 Answers

@NonNull(when = When.ALWAYS) should tell Kotlin that the Java code is returning a non-null value.

In your case, you were not using @NonNull(when = When.ALWAYS) directly, but instead had some other custom annotation that applied @NonNull(when = When.ALWAYS). Apparently, there is a bug or limitation in the IDE inspections for nullability that do not handle this case. If you can create a reproducible sample project, consider filing a bug report.

like image 87
CommonsWare Avatar answered Nov 02 '25 02:11

CommonsWare