Removed hidden descriptors from new resolve

This commit is contained in:
Stanislav Erokhin
2015-11-27 14:59:36 +03:00
parent e92c314b46
commit 3776e5698f
3 changed files with 13 additions and 6 deletions
@@ -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.TracingStrategy
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.types.isDynamic
import org.jetbrains.kotlin.util.OperatorNameConventions
@@ -186,10 +187,13 @@ class NewResolveOldInference(
// see spec-docs/dynamic-types.md
if (extensionReceiver != null && extensionReceiver.type.isDynamic()
&& !towerCandidate.descriptor.extensionReceiverParameter!!.value.type.isDynamic()) {
candidateCall.addStatus(ResolutionStatus.RECEIVER_PRESENCE_ERROR)
return Candidate(ResolutionCandidateStatus(listOf(ExtensionWithStaticTypeWithDynamicReceiver)), candidateCall)
}
if (towerCandidate.descriptor.isAnnotatedAsHidden()) {
return Candidate(ResolutionCandidateStatus(listOf(HiddenDescriptor)), candidateCall)
}
val callCandidateResolutionContext = CallCandidateResolutionContext.create(
candidateCall, basicCallContext, candidateTrace, tracing, basicCallContext.call,
ReceiverValue.NO_RECEIVER, CandidateResolveMode.FULLY // todo
@@ -79,7 +79,8 @@ enum class ResolutionCandidateApplicability {
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 not matched
INAPPLICABLE, // arguments not matched
HIDDEN, // removed from resolve
// todo wrong receiver
}
@@ -96,6 +97,7 @@ object ErrorDescriptorDiagnostic : ResolutionDiagnostic(ResolutionCandidateAppli
object SynthesizedDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED)
object DynamicDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED)
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 pushCandidates(candidates: Collection<C>) {
if (candidates.isEmpty()) return
val minimalLevel = candidates.map { getStatus(it).resultingApplicability }.min()!!
val filteredCandidates = candidates.filter { getStatus(it).resultingApplicability != ResolutionCandidateApplicability.HIDDEN }
if (filteredCandidates.isEmpty()) return
val minimalLevel = filteredCandidates.map { getStatus(it).resultingApplicability }.min()!!
if (currentLevel == null || currentLevel!! > minimalLevel) {
currentLevel = minimalLevel
currentCandidates = candidates.filter { getStatus(it).resultingApplicability == minimalLevel }
currentCandidates = filteredCandidates.filter { getStatus(it).resultingApplicability == minimalLevel }
}
}
}