[NI] Fix exception explicit qualified receiver and dispatch receiver

This commit is contained in:
Mikhail Zarechenskiy
2017-08-11 12:17:25 +03:00
committed by Stanislav Erokhin
parent 9f71de5f66
commit f42be4aea2
7 changed files with 51 additions and 11 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.resolve.calls.model
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
interface KotlinCall : ResolutionAtom {
@@ -25,7 +26,7 @@ interface KotlinCall : ResolutionAtom {
val explicitReceiver: ReceiverKotlinCallArgument?
// a.(foo)() -- (foo) is dispatchReceiverForInvoke
val dispatchReceiverForInvokeExtension: SimpleKotlinCallArgument? get() = null
val dispatchReceiverForInvokeExtension: ReceiverKotlinCallArgument? get() = null
val name: Name
@@ -62,8 +63,8 @@ fun KotlinCall.checkCallInvariants() {
"Lambda argument or callable reference is not allowed as explicit receiver: $explicitReceiver"
}
(explicitReceiver as? SimpleKotlinCallArgument)?.checkReceiverInvariants()
dispatchReceiverForInvokeExtension?.checkReceiverInvariants()
explicitReceiver.safeAs<SimpleKotlinCallArgument>()?.checkReceiverInvariants()
dispatchReceiverForInvokeExtension.safeAs<SimpleKotlinCallArgument>()?.checkReceiverInvariants()
argumentsInParenthesis.forEach(KotlinCallArgument::checkArgumentInvariants)
externalArgument?.checkArgumentInvariants()
@@ -28,9 +28,13 @@ import org.jetbrains.kotlin.types.UnwrappedType
interface ReceiverKotlinCallArgument : KotlinCallArgument {
val receiver: DetailedReceiver
val isSafeCall: Boolean
}
class QualifierReceiverKotlinCallArgument(override val receiver: QualifierReceiver) : ReceiverKotlinCallArgument {
override val isSafeCall: Boolean
get() = false // TODO: add warning
override fun toString() = "$receiver"
override val isSpread get() = false
@@ -46,8 +50,6 @@ interface PostponableKotlinCallArgument : KotlinCallArgument, ResolutionAtom
interface SimpleKotlinCallArgument : KotlinCallArgument, ReceiverKotlinCallArgument {
override val receiver: ReceiverValueWithSmartCastInfo
val isSafeCall: Boolean
}
interface ExpressionKotlinCallArgument : SimpleKotlinCallArgument, ResolutionAtom