https://kotlinlang.org logo
#jvm-ir-backend-feedback
Title
# jvm-ir-backend-feedback
a

Agi Maulana

03/08/2021, 5:16 AM
Hello, everyone! My app got an error and the app is an Android app, but I think this is the right channel for this topic. As long as I remember, the last thing I've done that might be contributing to this error is enabling the IR compiler on the Android Studio by the following line
Copy code
kotlinOptions.useIR = true
The view model has a LiveData that hold Kotlin's Result class
Copy code
fun doSomething(code: String, price: Long)  {
        repository.doX(code, price)
                .doOnComplete { _priceSubmission.postValue(Result.success(true)) }
                .doOnError { _priceSubmission.postValue(Result.failure(it.cause ?: it)) }
                .fromIo2Ui()
                .subscribe()
                .disposeOnCleared()
}
and the activity observing it by
Copy code
viewModel.priceSubmission.observe(this) { result ->
            if (result.isSuccess) {
                setResult(RESULT_OK)
                finish()
            } else {
                val error = result.exceptionOrNull()
                if (error is HttpException && error.code() == 400) {
                    showDialog()
                } else {
                    ToastUtils.showNetworkFailureToast()
                }
            }
        }
I got an error on runtime
Copy code
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/app/package/ui/MyActivity$onCreate$1.onChanged(Lkotlin/Result;)V @31: invokevirtual
  Reason:
    Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'kotlin/Result'
  Current Frame:
    bci: @31
    flags: { }
    locals: { 'com/app/package/ui/MyActivity$onCreate$1', 'kotlin/Result' }
    stack: { 'java/lang/Object' }
  Bytecode:
    0x0000000: 2b59 c600 09b6 001c a700 0557 0112 1eb8
    0x0000010: 0024 2b59 c600 09b6 001c a700 0557 01b6
    0x0000020: 001c b800 2899 0015 2ab4 000d 02b6 002e
    0x0000030: 2ab4 000d b600 31a7 004d 2b59 c600 09b6
    0x0000040: 001c a700 0557 0112 1eb8 0024 2b59 c600
    0x0000050: 09b6 001c a700 0557 01b6 001c b800 354d
    0x0000060: 2cc1 0037 9900 1a2c c000 37b6 003b 1101
    0x0000070: 90a0 000d 2ab4 000d b800 3ea7 0009 b200
    0x0000080: 44b6 0047 b1                           
  Stackmap Table:
    same_locals_1_stack_item_frame(@11,Object[#24])
    same_locals_1_stack_item_frame(@13,Object[#5])
    same_locals_1_stack_item_frame(@29,Object[#24])
    same_locals_1_stack_item_frame(@31,Object[#5])
    same_frame(@58)
    same_locals_1_stack_item_frame(@69,Object[#24])
    same_locals_1_stack_item_frame(@71,Object[#5])
    same_locals_1_stack_item_frame(@87,Object[#24])
    same_locals_1_stack_item_frame(@89,Object[#5])
    append_frame(@126,Object[#76])
    chop_frame(@132,1)


	at com.app.package.ui.MyActivity.onCreate(MyActivity.kt:36)
	at android.app.Activity.performCreate(Activity.java:7136)
	at android.app.Activity.performCreate(Activity.java:7127)
The 36th line of
MyActivity
is the
priceSubmission
observer Is this Kotlin's IR backend issue? Thanks.
I've tried disabled the IR backend on the Android Studio, and bamm!! the error gone, the tests passed.
i

Ivan Kubyshkin [JetBrains]

03/09/2021, 7:13 AM
Can you file an issue in Youtrack and attach the full code?
a

Agi Maulana

03/18/2021, 2:44 PM
Hi, @Ivan Kubyshkin [JetBrains], I've posted it, this is it. Thanks!
6 Views