Minor refactoring in frontend/resolution
Fix typos, formatting, diagnostic message
This commit is contained in:
+7
-9
@@ -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(
|
||||
|
||||
+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_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<out D: DeclarationDescriptor>(val descriptor: D) {
|
||||
class Classifier(classifierDescriptor: ClassifierDescriptor, val kind: WrongResolutionToClassifier)
|
||||
: ErrorCandidate<ClassifierDescriptor>(classifierDescriptor) {
|
||||
class Classifier(
|
||||
classifierDescriptor: ClassifierDescriptor,
|
||||
val kind: WrongResolutionToClassifier
|
||||
) : ErrorCandidate<ClassifierDescriptor>(classifierDescriptor) {
|
||||
val errorMessage = kind.message(descriptor.name)
|
||||
}
|
||||
}
|
||||
@@ -99,4 +101,4 @@ private fun ErrorCandidateContext.asClassifierCall(asFunction: Boolean) {
|
||||
|
||||
|
||||
add(ErrorCandidate.Classifier(classifier, kind))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user