Minor refactoring in frontend/resolution
Fix typos, formatting, diagnostic message
This commit is contained in:
+7
-9
@@ -261,20 +261,18 @@ class NewResolutionOldInference(
|
|||||||
): Boolean {
|
): Boolean {
|
||||||
val reference = context.call.calleeExpression as? KtReferenceExpression ?: return false
|
val reference = context.call.calleeExpression as? KtReferenceExpression ?: return false
|
||||||
|
|
||||||
val errorCadidates = when (kind) {
|
val errorCandidates = when (kind) {
|
||||||
ResolutionKind.Function -> collectErrorCandidatesForFunction(scopeTower, name, detailedReceiver)
|
ResolutionKind.Function -> collectErrorCandidatesForFunction(scopeTower, name, detailedReceiver)
|
||||||
ResolutionKind.Variable -> collectErrorCandidatesForVariable(scopeTower, name, detailedReceiver)
|
ResolutionKind.Variable -> collectErrorCandidatesForVariable(scopeTower, name, detailedReceiver)
|
||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (candidate in errorCadidates) {
|
val candidate = errorCandidates.firstOrNull() as? ErrorCandidate.Classifier ?: return false
|
||||||
if (candidate is ErrorCandidate.Classifier) {
|
|
||||||
context.trace.record(BindingContext.REFERENCE_TARGET, reference, candidate.descriptor)
|
context.trace.record(BindingContext.REFERENCE_TARGET, reference, candidate.descriptor)
|
||||||
context.trace.report(Errors.RESOLUTION_TO_CLASSIFIER.on(reference, candidate.descriptor, candidate.kind, candidate.errorMessage))
|
context.trace.report(Errors.RESOLUTION_TO_CLASSIFIER.on(reference, candidate.descriptor, candidate.kind, candidate.errorMessage))
|
||||||
return true
|
|
||||||
}
|
return true
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ImplicitScopeTowerImpl(
|
private class ImplicitScopeTowerImpl(
|
||||||
|
|||||||
+6
-4
@@ -31,12 +31,14 @@ enum class WrongResolutionToClassifier(val message: (Name) -> String) {
|
|||||||
INTERFACE_AS_VALUE({ "Interface $it does not have companion object" }),
|
INTERFACE_AS_VALUE({ "Interface $it does not have companion object" }),
|
||||||
INTERFACE_AS_FUNCTION({ "Interface $it does not have constructors" }),
|
INTERFACE_AS_FUNCTION({ "Interface $it does not have constructors" }),
|
||||||
CLASS_AS_VALUE({ "Class $it does not have companion object" }),
|
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<out D: DeclarationDescriptor>(val descriptor: D) {
|
sealed class ErrorCandidate<out D: DeclarationDescriptor>(val descriptor: D) {
|
||||||
class Classifier(classifierDescriptor: ClassifierDescriptor, val kind: WrongResolutionToClassifier)
|
class Classifier(
|
||||||
: ErrorCandidate<ClassifierDescriptor>(classifierDescriptor) {
|
classifierDescriptor: ClassifierDescriptor,
|
||||||
|
val kind: WrongResolutionToClassifier
|
||||||
|
) : ErrorCandidate<ClassifierDescriptor>(classifierDescriptor) {
|
||||||
val errorMessage = kind.message(descriptor.name)
|
val errorMessage = kind.message(descriptor.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,4 +101,4 @@ private fun ErrorCandidateContext.asClassifierCall(asFunction: Boolean) {
|
|||||||
|
|
||||||
|
|
||||||
add(ErrorCandidate.Classifier(classifier, kind))
|
add(ErrorCandidate.Classifier(classifier, kind))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user