Fixed exception AssertionError: Illegal resolved call to variable with invoke

#KT-13330 Fixed
#KT-13349 Fixed
This commit is contained in:
Stanislav Erokhin
2016-08-03 17:11:40 +03:00
parent 926deebff5
commit 85a951db52
6 changed files with 49 additions and 2 deletions
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.Call
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
import org.jetbrains.kotlin.psi.KtDestructuringDeclarationEntry
import org.jetbrains.kotlin.psi.KtOperationReferenceExpression
@@ -42,9 +43,10 @@ class OperatorCallChecker : CallChecker {
if (resolvedCall is VariableAsFunctionResolvedCall &&
call is CallTransformer.CallForImplicitInvoke && call.itIsVariableAsFunctionCall) {
val outerCall = call.outerCall
if (isConventionCall(outerCall) || outerCall.typeArguments.isNotEmpty()) {
if (isConventionCall(outerCall) || isWrongCallWithExplicitTypeArguments(resolvedCall, outerCall)) {
throw AssertionError("Illegal resolved call to variable with invoke for $outerCall. " +
"Variable: ${resolvedCall.variableCall.resultingDescriptor}")
"Variable: ${resolvedCall.variableCall.resultingDescriptor}" +
"Invoke: ${resolvedCall.functionCall.resultingDescriptor}")
}
}
@@ -75,5 +77,14 @@ class OperatorCallChecker : CallChecker {
private fun checkNotErrorOrDynamic(functionDescriptor: FunctionDescriptor): Boolean {
return !functionDescriptor.isDynamic() && !ErrorUtils.isError(functionDescriptor)
}
private fun isWrongCallWithExplicitTypeArguments(
resolvedCall: VariableAsFunctionResolvedCall,
outerCall: Call
): Boolean {
val passedTypeArgumentsToInvoke = outerCall.typeArguments.isNotEmpty() &&
resolvedCall.functionCall.candidateDescriptor.typeParameters.isNotEmpty()
return passedTypeArgumentsToInvoke && resolvedCall.variableCall.candidateDescriptor.typeParameters.isNotEmpty()
}
}
}