Hello, World! What can you do when you get this k...
# compiler
b
Hello, World! What can you do when you get this kind of errors:
Copy code
> Task :app:compileDebugKotlin
e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong bytecode generated
?
A bit more details:
Copy code
The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.codegen.coroutines.RefinedIntTypesAnalysisKt.performRefinedTypeAnalysis(refinedIntTypesAnalysis.kt:142)
        at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:92)
        at org.jetbrains.kotlin.codegen.FunctionCodegen.endVisit(FunctionCodegen.java:929)
        ... 49 more
Caused by: java.lang.AssertionError: int type expected, but null was found in basic frames
        at org.jetbrains.kotlin.codegen.coroutines.RefinedIntTypesAnalysisKt.performRefinedTypeAnalysis(refinedIntTypesAnalysis.kt:142)
        at org.jetbrains.kotlin.codegen.coroutines.CoroutineTransformerMethodVisitor.spillVariables(CoroutineTransformerMethodVisitor.kt:607)
        at org.jetbrains.kotlin.codegen.coroutines.CoroutineTransformerMethodVisitor.performTransformations(CoroutineTransformerMethodVisitor.kt:145)
        at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:70)
        ... 50 more
w
Ideally find the offending code and file a bug
b
for now I couldn't find it
going to have to go revert little by little I guess...
w
You can try a clean build first (
--rerun-tasks
) to make sure it’s not caching issue
b
ah! 🙂 I'll try
same 😢
if I remove one particular parameter from my method, it works again. But I need to pass this parameter!
w
Is it special somehow? Since this is a bug I would try some differently looking but similar solutions: changing order of parameters, making the function non-inline, etc.
Most obvious backend exceptions should’ve been found by now so you’re likely doing something rare, which means there’s a chance of doing it another way 😛
b
my method is pretty "normal" though:
Copy code
suspend fun getBeneficiaries(
        organizationId: String,
        bankAccountId: String?,
        nextPageToLoad: Int,
        perPage: Int?,
        hidden: Boolean,
        sortBy: String
    )
I tried changing the order of the parameters indeed 🙂 to no avail. If I remove
bankAccountId: String?
it does work.
w
I suppose it’s something about its usage in the body, then. Ideally you’d find whatever causes it directly (e.g. passing this nullable parameter to an inline function called in a specific fashion)
and in the meantime you can maybe change parameter type to
String
and pass some marker value (empty string,
"!!empty!!"
or something similar) and doing
takeIf
in the function body?
b
I'll try
nope, same problem if it's non null
w
Then I’d focus on wherever you’re passing nullable parameter
b
made it to work by removing
hidden
and
sortBy
which, luckily I didn't really need!
thanks a lot for your help
w
You’re welcome 🙂 I still encourage you to file an issue, as you did hit a bug
Probably something with
sortedBy
being an
inline
function with a
crossinline
selector, in which you’ve been capturing
hidden
param
b
no I swear the calling site was very basic too:
Copy code
remoteSource
                    .getBeneficiaries(
                        organizationId = membershipRepository.currentOrganization.id,
                        bankAccountId = if (shouldPassBankAccountIdToBeneficiariesCall()) transferCreationViewModel.bankAccountId else null,
                        nextPageToLoad = nextPageToLoad,
                        perPage = perPage,
                        hidden = false,
                        sortBy = "name:asc"
                    )
it's going to be hard to open a ticket though because I suppose this needs the whole codebase to repro - which is not open source 😞
w
yeah I imagine. Just for clarity, by call site I meant line where you were calling
sortedBy
with the captured
hidden
parameter
b
sorry I don't understand 🙂
sortedBy
is just a String parameter to which I pass a constant. Same for
hidden
, just a Boolean parameter, to which I pass
false
.
w
ahhh I thought you were calling
sortedBy
function on some collection 😄 Didn’t notice that the parameter has the same name, sorry for confusion
Well, I’d still encourage you to file the bug with the stacktrace at least, perhaps Kotlin folks will be able to figure out something without clear repro
b
all right no worries and thanks again! I'll try to find a few moments to do it.
👍 1