How can I call Kotlin methods with reified generics from Java?

后端 未结 1 699
夕颜
夕颜 2021-01-01 11:36

I have the following method in Kotlin:

inline fun  foo() {

}

If I try to call this from Java like this:

m         


        
1条回答
  •  囚心锁ツ
    2021-01-01 11:59

    There's no way to call Kotlin inline functions with reified type parameters from Java because they must be transformed and inlined at the call sites (in your case, T should be substituted with the actual type at each call site, but there's much more compiler logic for inline functions than just this), and the Java compiler is, expectedly, completely unaware of that.

    0 讨论(0)
提交回复
热议问题