diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt index 664d9b70e0e..f060ab9e1e5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt @@ -261,20 +261,18 @@ class NewResolutionOldInference( ): Boolean { val reference = context.call.calleeExpression as? KtReferenceExpression ?: return false - val errorCadidates = when (kind) { + val errorCandidates = when (kind) { ResolutionKind.Function -> collectErrorCandidatesForFunction(scopeTower, name, detailedReceiver) ResolutionKind.Variable -> collectErrorCandidatesForVariable(scopeTower, name, detailedReceiver) else -> emptyList() } - for (candidate in errorCadidates) { - if (candidate is ErrorCandidate.Classifier) { - context.trace.record(BindingContext.REFERENCE_TARGET, reference, candidate.descriptor) - context.trace.report(Errors.RESOLUTION_TO_CLASSIFIER.on(reference, candidate.descriptor, candidate.kind, candidate.errorMessage)) - return true - } - } - return false + val candidate = errorCandidates.firstOrNull() as? ErrorCandidate.Classifier ?: return false + + context.trace.record(BindingContext.REFERENCE_TARGET, reference, candidate.descriptor) + context.trace.report(Errors.RESOLUTION_TO_CLASSIFIER.on(reference, candidate.descriptor, candidate.kind, candidate.errorMessage)) + + return true } private class ImplicitScopeTowerImpl( diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ErrorCandidateFactory.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ErrorCandidateFactory.kt index e137260173d..6b642d5e0d3 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ErrorCandidateFactory.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ErrorCandidateFactory.kt @@ -31,12 +31,14 @@ enum class WrongResolutionToClassifier(val message: (Name) -> String) { INTERFACE_AS_VALUE({ "Interface $it does not have companion object" }), INTERFACE_AS_FUNCTION({ "Interface $it does not have constructors" }), CLASS_AS_VALUE({ "Class $it does not have companion object" }), - OBJECT_AS_FUNCTION({ " Function 'invoke()' is not found in object $it " }) + OBJECT_AS_FUNCTION({ "Function 'invoke()' is not found in object $it" }) } sealed class ErrorCandidate(val descriptor: D) { - class Classifier(classifierDescriptor: ClassifierDescriptor, val kind: WrongResolutionToClassifier) - : ErrorCandidate(classifierDescriptor) { + class Classifier( + classifierDescriptor: ClassifierDescriptor, + val kind: WrongResolutionToClassifier + ) : ErrorCandidate(classifierDescriptor) { val errorMessage = kind.message(descriptor.name) } } @@ -99,4 +101,4 @@ private fun ErrorCandidateContext.asClassifierCall(asFunction: Boolean) { add(ErrorCandidate.Classifier(classifier, kind)) -} \ No newline at end of file +}