[NI] Don't report uninferred type parameter error on special functions
Type parameters can't be specified explicitly for special constructions. Reporting this error does not help fixing the cause of it and needlessly reveals implementation details. ^KT-36342 Fixed
This commit is contained in:
+12
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
@@ -391,6 +392,9 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
}
|
||||
) return
|
||||
|
||||
if (isSpecialFunction(error.resolvedAtom))
|
||||
return
|
||||
|
||||
val expression = when (val atom = error.resolvedAtom.atom) {
|
||||
is PSIKotlinCall -> atom.psiCall.calleeExpression
|
||||
is PSIKotlinCallArgument -> atom.valueArgument.getArgumentExpression()
|
||||
@@ -407,6 +411,14 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSpecialFunction(atom: ResolvedAtom): Boolean {
|
||||
if (atom !is ResolvedCallAtom) return false
|
||||
|
||||
return ControlStructureTypingUtils.ResolveConstruct.values().any { specialFunction ->
|
||||
specialFunction.specialFunctionName == atom.candidateDescriptor.name
|
||||
}
|
||||
}
|
||||
|
||||
private fun reportConstantTypeMismatch(constraintError: NewConstraintError, expression: KtExpression): Boolean {
|
||||
if (expression is KtConstantExpression) {
|
||||
val module = context.scope.ownerDescriptor.module
|
||||
|
||||
Reference in New Issue
Block a user