[FIR] Fix incorrect resolve of callable reference in function signature (^KT-48304 Fixed)
This commit is contained in:
@@ -378,7 +378,12 @@ class FirCallResolver(
|
||||
noSuccessfulCandidates -> {
|
||||
val errorReference = buildErrorReference(
|
||||
info,
|
||||
ConeUnresolvedReferenceError(info.name),
|
||||
if (applicability == CandidateApplicability.UNSUPPORTED) {
|
||||
val unsupportedResolutionDiagnostic = reducedCandidates.firstOrNull()?.diagnostics?.firstOrNull() as? Unsupported
|
||||
ConeUnsupported(unsupportedResolutionDiagnostic?.message ?: "", unsupportedResolutionDiagnostic?.source)
|
||||
} else {
|
||||
ConeUnresolvedReferenceError(info.name)
|
||||
},
|
||||
callableReferenceAccess.source
|
||||
)
|
||||
resolvedCallableReferenceAtom.resultingReference = errorReference
|
||||
|
||||
+12
-3
@@ -17,8 +17,7 @@ import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.fir.returnExpressions
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirErrorFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirErrorPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzerContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||
@@ -51,7 +50,7 @@ class CandidateFactory private constructor(
|
||||
extensionReceiverValue: ReceiverValue? = null,
|
||||
builtInExtensionFunctionReceiverValue: ReceiverValue? = null
|
||||
): Candidate {
|
||||
return Candidate(
|
||||
val result = Candidate(
|
||||
symbol, dispatchReceiverValue, extensionReceiverValue,
|
||||
explicitReceiverKind, context.inferenceComponents.constraintSystemFactory, baseSystem,
|
||||
builtInExtensionFunctionReceiverValue?.receiverExpression?.let {
|
||||
@@ -65,6 +64,16 @@ class CandidateFactory private constructor(
|
||||
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, ExplicitReceiverKind.BOTH_RECEIVERS -> false
|
||||
}
|
||||
)
|
||||
|
||||
// The counterpart in FE 1.0 checks if the given descriptor is VariableDescriptor yet not PropertyDescriptor.
|
||||
// Here, we explicitly check if the referred declaration/symbol is value parameter, local variable, or backing field.
|
||||
val callSite = callInfo.callSite
|
||||
if (callSite is FirCallableReferenceAccess) {
|
||||
if (symbol is FirValueParameterSymbol || symbol is FirPropertySymbol && symbol.isLocal || symbol is FirBackingFieldSymbol) {
|
||||
result.addDiagnostic(Unsupported("References to variables aren't supported yet", callSite.calleeReference.source))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun ReceiverValue?.isCandidateFromCompanionObjectTypeScope(): Boolean {
|
||||
|
||||
+3
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
@@ -94,3 +95,5 @@ class ManyLambdaExpressionArguments(
|
||||
|
||||
class InfixCallOfNonInfixFunction(val function: FirNamedFunctionSymbol) : ResolutionDiagnostic(INAPPLICABLE_MODIFIER)
|
||||
class OperatorCallOfNonOperatorFunction(val function: FirNamedFunctionSymbol) : ResolutionDiagnostic(INAPPLICABLE_MODIFIER)
|
||||
|
||||
class Unsupported(val message: String, val source: FirSourceElement? = null) : ResolutionDiagnostic(UNSUPPORTED)
|
||||
+4
-2
@@ -156,10 +156,12 @@ class ConeImportFromSingleton(val name: Name) : ConeDiagnostic() {
|
||||
override val reason: String get() = "Import from singleton $name is not allowed"
|
||||
}
|
||||
|
||||
class ConeUnsupportedDynamicType() : ConeDiagnostic() {
|
||||
override val reason: String get() = "Dynamic types are not supported in this context"
|
||||
open class ConeUnsupported(val message: String, val source: FirSourceElement? = null) : ConeDiagnostic() {
|
||||
override val reason: String get() = message
|
||||
}
|
||||
|
||||
class ConeUnsupportedDynamicType : ConeUnsupported("Dynamic types are not supported in this context")
|
||||
|
||||
class ConeDeprecated(val source: FirSourceElement?, val symbol: FirBasedSymbol<*>, val deprecation: Deprecation) : ConeDiagnostic() {
|
||||
override val reason: String get() = "Deprecated: ${deprecation.message}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user