FIR: build functional type for SAM with receiver properly

This commit is contained in:
Jinseong Jeon
2021-01-04 13:25:03 -08:00
committed by Mikhail Glukhikh
parent f618763250
commit d53354057a
8 changed files with 16 additions and 9 deletions
@@ -78,7 +78,13 @@ fun createFunctionalType(
}
val functionalTypeId = ClassId(kind.packageFqName, kind.numberedClassName(receiverAndParameterTypes.size - 1))
return ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(functionalTypeId), receiverAndParameterTypes.toTypedArray(), isNullable = false)
val attributes = if (receiverType != null) ConeAttributes.WithExtensionFunctionType else ConeAttributes.Empty
return ConeClassLikeTypeImpl(
ConeClassLikeLookupTagImpl(functionalTypeId),
receiverAndParameterTypes.toTypedArray(),
isNullable = false,
attributes = attributes
)
}
fun createKPropertyType(
@@ -346,7 +346,8 @@ private fun FirSimpleFunction.getFunctionTypeForAbstractMethod(): ConeLookupTagB
}
return createFunctionalType(
parameterTypes, receiverType = null,
parameterTypes,
receiverType = receiverTypeRef?.coneType,
rawReturnType = returnTypeRef.coneType,
isSuspend = this.isSuspend
)
@@ -61,7 +61,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
isExtensionFunction: Boolean
): SimpleTypeMarker {
val attributes = if (isExtensionFunction) // TODO: assert correct type constructor
ConeAttributes.create(listOf(CompilerConeAttributes.ExtensionFunctionType))
ConeAttributes.WithExtensionFunctionType
else ConeAttributes.Empty
@Suppress("UNCHECKED_CAST")
return when (constructor) {