K2: Get rid of errorsToIgnore parameter during error reporting
The reason is that it's potentially might lead to some errors are actually ignored leading to false-negatively green code, while on the other hand we don't have any evidences (like tests) that not-having the parameter lead to at least some redundant diagnostics.
This commit is contained in:
committed by
Space Team
parent
ffcb4cd1cb
commit
8519053527
+1
-16
@@ -15,11 +15,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
|||||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.isLocalMember
|
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.isLocalMember
|
||||||
import org.jetbrains.kotlin.fir.analysis.getChild
|
import org.jetbrains.kotlin.fir.analysis.getChild
|
||||||
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
|
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isInfix
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isInner
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isOperator
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.*
|
import org.jetbrains.kotlin.fir.diagnostics.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
|
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
|
||||||
@@ -314,7 +310,6 @@ private fun mapInapplicableCandidateError(
|
|||||||
source,
|
source,
|
||||||
qualifiedAccessSource,
|
qualifiedAccessSource,
|
||||||
session.typeContext,
|
session.typeContext,
|
||||||
mutableSetOf(),
|
|
||||||
diagnostic.candidate
|
diagnostic.candidate
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -345,7 +340,6 @@ private fun mapSystemHasContradictionError(
|
|||||||
source: KtSourceElement,
|
source: KtSourceElement,
|
||||||
qualifiedAccessSource: KtSourceElement?,
|
qualifiedAccessSource: KtSourceElement?,
|
||||||
): List<KtDiagnostic> {
|
): List<KtDiagnostic> {
|
||||||
val errorsToIgnore = mutableSetOf<ConstraintSystemError>()
|
|
||||||
return buildList {
|
return buildList {
|
||||||
for (error in diagnostic.candidate.errors) {
|
for (error in diagnostic.candidate.errors) {
|
||||||
addIfNotNull(
|
addIfNotNull(
|
||||||
@@ -353,7 +347,6 @@ private fun mapSystemHasContradictionError(
|
|||||||
source,
|
source,
|
||||||
qualifiedAccessSource,
|
qualifiedAccessSource,
|
||||||
session.typeContext,
|
session.typeContext,
|
||||||
errorsToIgnore,
|
|
||||||
diagnostic.candidate,
|
diagnostic.candidate,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -361,7 +354,6 @@ private fun mapSystemHasContradictionError(
|
|||||||
}.ifEmpty {
|
}.ifEmpty {
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
diagnostic.candidate.errors.firstNotNullOfOrNull {
|
diagnostic.candidate.errors.firstNotNullOfOrNull {
|
||||||
if (it in errorsToIgnore) return@firstNotNullOfOrNull null
|
|
||||||
val message = when (it) {
|
val message = when (it) {
|
||||||
is NewConstraintError -> "NewConstraintError at ${it.position}: ${it.lowerType} <!: ${it.upperType}"
|
is NewConstraintError -> "NewConstraintError at ${it.position}: ${it.lowerType} <!: ${it.upperType}"
|
||||||
// Error should be reported on the error type itself
|
// Error should be reported on the error type itself
|
||||||
@@ -387,7 +379,6 @@ private fun ConstraintSystemError.toDiagnostic(
|
|||||||
source: KtSourceElement,
|
source: KtSourceElement,
|
||||||
qualifiedAccessSource: KtSourceElement?,
|
qualifiedAccessSource: KtSourceElement?,
|
||||||
typeContext: ConeTypeContext,
|
typeContext: ConeTypeContext,
|
||||||
errorsToIgnore: MutableSet<ConstraintSystemError>,
|
|
||||||
candidate: AbstractCandidate,
|
candidate: AbstractCandidate,
|
||||||
): KtDiagnostic? {
|
): KtDiagnostic? {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
@@ -427,12 +418,6 @@ private fun ConstraintSystemError.toDiagnostic(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ExplicitTypeParameterConstraintPosition<*>,
|
|
||||||
is DelegatedPropertyConstraintPosition<*> -> {
|
|
||||||
errorsToIgnore.add(this)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user