Compilation issue after upgrading to 1.2.50


#1

I have compilation issue on code using generic since upgrade to 1.2.50.

        sequenceOfValidations(
            { projectId.length < 3 } to { "projectId" to ErrorMessage("Project id should have at least three characters") },
            { projectId.contains(' ') } to { "projectId" to ErrorMessage("Project id should not contains space") }
        ).flatMap {

with the following code :

package validations

import arrow.data.*

fun sequenceOfValidations(vararg validations: Pair<() -> Boolean, () -> Pair<String, ErrorDetail>>): OnSuccessHandler =
ValidationsEvents(
validations.filter { (validator, ) -> validator() }.map { (, errorFactory) -> errorFactory() })

interface OnSuccessHandler {
fun map(block: () -> V): ValidatedNel<Pair<String, ErrorDetail>, V>
fun flatMap(block: () -> ValidatedNel<Pair<String, ErrorDetail>, V>): ValidatedNel<Pair<String, ErrorDetail>, V>
}

private class ValidationsEvents(val validationResults: List<Pair<String, ErrorDetail>>) : OnSuccessHandler {
override fun map(block: () -> V): ValidatedNel<Pair<String, ErrorDetail>, V> =
if (validationResults.isEmpty()) {
block().validNel()
} else {
buildInvalidNel()
}

override fun <V> flatMap(block: () -> ValidatedNel<Pair<String, ErrorDetail>, V>): ValidatedNel<Pair<String, ErrorDetail>, V> =
    if (validationResults.isEmpty()) {
        block()
    } else {
        buildInvalidNel()
    }

private fun <V> buildInvalidNel(): ValidatedNel<Pair<String, ErrorDetail>, V> {
    return if (validationResults.size == 1) {
        validationResults[0].invalidNel()
    } else {
        NonEmptyList(
            validationResults[0],
            validationResults.subList(1, validationResults.size)
        ).invalid()
    }
}

}

The compiler error is the following:

File being compiled at position: (36,23) in
The root cause was thrown at: SerializerExtension.kt:61
at org.jetbrains.kotlin.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:317)
at org.jetbrains.kotlin.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:278)
at org.jetbrains.kotlin.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:323)
at org.jetbrains.kotlin.codegen.CallGenerator$DefaultCallGenerator.genValueAndPut(CallGenerator.kt:53)
at org.jetbrains.kotlin.codegen.CallBasedArgumentGenerator.generateExpression(CallBasedArgumentGenerator.java:51)
at org.jetbrains.kotlin.codegen.ArgumentGenerator.generate(ArgumentGenerator.kt:68)
at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2374)
at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2351)
at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:41)
at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:13)
at org.jetbrains.kotlin.codegen.OperationStackValue.putSelector(StackValue.kt:79)
at org.jetbrains.kotlin.codegen.StackValueWithLeaveTask.putSelector(StackValue.kt:67)
at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:110)
at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:99)
at org.jetbrains.kotlin.codegen.ExpressionCodegen.putStackValue(ExpressionCodegen.java:347)
at org.jetbrains.kotlin.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:332)
at org.jetbrains.kotlin.codegen.ExpressionCodegen.returnExpression(ExpressionCodegen.java:1627)
at org.jetbrains.kotlin.codegen.FunctionGenerationStrategy$FunctionDefault.doGenerateBody(FunctionGenerationStrategy.java:60)
at org.jetbrains.kotlin.codegen.ClosureGenerationStrategy.doGenerateBody(ClosureGenerationStrategy.kt:31)
at org.jetbrains.kotlin.codegen.FunctionGenerationStrategy$CodegenBased.generateBody(FunctionGenerationStrategy.java:80)
at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethodBody(FunctionCodegen.java:643)
at org.jetbrains.kotlin.codegen.inline.PsiSourceCompilerForInline.generateMethodBody(SourceCompilerForInline.kt:202)
at org.jetbrains.kotlin.codegen.inline.PsiSourceCompilerForInline.generateLambdaBody(SourceCompilerForInline.kt:154)


#2

Please use YouTrack for bug reports like these. Thank you!


#3

That’s done, and I found a simplest example: https://youtrack.jetbrains.com/issue/KT-24964.