[NI] Fix reporting UNSAFE_IMPLICIT_INVOKE_CALL diagnostic

This commit is contained in:
Dmitriy Novozhilov
2019-04-25 17:59:20 +03:00
committed by Mikhail Zarechenskiy
parent 251a02f71d
commit e6deaf3315
10 changed files with 56 additions and 5 deletions
@@ -24,6 +24,8 @@ interface KotlinCall : ResolutionAtom {
val argumentsInParenthesis: List<KotlinCallArgument>
val externalArgument: KotlinCallArgument?
val isForImplicitInvoke: Boolean
}
private fun SimpleKotlinCallArgument.checkReceiverInvariants() {
@@ -76,7 +76,9 @@ class SimpleCandidateFactory(
fromResolution: ReceiverValueWithSmartCastInfo?
): SimpleKotlinCallArgument? =
explicitReceiver as? SimpleKotlinCallArgument ?: // qualifier receiver cannot be safe
fromResolution?.let { ReceiverExpressionKotlinCallArgument(it, isSafeCall = false) } // todo smartcast implicit this
fromResolution?.let {
ReceiverExpressionKotlinCallArgument(it, isSafeCall = false, isForImplicitInvoke = kotlinCall.isForImplicitInvoke)
} // todo smartcast implicit this
private fun KotlinCall.getExplicitDispatchReceiver(explicitReceiverKind: ExplicitReceiverKind) = when (explicitReceiverKind) {
ExplicitReceiverKind.DISPATCH_RECEIVER -> explicitReceiver
@@ -94,7 +96,9 @@ class SimpleCandidateFactory(
val explicitReceiverKind =
if (givenCandidate.dispatchReceiver == null) ExplicitReceiverKind.NO_EXPLICIT_RECEIVER else ExplicitReceiverKind.DISPATCH_RECEIVER
val dispatchArgumentReceiver = givenCandidate.dispatchReceiver?.let { ReceiverExpressionKotlinCallArgument(it, isSafeCall) }
val dispatchArgumentReceiver = givenCandidate.dispatchReceiver?.let {
ReceiverExpressionKotlinCallArgument(it, isSafeCall)
}
return createCandidate(
givenCandidate.descriptor, explicitReceiverKind, dispatchArgumentReceiver, null,
listOf(), givenCandidate.knownTypeParametersResultingSubstitutor