Removed hidden descriptors from new resolve
This commit is contained in:
+5
-1
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallableDescriptors
|
|||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyForInvoke
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyForInvoke
|
||||||
|
import org.jetbrains.kotlin.resolve.isAnnotatedAsHidden
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||||
import org.jetbrains.kotlin.types.isDynamic
|
import org.jetbrains.kotlin.types.isDynamic
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
@@ -186,10 +187,13 @@ class NewResolveOldInference(
|
|||||||
// see spec-docs/dynamic-types.md
|
// see spec-docs/dynamic-types.md
|
||||||
if (extensionReceiver != null && extensionReceiver.type.isDynamic()
|
if (extensionReceiver != null && extensionReceiver.type.isDynamic()
|
||||||
&& !towerCandidate.descriptor.extensionReceiverParameter!!.value.type.isDynamic()) {
|
&& !towerCandidate.descriptor.extensionReceiverParameter!!.value.type.isDynamic()) {
|
||||||
candidateCall.addStatus(ResolutionStatus.RECEIVER_PRESENCE_ERROR)
|
|
||||||
return Candidate(ResolutionCandidateStatus(listOf(ExtensionWithStaticTypeWithDynamicReceiver)), candidateCall)
|
return Candidate(ResolutionCandidateStatus(listOf(ExtensionWithStaticTypeWithDynamicReceiver)), candidateCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (towerCandidate.descriptor.isAnnotatedAsHidden()) {
|
||||||
|
return Candidate(ResolutionCandidateStatus(listOf(HiddenDescriptor)), candidateCall)
|
||||||
|
}
|
||||||
|
|
||||||
val callCandidateResolutionContext = CallCandidateResolutionContext.create(
|
val callCandidateResolutionContext = CallCandidateResolutionContext.create(
|
||||||
candidateCall, basicCallContext, candidateTrace, tracing, basicCallContext.call,
|
candidateCall, basicCallContext, candidateTrace, tracing, basicCallContext.call,
|
||||||
ReceiverValue.NO_RECEIVER, CandidateResolveMode.FULLY // todo
|
ReceiverValue.NO_RECEIVER, CandidateResolveMode.FULLY // todo
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ enum class ResolutionCandidateApplicability {
|
|||||||
MAY_THROW_RUNTIME_ERROR, // unsafe call or unstable smart cast
|
MAY_THROW_RUNTIME_ERROR, // unsafe call or unstable smart cast
|
||||||
RUNTIME_ERROR, // problems with visibility
|
RUNTIME_ERROR, // problems with visibility
|
||||||
IMPOSSIBLE_TO_GENERATE, // access to outer class from nested
|
IMPOSSIBLE_TO_GENERATE, // access to outer class from nested
|
||||||
INAPPLICABLE // arguments not matched
|
INAPPLICABLE, // arguments not matched
|
||||||
|
HIDDEN, // removed from resolve
|
||||||
// todo wrong receiver
|
// todo wrong receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +97,7 @@ object ErrorDescriptorDiagnostic : ResolutionDiagnostic(ResolutionCandidateAppli
|
|||||||
object SynthesizedDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED)
|
object SynthesizedDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED)
|
||||||
object DynamicDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED)
|
object DynamicDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED)
|
||||||
object UnstableSmartCastDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.MAY_THROW_RUNTIME_ERROR)
|
object UnstableSmartCastDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.MAY_THROW_RUNTIME_ERROR)
|
||||||
object ExtensionWithStaticTypeWithDynamicReceiver: ResolutionDiagnostic(ResolutionCandidateApplicability.INAPPLICABLE)
|
object ExtensionWithStaticTypeWithDynamicReceiver: ResolutionDiagnostic(ResolutionCandidateApplicability.HIDDEN)
|
||||||
|
object HiddenDescriptor: ResolutionDiagnostic(ResolutionCandidateApplicability.HIDDEN)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -112,11 +112,12 @@ class TowerResolver {
|
|||||||
fun getFinalCandidates() = getResolved() ?: getSyntheticResolved() ?: getErrors() ?: emptyList()
|
fun getFinalCandidates() = getResolved() ?: getSyntheticResolved() ?: getErrors() ?: emptyList()
|
||||||
|
|
||||||
fun pushCandidates(candidates: Collection<C>) {
|
fun pushCandidates(candidates: Collection<C>) {
|
||||||
if (candidates.isEmpty()) return
|
val filteredCandidates = candidates.filter { getStatus(it).resultingApplicability != ResolutionCandidateApplicability.HIDDEN }
|
||||||
val minimalLevel = candidates.map { getStatus(it).resultingApplicability }.min()!!
|
if (filteredCandidates.isEmpty()) return
|
||||||
|
val minimalLevel = filteredCandidates.map { getStatus(it).resultingApplicability }.min()!!
|
||||||
if (currentLevel == null || currentLevel!! > minimalLevel) {
|
if (currentLevel == null || currentLevel!! > minimalLevel) {
|
||||||
currentLevel = minimalLevel
|
currentLevel = minimalLevel
|
||||||
currentCandidates = candidates.filter { getStatus(it).resultingApplicability == minimalLevel }
|
currentCandidates = filteredCandidates.filter { getStatus(it).resultingApplicability == minimalLevel }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user