[FE] Properly report diagnostics about type arguments of implicit invoke

#KT-40396 Fixed
This commit is contained in:
Dmitriy Novozhilov
2020-12-16 16:10:40 +03:00
committed by TeamCityServer
parent 329066a4f3
commit 44948aa9a2
8 changed files with 64 additions and 10 deletions
@@ -436,8 +436,8 @@ class DiagnosticReporterByTrackingStrategy(
if (isSpecialFunction(error.resolvedAtom))
return
val expression = when (val atom = error.resolvedAtom.atom) {
is PSIKotlinCallForInvoke -> (atom.psiCall as? CallTransformer.CallForImplicitInvoke)?.outerCall?.calleeExpression
is PSIKotlinCall -> atom.psiCall.calleeExpression
is PSIKotlinCallArgument -> atom.valueArgument.getArgumentExpression()
else -> call.calleeExpression
@@ -24,10 +24,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
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
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.calls.CallTransformer
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -52,11 +49,7 @@ class OperatorCallChecker : CallChecker {
val containingDeclarationName = functionDescriptor.containingDeclaration.fqNameUnsafe.asString()
context.trace.report(Errors.PROPERTY_AS_OPERATOR.on(reportOn, functionDescriptor, containingDeclarationName))
} else if (isWrongCallWithExplicitTypeArguments(resolvedCall, outerCall)) {
throw AssertionError(
"Illegal resolved call to variable with invoke for $outerCall. " +
"Variable: ${resolvedCall.variableCall.resultingDescriptor}" +
"Invoke: ${resolvedCall.functionCall.resultingDescriptor}"
)
context.trace.report(Errors.TYPE_ARGUMENTS_NOT_ALLOWED.on(reportOn as KtElement, "on implicit invoke call"))
}
}