Remove SAFE_CALL_IN_QUALIFIER diagnostic which was never reported
See UNEXPECTED_SAFE_CALL which is reported instead
This commit is contained in:
@@ -28,9 +28,9 @@ import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
|
|||||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData;
|
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -502,8 +502,6 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory1<KtExpression, String> ILLEGAL_SELECTOR = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, String> ILLEGAL_SELECTOR = DiagnosticFactory1.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory0<PsiElement> SAFE_CALL_IN_QUALIFIER = DiagnosticFactory0.create(ERROR);
|
|
||||||
|
|
||||||
DiagnosticFactory2<KtExpression, KtExpression, KotlinType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<KtExpression, KtExpression, KotlinType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
||||||
DiagnosticFactory2<KtExpression, KtExpression, Boolean> FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION);
|
DiagnosticFactory2<KtExpression, KtExpression, Boolean> FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION);
|
||||||
|
|
||||||
|
|||||||
-2
@@ -473,8 +473,6 @@ public class DefaultErrorMessages {
|
|||||||
|
|
||||||
MAP.put(ILLEGAL_SELECTOR, "Expression ''{0}'' cannot be a selector (occur after a dot)", STRING);
|
MAP.put(ILLEGAL_SELECTOR, "Expression ''{0}'' cannot be a selector (occur after a dot)", STRING);
|
||||||
|
|
||||||
MAP.put(SAFE_CALL_IN_QUALIFIER, "Safe call is not allowed for qualifier");
|
|
||||||
|
|
||||||
MAP.put(NO_TAIL_CALLS_FOUND, "A function is marked as tail-recursive but no tail calls are found");
|
MAP.put(NO_TAIL_CALLS_FOUND, "A function is marked as tail-recursive but no tail calls are found");
|
||||||
MAP.put(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION, "A type annotation is required on a value parameter");
|
MAP.put(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION, "A type annotation is required on a value parameter");
|
||||||
MAP.put(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP, "'break' and 'continue' are only allowed inside a loop");
|
MAP.put(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP, "'break' and 'continue' are only allowed inside a loop");
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
|||||||
packageFragmentForVisibilityCheck: PackageFragmentDescriptor?
|
packageFragmentForVisibilityCheck: PackageFragmentDescriptor?
|
||||||
): ImportingScope? { // null if some error happened
|
): ImportingScope? { // null if some error happened
|
||||||
val importedReference = importDirective.importedReference ?: return null
|
val importedReference = importDirective.importedReference ?: return null
|
||||||
val path = importedReference.asQualifierPartList(trace)
|
val path = importedReference.asQualifierPartList()
|
||||||
val lastPart = path.lastOrNull() ?: return null
|
val lastPart = path.lastOrNull() ?: return null
|
||||||
val packageFragmentForCheck =
|
val packageFragmentForCheck =
|
||||||
when {
|
when {
|
||||||
@@ -270,7 +270,7 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
|||||||
storeResult(trace, lastPart.expression, descriptors, shouldBeVisibleFrom = null, position = QualifierPosition.IMPORT, isQualifier = false)
|
storeResult(trace, lastPart.expression, descriptors, shouldBeVisibleFrom = null, position = QualifierPosition.IMPORT, isQualifier = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KtExpression.asQualifierPartList(trace: BindingTrace): List<QualifierPart> {
|
private fun KtExpression.asQualifierPartList(): List<QualifierPart> {
|
||||||
val result = SmartList<QualifierPart>()
|
val result = SmartList<QualifierPart>()
|
||||||
var expression: KtExpression? = this
|
var expression: KtExpression? = this
|
||||||
loop@ while (expression != null) {
|
loop@ while (expression != null) {
|
||||||
@@ -284,9 +284,6 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
|||||||
result.add(QualifierPart(it.getReferencedNameAsName(), it))
|
result.add(QualifierPart(it.getReferencedNameAsName(), it))
|
||||||
}
|
}
|
||||||
expression = expression.receiverExpression
|
expression = expression.receiverExpression
|
||||||
if (expression is KtSafeQualifiedExpression) {
|
|
||||||
trace.report(Errors.SAFE_CALL_IN_QUALIFIER.on(expression.operationTokenNode.psi))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> expression = null
|
else -> expression = null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user