Agi Maulana

    Agi Maulana

    1 year ago
    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
    kotlinOptions.useIR = true
    The view model has a LiveData that hold Kotlin's Result class
    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
    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
    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.
    Ivan Kubyshkin [JetBrains]

    Ivan Kubyshkin [JetBrains]

    1 year ago
    Can you file an issue in Youtrack and attach the full code?
    Agi Maulana

    Agi Maulana

    1 year ago
    Hi, @Ivan Kubyshkin [JetBrains], I've posted it, this is it. Thanks!