Fix computation of erased receiver for intersection types

#KT-9630 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2016-12-26 18:07:38 +03:00
parent f7d64ac807
commit 38a2518498
14 changed files with 205 additions and 1 deletions
@@ -106,7 +106,19 @@ fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescript
for (typeProjection in receiverType.arguments) {
fakeTypeArguments.add(TypeProjectionImpl(typeProjection.projectionKind, DONT_CARE))
}
return KotlinTypeFactory.simpleType(receiverType.annotations, receiverType.constructor, fakeTypeArguments,
val receiverTypeConstructor = if (receiverType.constructor is IntersectionTypeConstructor) {
val superTypesWithFakeArguments = receiverType.constructor.supertypes.map { supertype ->
val fakeArguments = supertype.arguments.map { TypeProjectionImpl(it.projectionKind, DONT_CARE) }
supertype.replace(fakeArguments)
}
IntersectionTypeConstructor(superTypesWithFakeArguments)
} else {
receiverType.constructor
}
return KotlinTypeFactory.simpleType(receiverType.annotations, receiverTypeConstructor, fakeTypeArguments,
receiverType.isMarkedNullable, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true))
}