Tag: 具体化

Kotlin:UnsupportedOperationException用于get / set操作符

我试图将我的库中read和write的函数分别转换为运算符函数get和set 。 我的函数使用一个泛化的泛型类型,它们也是内联的方法。 (你可以在这里看到我的图书馆。) 编译器没有让我通过的问题,我不明白为什么使用非运算符函数推理工作得很好,但使用运算符在运行时失败。 Exception in thread "main" java.lang.UnsupportedOperationException: This function has a reified type parameter and thus can only be inlined at compilation time, not called directly. at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:173) at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:167) at kotlin.jvm.internal.Intrinsics.reifyJavaClass(Intrinsics.java:201) 代码如下: operator inline fun <reified T> get(address: Long): T { … } operator inline fun <reified T> get(address: Int): T […]