Kotlin中操作数堆栈的类型错误
我有以下代码:Kotlin中操作数堆栈的类型错误,kotlin,lambda,Kotlin,Lambda,我有以下代码: fun getPriceVariants(request: PriceVariantsRequest): List<PriceVariant> { val calculateVariables = Option.Some(request) map { mapPVRequestToPRVariables(it) } InstallmentType.values() .asSequence()
fun getPriceVariants(request: PriceVariantsRequest): List<PriceVariant> {
val calculateVariables = Option.Some(request) map { mapPVRequestToPRVariables(it) }
InstallmentType.values()
.asSequence()
.map { installmentType -> addInstallmentTypeToPRVariables(installmentType, calculateVariables) }
return listOf()
}
}
以及函数addInstallmentTypeToPRVariables
:
fun addInstallmentTypeToPRVariables(
installmentType: InstallmentType,
prVariables: Option<PriceRequestVariables>
): Option<PriceRequestVariables> =
prVariables map { prVar -> prVar withInstallmentType { installmentType } }
对此有什么想法吗?您可以添加JDK、Kotlin和您正在使用的任何扩展的版本吗。
VerifyError
是一件非常糟糕的事情,因此这可能是不兼容或编译器错误。我正在使用JDK 1.8.0_192、Kotlin 1.3.41和Spring Boot 2.1.6.release。我建议使用最新和最好的Kotlin(1.3.50),如果不起作用,请报告错误。我已切换到最新版本的Kotlin,但是仍然面临这个问题。我的一个解决方案是创建子类。
fun addInstallmentTypeToPRVariables(
installmentType: InstallmentType,
prVariables: Option<PriceRequestVariables>
): Option<PriceRequestVariables> =
prVariables map { prVar -> prVar withInstallmentType { installmentType } }
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
ro/orange/eshop/personalisationengineapiimpl/domain/service/ProductSalePriceService.getPriceVariants(Lro/orange/eshop/personalisationengineapiimpl/domain/model/PriceVariantsRequest;)Ljava/util/List; @83: invokespecial
Reason:
Type 'java/lang/Object' (current frame, stack[4]) is not assignable to 'ro/orange/eshop/personalisationengineapiimpl/domain/service/Option'
Current Frame:
bci: @83
flags: { }
locals: { 'ro/orange/eshop/personalisationengineapiimpl/domain/service/ProductSalePriceService', 'ro/orange/eshop/personalisationengineapiimpl/domain/model/PriceVariantsRequest', 'java/lang/Object', 'ro/orange/eshop/personalisationengineapiimpl/domain/service/Option$Some', integer, 'ro/orange/eshop/personalisationengineapiimpl/domain/service/Option$Some' }
stack: { 'kotlin/sequences/Sequence', uninitialized 77, uninitialized 77, 'ro/orange/eshop/personalisationengineapiimpl/domain/service/ProductSalePriceService', 'java/lang/Object' }
Bytecode:
0x0000000: 2b12 0bb8 0011 bb00 1359 2bb7 0017 4e03
0x0000010: 3604 2d3a 0519 05c1 0019 9900 072d a700
0x0000020: 272d b600 1dc0 001f 3a06 0336 072a 1906
0x0000030: b600 233a 0a19 0a3a 0bbb 0013 5919 0bb7
0x0000040: 0017 c000 2500 4db8 002b b800 31bb 0033
0x0000050: 592a 2cb7 0036 c000 38b8 003e 5703 3eb8
0x0000060: 0044 b0
Stackmap Table:
full_frame(@33,{Object[#2],Object[#31],Top,Object[#19],Integer,Object[#19]},{})
same_locals_1_stack_item_frame(@69,Object[#4])