Change order of enum entries in CandidateApplicability

This commit is contained in:
Dmitriy Novozhilov
2020-09-08 11:27:14 +03:00
parent d1568c1ce6
commit cd557ad178
4 changed files with 19 additions and 19 deletions
@@ -6,20 +6,20 @@
package org.jetbrains.kotlin.resolve.calls.tower
enum class CandidateApplicability {
RESOLVED, // call success or has uncompleted inference or in other words possible successful candidate
RESOLVED_WITH_ERROR, // call has error, but it is still successful from resolution perspective
RESOLVED_NEED_PRESERVE_COMPATIBILITY, // call resolved successfully, but using new features that changes resolve
RESOLVED_LOW_PRIORITY,
CONVENTION_ERROR, // missing infix, operator etc
MAY_THROW_RUNTIME_ERROR, // unsafe call or unstable smart cast
RUNTIME_ERROR, // problems with visibility
IMPOSSIBLE_TO_GENERATE, // access to outer class from nested
INAPPLICABLE, // arguments have wrong types
INAPPLICABLE_ARGUMENTS_MAPPING_ERROR, // arguments not mapped to parameters (i.e. different size of arguments and parameters)
INAPPLICABLE_WRONG_RECEIVER, // receiver not matched
HIDDEN, // removed from resolve
RESOLVED_TO_SAM_WITH_VARARG, // migration warning up to 1.5 (when resolve to function with SAM conversion and array without spread as vararg)
HIDDEN, // removed from resolve
INAPPLICABLE_WRONG_RECEIVER, // receiver not matched
INAPPLICABLE_ARGUMENTS_MAPPING_ERROR, // arguments not mapped to parameters (i.e. different size of arguments and parameters)
INAPPLICABLE, // arguments have wrong types
IMPOSSIBLE_TO_GENERATE, // access to outer class from nested
RUNTIME_ERROR, // problems with visibility
MAY_THROW_RUNTIME_ERROR, // unsafe call or unstable smart cast
CONVENTION_ERROR, // missing infix, operator etc
RESOLVED_LOW_PRIORITY,
RESOLVED_NEED_PRESERVE_COMPATIBILITY, // call resolved successfully, but using new features that changes resolve
RESOLVED_WITH_ERROR, // call has error, but it is still successful from resolution perspective
RESOLVED, // call success or has uncompleted inference or in other words possible successful candidate
}
val CandidateApplicability.isSuccess: Boolean
get() = this <= CandidateApplicability.RESOLVED_LOW_PRIORITY
get() = this >= CandidateApplicability.RESOLVED_LOW_PRIORITY
@@ -102,7 +102,7 @@ class KotlinResolutionCandidate(
override fun addDiagnostic(diagnostic: KotlinCallDiagnostic) {
diagnosticsFromResolutionParts.add(diagnostic)
currentApplicability = maxOf(diagnostic.candidateApplicability, currentApplicability)
currentApplicability = minOf(diagnostic.candidateApplicability, currentApplicability)
}
fun getSubResolvedAtoms(): List<ResolvedAtom> = subResolvedAtoms
@@ -168,7 +168,7 @@ class KotlinResolutionCandidate(
processParts(stopOnFirstError = false)
val systemApplicability = getResultApplicability(getSystem().errors)
return maxOf(currentApplicability, systemApplicability, variableApplicability)
return minOf(currentApplicability, systemApplicability, variableApplicability)
}
override fun addCompatibilityWarning(other: Candidate) {
@@ -91,11 +91,11 @@ class CandidateWithBoundDispatchReceiver(
@JvmName("getResultApplicabilityForConstraintErrors")
fun getResultApplicability(diagnostics: Collection<ConstraintSystemError>): CandidateApplicability =
diagnostics.maxByOrNull { it.applicability }?.applicability ?: RESOLVED
diagnostics.minByOrNull { it.applicability }?.applicability ?: RESOLVED
@JvmName("getResultApplicabilityForCallDiagnostics")
fun getResultApplicability(diagnostics: Collection<KotlinCallDiagnostic>): CandidateApplicability =
diagnostics.maxByOrNull { it.candidateApplicability }?.candidateApplicability ?: RESOLVED
diagnostics.minByOrNull { it.candidateApplicability }?.candidateApplicability ?: RESOLVED
abstract class ResolutionDiagnostic(candidateApplicability: CandidateApplicability) :
KotlinCallDiagnostic(candidateApplicability) {
@@ -376,7 +376,7 @@ class TowerResolver {
}
override fun getFinalCandidates(): Collection<C> {
val moreSuitableGroup = candidateGroups.minByOrNull { it.groupApplicability } ?: return emptyList()
val moreSuitableGroup = candidateGroups.maxByOrNull { it.groupApplicability } ?: return emptyList()
val groupApplicability = moreSuitableGroup.groupApplicability
if (groupApplicability == CandidateApplicability.HIDDEN) return emptyList()
@@ -384,6 +384,6 @@ class TowerResolver {
}
private val Collection<C>.groupApplicability: CandidateApplicability
get() = minOfOrNull { it.resultingApplicability } ?: CandidateApplicability.HIDDEN
get() = maxOfOrNull { it.resultingApplicability } ?: CandidateApplicability.HIDDEN
}
}