提交 d5c75ae7 编写于 作者: A Alexander Udalov

Minor refactoring in frontend/resolution

Fix typos, formatting, diagnostic message
上级 921694e1
......@@ -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(
......
......@@ -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))
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册