KT-51284 Fix SAM conversion for methods with context receivers

This commit is contained in:
Pavel Mikhailovskii
2022-12-07 09:01:21 +00:00
committed by Space Team
parent cc9beb466e
commit 4676072137
5 changed files with 42 additions and 4 deletions
@@ -17456,6 +17456,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/iteratorOperator.kt");
}
@Test
@TestMetadata("kt51284.kt")
public void testKt51284() throws Exception {
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt51284.kt");
}
@Test
@TestMetadata("kt51863.kt")
public void testKt51863() throws Exception {
@@ -387,12 +387,15 @@ private fun FirSimpleFunction.getFunctionTypeForAbstractMethod(): ConeLookupTagB
val parameterTypes = valueParameters.map {
it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: ConeErrorType(ConeIntermediateDiagnostic("No type for parameter $it"))
}
val contextReceiversTypes = contextReceivers.map {
it.typeRef.coneTypeSafe<ConeKotlinType>() ?: ConeErrorType(ConeIntermediateDiagnostic("No type for context receiver $it"))
}
return createFunctionalType(
parameterTypes,
receiverType = receiverParameter?.typeRef?.coneType,
rawReturnType = returnTypeRef.coneType,
isSuspend = this.isSuspend
isSuspend = this.isSuspend,
contextReceivers = contextReceiversTypes
)
}