From f2e60a0e11c15a754399d3098aae3e352643cbdf Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Fri, 4 Dec 2015 16:02:58 +0300 Subject: [PATCH] Minor. Have to deal with error descriptors like previous resolution does. --- .../kotlin/resolve/calls/tower/ScopeTower.kt | 2 +- .../kotlin/resolve/calls/tower/TowerLevels.kt | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt index 92228300b8f..4e22c916b3a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTower.kt @@ -93,7 +93,7 @@ class InnerClassViaStaticReference(val classDescriptor: ClassDescriptor): Resolu class UnsupportedInnerClassCall(val message: String): ResolutionDiagnostic(ResolutionCandidateApplicability.IMPOSSIBLE_TO_GENERATE) class UsedSmartCastForDispatchReceiver(val smartCastType: KotlinType): ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED) -object ErrorDescriptorDiagnostic : ResolutionDiagnostic(ResolutionCandidateApplicability.INAPPLICABLE) +object ErrorDescriptorDiagnostic : ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED) // todo discuss and change to INAPPLICABLE object SynthesizedDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED) object DynamicDescriptorDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.RESOLVED_SYNTHESIZED) object UnstableSmartCastDiagnostic: ResolutionDiagnostic(ResolutionCandidateApplicability.MAY_THROW_RUNTIME_ERROR) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt index 8df72ea76b7..62ee1fadadb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt @@ -47,15 +47,18 @@ internal abstract class AbstractScopeTowerLevel( val diagnostics = SmartList() diagnostics.addIfNotNull(specialError) - if (ErrorUtils.isError(descriptor)) diagnostics.add(ErrorDescriptorDiagnostic) - if (descriptor.isSynthesized) diagnostics.add(SynthesizedDescriptorDiagnostic) - if (dispatchReceiverSmartCastType != null) diagnostics.add(UsedSmartCastForDispatchReceiver(dispatchReceiverSmartCastType)) - - Visibilities.findInvisibleMember( - dispatchReceiver ?: ReceiverValue.NO_RECEIVER, descriptor, - scopeTower.lexicalScope.ownerDescriptor - )?.let { diagnostics.add(VisibilityError(it)) } + if (ErrorUtils.isError(descriptor)) { + diagnostics.add(ErrorDescriptorDiagnostic) + } + else { + if (descriptor.isSynthesized) diagnostics.add(SynthesizedDescriptorDiagnostic) + if (dispatchReceiverSmartCastType != null) diagnostics.add(UsedSmartCastForDispatchReceiver(dispatchReceiverSmartCastType)) + Visibilities.findInvisibleMember( + dispatchReceiver ?: ReceiverValue.NO_RECEIVER, descriptor, + scopeTower.lexicalScope.ownerDescriptor + )?.let { diagnostics.add(VisibilityError(it)) } + } return CandidateWithBoundDispatchReceiverImpl(dispatchReceiver, descriptor, diagnostics) }