JVM_IR indy-SAM: KT-45069 box lambda 'Unit' return type if needed

This commit is contained in:
Dmitry Petrov
2021-02-20 11:07:48 +03:00
parent 187d4998fa
commit 387d84f826
19 changed files with 561 additions and 3 deletions
@@ -241,6 +241,8 @@ internal class LambdaMetafactoryArgumentsBuilder(
}
if (!checkTypeCompliesWithConstraint(implFun.returnType, constraints.returnType))
return false
if (implFun.returnType.isUnit() && !fakeInstanceMethod.returnType.isUnit())
return false
return true
}
@@ -278,7 +280,9 @@ internal class LambdaMetafactoryArgumentsBuilder(
implParameter.type = implParameter.type.makeNullable()
}
}
if (constraints.returnType.requiresImplLambdaBoxing()) {
if (constraints.returnType.requiresImplLambdaBoxing() ||
implFun.returnType.isUnit() && !fakeInstanceMethod.returnType.isUnit()
) {
implFun.returnType = implFun.returnType.makeNullable()
}
}