Introduce original for ReceiverValue and use it inside coroutine checker

This commit is contained in:
Mikhail Zarechenskiy
2018-05-04 18:40:21 +03:00
parent b23e9f771b
commit 54ca2cbbe0
13 changed files with 88 additions and 41 deletions
@@ -22,9 +22,12 @@ import org.jetbrains.kotlin.types.KotlinType
fun getReceiverValueWithSmartCast(
receiverArgument: ReceiverValue?,
smartCastType: KotlinType?
) = smartCastType?.let(::SmartCastReceiverValue) ?: receiverArgument
) = smartCastType?.let { type -> SmartCastReceiverValue(type, original = null) } ?: receiverArgument
private class SmartCastReceiverValue(private val type: KotlinType, original: SmartCastReceiverValue?) : ReceiverValue {
private val original = original ?: this
private class SmartCastReceiverValue(private val type: KotlinType) : ReceiverValue {
override fun getType() = type
override fun replaceType(newType: KotlinType) = SmartCastReceiverValue(newType)
override fun replaceType(newType: KotlinType) = SmartCastReceiverValue(newType, original)
override fun getOriginal() = original
}