FIR: introduce helpers to get resolved reference / symbol
This commit is contained in:
+2
-2
@@ -13,8 +13,8 @@ import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentList
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirSuperReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
@@ -26,7 +26,7 @@ object FirSuperCallWithDefaultsChecker : FirFunctionCallChecker() {
|
||||
?: return
|
||||
|
||||
val functionSymbol =
|
||||
(expression.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirNamedFunctionSymbol ?: return
|
||||
expression.calleeReference.resolvedSymbol as? FirNamedFunctionSymbol ?: return
|
||||
if (!functionSymbol.valueParameterSymbols.any { it.hasDefaultValue }) return
|
||||
val arguments = expression.argumentList as? FirResolvedArgumentList ?: return
|
||||
if (arguments.arguments.size < functionSymbol.valueParameterSymbols.size) {
|
||||
|
||||
+3
-3
@@ -20,10 +20,10 @@ import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.resolved
|
||||
import org.jetbrains.kotlin.fir.symbols.ensureResolved
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
@@ -40,7 +40,7 @@ fun FirRegularClass.getRetention(): AnnotationRetention {
|
||||
fun FirAnnotation.getRetention(): AnnotationRetention {
|
||||
val retentionArgument = findArgumentByName(ParameterNames.retentionValue) as? FirQualifiedAccessExpression
|
||||
?: return AnnotationRetention.RUNTIME
|
||||
val retentionName = (retentionArgument.calleeReference as? FirResolvedNamedReference)?.name?.asString()
|
||||
val retentionName = retentionArgument.calleeReference.resolved?.name?.asString()
|
||||
?: return AnnotationRetention.RUNTIME
|
||||
return AnnotationRetention.values().firstOrNull { it.name == retentionName } ?: AnnotationRetention.RUNTIME
|
||||
}
|
||||
@@ -74,7 +74,7 @@ fun FirClassLikeSymbol<*>.getAllowedAnnotationTargets(): Set<KotlinTarget> {
|
||||
|
||||
return arguments.mapNotNullTo(mutableSetOf()) { argument ->
|
||||
val targetExpression = argument as? FirQualifiedAccessExpression
|
||||
val targetName = (targetExpression?.calleeReference as? FirResolvedNamedReference)?.name?.asString() ?: return@mapNotNullTo null
|
||||
val targetName = targetExpression?.calleeReference?.resolved?.name?.asString() ?: return@mapNotNullTo null
|
||||
KotlinTarget.values().firstOrNull { target -> target.name == targetName }
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,11 +19,11 @@ import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeConstraintSystemHasContradiction
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableCandidateError
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.ensureResolved
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
@@ -185,7 +185,7 @@ object FirDestructuringDeclarationChecker : FirPropertyChecker() {
|
||||
|
||||
private val FirQualifiedAccessExpression.resolvedVariable: FirVariable?
|
||||
get() {
|
||||
val symbol = (calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirVariableSymbol<*> ?: return null
|
||||
val symbol = calleeReference.resolvedSymbol as? FirVariableSymbol<*> ?: return null
|
||||
symbol.ensureResolved(FirResolvePhase.BODY_RESOLVE)
|
||||
@OptIn(SymbolInternals::class)
|
||||
return symbol.fir
|
||||
|
||||
+2
-3
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
@@ -92,10 +92,9 @@ object FirFunctionParameterChecker : FirFunctionChecker() {
|
||||
}
|
||||
|
||||
override fun visitQualifiedAccessExpression(qualifiedAccessExpression: FirQualifiedAccessExpression) {
|
||||
val namedReference = qualifiedAccessExpression.calleeReference as? FirResolvedNamedReference ?: return
|
||||
|
||||
@OptIn(SymbolInternals::class)
|
||||
val referredParameter = namedReference.resolvedSymbol.fir as? FirValueParameter ?: return
|
||||
val referredParameter = qualifiedAccessExpression.calleeReference.resolvedSymbol?.fir as? FirValueParameter ?: return
|
||||
val referredParameterIndex = function.valueParameters.indexOf(referredParameter)
|
||||
// Skip if the referred parameter is not declared in the same function.
|
||||
if (referredParameterIndex < 0) return
|
||||
|
||||
+2
-2
@@ -13,14 +13,14 @@ import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCallOrigin
|
||||
import org.jetbrains.kotlin.fir.expressions.FirOperationNameConventions
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.isUnit
|
||||
|
||||
object FirAssignmentOperatorCallChecker : FirFunctionCallChecker() {
|
||||
override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val resolvedCallee = expression.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val resolvedCalleeSymbol = resolvedCallee.resolvedSymbol as? FirNamedFunctionSymbol ?: return
|
||||
val resolvedCalleeSymbol = expression.calleeReference.resolvedSymbol as? FirNamedFunctionSymbol ?: return
|
||||
val resolvedCalleeName = resolvedCalleeSymbol.name
|
||||
if (expression.origin != FirFunctionCallOrigin.Operator ||
|
||||
resolvedCalleeName !in FirOperationNameConventions.ASSIGNMENT_NAMES
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolved
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
|
||||
@@ -35,7 +35,7 @@ object FirCallableReferenceChecker : FirQualifiedAccessExpressionChecker() {
|
||||
reporter: DiagnosticReporter
|
||||
) {
|
||||
// UNRESOLVED_REFERENCE will be reported separately.
|
||||
val reference = callableReferenceAccess.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val reference = callableReferenceAccess.calleeReference.resolved ?: return
|
||||
|
||||
val source = reference.source ?: return
|
||||
if (source.kind is KtFakeSourceElementKind) return
|
||||
|
||||
+2
-4
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.ensureResolved
|
||||
@@ -107,9 +107,7 @@ object FirClassLiteralChecker : FirGetClassCallChecker() {
|
||||
|
||||
private val FirExpression.safeAsTypeParameterSymbol: FirTypeParameterSymbol?
|
||||
get() {
|
||||
return ((this as? FirQualifiedAccessExpression)
|
||||
?.calleeReference as? FirResolvedNamedReference)
|
||||
?.resolvedSymbol as? FirTypeParameterSymbol
|
||||
return (this as? FirQualifiedAccessExpression)?.calleeReference?.resolvedSymbol as? FirTypeParameterSymbol
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.isAllowedInClassLiteral(context: CheckerContext): Boolean =
|
||||
|
||||
+2
-3
@@ -16,14 +16,13 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isAbstract
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
|
||||
object FirConstructorCallChecker : FirFunctionCallChecker() {
|
||||
override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val constructorSymbol =
|
||||
(expression.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirConstructorSymbol ?: return
|
||||
val constructorSymbol = expression.calleeReference.resolvedSymbol as? FirConstructorSymbol ?: return
|
||||
val declarationClass = constructorSymbol.resolvedReturnTypeRef.coneType.toRegularClassSymbol(context.session)
|
||||
|
||||
if (declarationClass != null) {
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvable
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolved
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
import org.jetbrains.kotlin.resolve.deprecation.DeprecationInfo
|
||||
@@ -37,7 +37,7 @@ object FirDeprecationChecker : FirBasicExpressionChecker() {
|
||||
if (!allowedSourceKinds.contains(expression.source?.kind)) return
|
||||
if (expression is FirAnnotation || expression is FirDelegatedConstructorCall) return //checked by FirDeprecatedTypeChecker
|
||||
val resolvable = expression as? FirResolvable ?: return
|
||||
val reference = resolvable.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val reference = resolvable.calleeReference.resolved ?: return
|
||||
val referencedSymbol = reference.resolvedSymbol
|
||||
|
||||
reportDeprecationIfNeeded(reference.source, referencedSymbol, expression, context, reporter)
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirConstExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.arguments
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -25,7 +25,7 @@ object FirDivisionByZeroChecker : FirFunctionCallChecker() {
|
||||
val firstValue = (expression.arguments.singleOrNull() as? FirConstExpression<*>)?.value
|
||||
if (firstValue != null && (firstValue == 0L || firstValue == 0.0f || firstValue == 0.0)) {
|
||||
val callableId =
|
||||
((expression.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirNamedFunctionSymbol)?.callableId
|
||||
(expression.calleeReference.resolvedSymbol as? FirNamedFunctionSymbol)?.callableId
|
||||
if (callableId != null && callableId.packageName == defaultPackageName && callableId.callableName == defaultDivName) {
|
||||
reporter.reportOn(expression.source, FirErrors.DIVISION_BY_ZERO, context)
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,14 +14,14 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isFun
|
||||
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolved
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
|
||||
object FirFunInterfaceConstructorReferenceChecker : FirQualifiedAccessExpressionChecker() {
|
||||
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (expression !is FirCallableReferenceAccess) return
|
||||
|
||||
val reference = expression.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val reference = expression.calleeReference.resolved ?: return
|
||||
val referredSymbol = reference.resolvedSymbol
|
||||
|
||||
if (referredSymbol is FirNamedFunctionSymbol &&
|
||||
|
||||
+2
-3
@@ -11,8 +11,8 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
|
||||
@@ -22,8 +22,7 @@ object FirOptInUsageAccessChecker : FirQualifiedAccessChecker() {
|
||||
if (sourceKind is KtFakeSourceElementKind.DataClassGeneratedMembers ||
|
||||
sourceKind is KtFakeSourceElementKind.PropertyFromParameter
|
||||
) return
|
||||
val reference = expression.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val resolvedSymbol = reference.resolvedSymbol
|
||||
val resolvedSymbol = expression.calleeReference.resolvedSymbol ?: return
|
||||
val dispatchReceiverType =
|
||||
expression.dispatchReceiver.takeIf { it !is FirNoReceiverExpression }?.typeRef?.coneType?.fullyExpandedType(context.session)
|
||||
with(FirOptInUsageBaseChecker) {
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ object FirOptInUsageBaseChecker {
|
||||
?: return null
|
||||
|
||||
val levelArgument = experimental.findArgumentByName(LEVEL) as? FirQualifiedAccessExpression
|
||||
val levelName = (levelArgument?.calleeReference as? FirResolvedNamedReference)?.name?.asString()
|
||||
val levelName = levelArgument?.calleeReference?.resolved?.name?.asString()
|
||||
val level = OptInLevel.values().firstOrNull { it.name == levelName } ?: OptInLevel.DEFAULT
|
||||
val message = (experimental.findArgumentByName(MESSAGE) as? FirConstExpression<*>)?.value as? String
|
||||
return Experimentality(symbol.classId, level.severity, message)
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@ import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
|
||||
import org.jetbrains.kotlin.fir.expressions.toResolvedCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.originalForSubstitutionOverride
|
||||
import org.jetbrains.kotlin.fir.references.FirBackingFieldReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ExpressionReceiverValue
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
|
||||
@@ -100,7 +100,7 @@ object FirReassignmentAndInvisibleSetterChecker : FirVariableAssignmentChecker()
|
||||
context: CheckerContext,
|
||||
reporter: DiagnosticReporter
|
||||
) {
|
||||
val valueParameter = (expression.lValue as? FirResolvedNamedReference)?.resolvedSymbol as? FirValueParameterSymbol ?: return
|
||||
val valueParameter = expression.lValue.resolvedSymbol as? FirValueParameterSymbol ?: return
|
||||
reporter.reportOn(expression.lValue.source, FirErrors.VAL_REASSIGNMENT, valueParameter, context)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
@@ -39,7 +39,7 @@ object FirReturnSyntaxAndLabelChecker : FirReturnExpressionChecker() {
|
||||
if (label?.source?.kind !is KtRealSourceElementKind) {
|
||||
val functionCall = context.qualifiedAccessOrAnnotationCalls.asReversed().find {
|
||||
it is FirFunctionCall &&
|
||||
((it.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirNamedFunctionSymbol)?.callableId ==
|
||||
(it.calleeReference.resolvedSymbol as? FirNamedFunctionSymbol)?.callableId ==
|
||||
FirSuspendCallChecker.KOTLIN_SUSPEND_BUILT_IN_FUNCTION_CALLABLE_ID
|
||||
}
|
||||
if (functionCall is FirFunctionCall &&
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.resolved
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
@@ -39,7 +40,7 @@ object FirSuspendCallChecker : FirQualifiedAccessExpressionChecker() {
|
||||
internal val KOTLIN_SUSPEND_BUILT_IN_FUNCTION_CALLABLE_ID = CallableId(StandardClassIds.BASE_KOTLIN_PACKAGE, BUILTIN_SUSPEND_NAME)
|
||||
|
||||
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val reference = expression.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val reference = expression.calleeReference.resolved ?: return
|
||||
val symbol = reference.resolvedSymbol as? FirCallableSymbol ?: return
|
||||
if (reference.name == BUILTIN_SUSPEND_NAME ||
|
||||
symbol is FirNamedFunctionSymbol && symbol.name == BUILTIN_SUSPEND_NAME
|
||||
|
||||
+3
-4
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isEnumClass
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.ensureResolved
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirEnumEntrySymbol
|
||||
@@ -74,8 +74,7 @@ object FirUninitializedEnumChecker : FirQualifiedAccessExpressionChecker() {
|
||||
val source = expression.source ?: return
|
||||
if (source.kind is KtFakeSourceElementKind) return
|
||||
|
||||
val reference = expression.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val calleeSymbol = reference.resolvedSymbol
|
||||
val calleeSymbol = expression.calleeReference.resolvedSymbol ?: return
|
||||
val calleeContainingClassSymbol = calleeSymbol.getContainingClassSymbol(context.session) as? FirRegularClassSymbol ?: return
|
||||
// We're looking for members/entries/companion object in an enum class or members in companion object of an enum class.
|
||||
val calleeIsInsideEnum = calleeContainingClassSymbol.isEnumClass
|
||||
@@ -228,7 +227,7 @@ object FirUninitializedEnumChecker : FirQualifiedAccessExpressionChecker() {
|
||||
if (property.delegate == null || property.delegate !is FirFunctionCall) return null
|
||||
val delegateCall = property.delegate as FirFunctionCall
|
||||
val calleeSymbol =
|
||||
(delegateCall.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirNamedFunctionSymbol ?: return null
|
||||
delegateCall.calleeReference.resolvedSymbol as? FirNamedFunctionSymbol ?: return null
|
||||
if (calleeSymbol.callableId.asSingleFqName().asString() != "kotlin.lazy") return null
|
||||
val lazyCallArgument = delegateCall.argumentList.arguments.singleOrNull() as? FirLambdaArgumentExpression ?: return null
|
||||
return (lazyCallArgument.expression as? FirAnonymousFunctionExpression)?.anonymousFunction
|
||||
|
||||
+2
-3
@@ -19,8 +19,8 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
|
||||
object CanBeValChecker : AbstractFirPropertyInitializationChecker() {
|
||||
@@ -85,8 +85,7 @@ object CanBeValChecker : AbstractFirPropertyInitializationChecker() {
|
||||
override fun visitNode(node: CFGNode<*>) {}
|
||||
|
||||
override fun visitVariableAssignmentNode(node: VariableAssignmentNode) {
|
||||
val symbol = (node.fir.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirPropertySymbol
|
||||
?: return
|
||||
val symbol = node.fir.calleeReference.resolvedSymbol as? FirPropertySymbol ?: return
|
||||
if (symbol !in localProperties) return
|
||||
unprocessedProperties.remove(symbol)
|
||||
|
||||
|
||||
+6
-7
@@ -25,8 +25,9 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
|
||||
import org.jetbrains.kotlin.fir.resolved
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.types.isFunctionalType
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.ensureResolved
|
||||
@@ -52,7 +53,7 @@ object UnusedChecker : FirControlFlowChecker() {
|
||||
override fun visitNode(node: CFGNode<*>) {}
|
||||
|
||||
override fun visitVariableAssignmentNode(node: VariableAssignmentNode) {
|
||||
val variableSymbol = (node.fir.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol ?: return
|
||||
val variableSymbol = node.fir.calleeReference.resolvedSymbol ?: return
|
||||
val dataPerNode = data[node] ?: return
|
||||
for (dataPerLabel in dataPerNode.values) {
|
||||
val data = dataPerLabel[variableSymbol] ?: continue
|
||||
@@ -217,8 +218,7 @@ object UnusedChecker : FirControlFlowChecker() {
|
||||
data: Collection<Pair<EdgeLabel, PathAwareVariableStatusInfo>>
|
||||
): PathAwareVariableStatusInfo {
|
||||
val dataForNode = visitNode(node, data)
|
||||
val reference = node.fir.lValue as? FirResolvedNamedReference ?: return dataForNode
|
||||
val symbol = reference.resolvedSymbol as? FirPropertySymbol ?: return dataForNode
|
||||
val symbol = node.fir.lValue.resolvedSymbol as? FirPropertySymbol ?: return dataForNode
|
||||
return update(dataForNode, symbol) update@{ prev ->
|
||||
val toPut = when {
|
||||
symbol !in localProperties -> {
|
||||
@@ -267,8 +267,7 @@ object UnusedChecker : FirControlFlowChecker() {
|
||||
vararg qualifiedAccesses: FirQualifiedAccess,
|
||||
): PathAwareVariableStatusInfo {
|
||||
fun retrieveSymbol(qualifiedAccess: FirQualifiedAccess): FirPropertySymbol? {
|
||||
val reference = qualifiedAccess.calleeReference as? FirResolvedNamedReference ?: return null
|
||||
val symbol = reference.resolvedSymbol as? FirPropertySymbol ?: return null
|
||||
val symbol = qualifiedAccess.calleeReference.resolvedSymbol as? FirPropertySymbol ?: return null
|
||||
return if (symbol !in localProperties) null else symbol
|
||||
}
|
||||
|
||||
@@ -285,7 +284,7 @@ object UnusedChecker : FirControlFlowChecker() {
|
||||
data: Collection<Pair<EdgeLabel, PathAwareVariableStatusInfo>>
|
||||
): PathAwareVariableStatusInfo {
|
||||
val dataForNode = visitNode(node, data)
|
||||
val reference = node.fir.calleeReference as? FirResolvedNamedReference ?: return dataForNode
|
||||
val reference = node.fir.calleeReference.resolved ?: return dataForNode
|
||||
val functionSymbol = reference.resolvedSymbol as? FirFunctionSymbol<*> ?: return dataForNode
|
||||
val symbol = if (functionSymbol.callableId.callableName.identifier == "invoke") {
|
||||
localProperties.find { it.name == reference.name && it.resolvedReturnTypeRef.coneType.isFunctionalType(session) }
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeNullability
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
@@ -33,7 +33,7 @@ object UselessCallOnNotNullChecker : FirQualifiedAccessExpressionChecker() {
|
||||
}
|
||||
|
||||
private fun FirQualifiedAccessExpression.getCallableId() =
|
||||
((calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirNamedFunctionSymbol)?.callableId
|
||||
(calleeReference.resolvedSymbol as? FirNamedFunctionSymbol)?.callableId
|
||||
|
||||
private fun FirExpression.getPackage() =
|
||||
typeRef.coneType.classId?.packageFqName.toString()
|
||||
|
||||
+1
-3
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass
|
||||
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyConstructor
|
||||
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyProperty
|
||||
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazySimpleFunction
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.isLocalClassOrAnonymousObject
|
||||
import org.jetbrains.kotlin.fir.types.isSuspendFunctionType
|
||||
import org.jetbrains.kotlin.fir.resolve.isKFunctionInvoke
|
||||
@@ -797,8 +796,7 @@ class Fir2IrDeclarationStorage(
|
||||
val origin = property.computeIrOrigin(predefinedOrigin)
|
||||
classifierStorage.preCacheTypeParameters(property)
|
||||
if (property.delegate != null) {
|
||||
val delegateReference = (property.delegate as? FirQualifiedAccess)?.calleeReference as? FirResolvedNamedReference
|
||||
(delegateReference?.resolvedSymbol?.fir as? FirTypeParameterRefsOwner)?.let {
|
||||
((property.delegate as? FirQualifiedAccess)?.calleeReference?.resolvedSymbol?.fir as? FirTypeParameterRefsOwner)?.let {
|
||||
classifierStorage.preCacheTypeParameters(it)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -11,8 +11,8 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirStubStatement
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
|
||||
@@ -292,9 +292,7 @@ class Fir2IrImplicitCastInserter(
|
||||
originalTypeRef: FirTypeRef,
|
||||
calleeReference: FirReference,
|
||||
): IrExpression {
|
||||
val referencedDeclaration =
|
||||
((calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirCallableSymbol<*>)?.unwrapCallRepresentative()
|
||||
?.fir
|
||||
val referencedDeclaration = (calleeReference.resolvedSymbol as? FirCallableSymbol<*>)?.unwrapCallRepresentative()?.fir
|
||||
|
||||
val dispatchReceiverType =
|
||||
referencedDeclaration?.dispatchReceiverType as? ConeClassLikeType
|
||||
|
||||
@@ -275,7 +275,7 @@ class Fir2IrVisitor(
|
||||
}
|
||||
val initializer = variable.initializer
|
||||
val isNextVariable = initializer is FirFunctionCall &&
|
||||
initializer.resolvedNamedFunctionSymbol()?.callableId?.isIteratorNext() == true &&
|
||||
(initializer.calleeReference.resolvedSymbol as? FirNamedFunctionSymbol)?.callableId?.isIteratorNext() == true &&
|
||||
variable.source.psi?.parent is KtForExpression
|
||||
val irVariable = declarationStorage.createIrVariable(
|
||||
variable, conversionScope.parentFromStack(),
|
||||
@@ -395,11 +395,6 @@ class Fir2IrVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirFunctionCall.resolvedNamedFunctionSymbol(): FirNamedFunctionSymbol? {
|
||||
val calleeReference = (calleeReference as? FirResolvedNamedReference) ?: return null
|
||||
return calleeReference.resolvedSymbol as? FirNamedFunctionSymbol
|
||||
}
|
||||
|
||||
override fun visitAnnotation(annotation: FirAnnotation, data: Any?): IrElement {
|
||||
return callGenerator.convertToIrConstructorCall(annotation)
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@ import org.jetbrains.kotlin.fir.extensions.declarationGenerators
|
||||
import org.jetbrains.kotlin.fir.extensions.extensionService
|
||||
import org.jetbrains.kotlin.fir.extensions.generatedMembers
|
||||
import org.jetbrains.kotlin.fir.extensions.generatedNestedClassifiers
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
@@ -294,7 +294,7 @@ internal class ClassMemberGenerator(
|
||||
|
||||
internal fun FirDelegatedConstructorCall.toIrDelegatingConstructorCall(): IrExpression {
|
||||
val constructedIrType = constructedTypeRef.toIrType()
|
||||
val referencedSymbol = (this.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirConstructorSymbol
|
||||
val referencedSymbol = calleeReference.resolvedSymbol as? FirConstructorSymbol
|
||||
?: return convertWithOffsets { startOffset, endOffset ->
|
||||
IrErrorCallExpressionImpl(
|
||||
startOffset, endOffset, constructedIrType, "Cannot find delegated constructor call"
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
@@ -38,7 +39,7 @@ private fun FirAnnotation.toAnnotationClass(session: FirSession): FirRegularClas
|
||||
private val FirExpression.callableNameOfMetaAnnotationArgument: Name?
|
||||
get() =
|
||||
(this as? FirQualifiedAccessExpression)?.let {
|
||||
val callableSymbol = (it.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirCallableSymbol<*>
|
||||
val callableSymbol = it.calleeReference.resolvedSymbol as? FirCallableSymbol<*>
|
||||
callableSymbol?.callableId?.callableName
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.contracts.buildContractFir
|
||||
@@ -1054,11 +1053,11 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
val owner: FirContractDescriptionOwner? = when (qualifiedAccess) {
|
||||
is FirFunctionCall -> qualifiedAccess.toResolvedCallableSymbol()?.fir as? FirSimpleFunction
|
||||
is FirQualifiedAccessExpression -> {
|
||||
val property = (qualifiedAccess.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol?.fir as? FirProperty
|
||||
val property = qualifiedAccess.calleeReference.resolvedSymbol?.fir as? FirProperty
|
||||
property?.getter
|
||||
}
|
||||
is FirVariableAssignment -> {
|
||||
val property = (qualifiedAccess.lValue as? FirResolvedNamedReference)?.resolvedSymbol?.fir as? FirProperty
|
||||
val property = qualifiedAccess.lValue.resolvedSymbol?.fir as? FirProperty
|
||||
property?.setter
|
||||
}
|
||||
else -> null
|
||||
@@ -1146,7 +1145,7 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
|
||||
fun exitVariableAssignment(assignment: FirVariableAssignment) {
|
||||
val node = graphBuilder.exitVariableAssignment(assignment).mergeIncomingFlow()
|
||||
val property = (assignment.lValue as? FirResolvedNamedReference)?.resolvedSymbol?.fir as? FirProperty ?: return
|
||||
val property = assignment.lValue.resolvedSymbol?.fir as? FirProperty ?: return
|
||||
// TODO: add unstable smartcast
|
||||
if (property.isLocal || !property.isVar) {
|
||||
exitVariableInitialization(node, assignment.rValue, property, assignment, hasExplicitType = false)
|
||||
|
||||
+1
-1
@@ -492,7 +492,7 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
val operatorReturnTypeMatches = operatorIsSuccessful && operatorReturnTypeMatches(operatorCallReference!!.candidate)
|
||||
|
||||
val lhsReference = leftArgument.toReference()
|
||||
val lhsSymbol = (lhsReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirVariableSymbol<*>
|
||||
val lhsSymbol = lhsReference?.resolvedSymbol as? FirVariableSymbol<*>
|
||||
val lhsVariable = lhsSymbol?.fir
|
||||
val lhsIsVar = lhsVariable?.isVar == true
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ import org.jetbrains.kotlin.fakeElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||
@@ -69,3 +72,6 @@ val FirFile.packageFqName: FqName
|
||||
val FirElement.psi: PsiElement? get() = (source as? KtPsiSourceElement)?.psi
|
||||
val FirElement.realPsi: PsiElement? get() = (source as? KtRealPsiSourceElement)?.psi
|
||||
|
||||
val FirReference.resolved: FirResolvedNamedReference? get() = this as? FirResolvedNamedReference
|
||||
val FirReference.resolvedSymbol: FirBasedSymbol<*>? get() = resolved?.resolvedSymbol
|
||||
|
||||
|
||||
+2
-3
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.declarations.utils
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||
@@ -39,8 +39,7 @@ val FirClass.delegateFields: List<FirField>
|
||||
|
||||
val FirQualifiedAccess.referredPropertySymbol: FirPropertySymbol?
|
||||
get() {
|
||||
val reference = calleeReference as? FirResolvedNamedReference ?: return null
|
||||
return reference.resolvedSymbol as? FirPropertySymbol
|
||||
return calleeReference.resolvedSymbol as? FirPropertySymbol
|
||||
}
|
||||
|
||||
inline val FirDeclaration.isJava: Boolean
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolved
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
@@ -56,7 +58,7 @@ inline val FirCall.argumentMapping: LinkedHashMap<FirExpression, FirValueParamet
|
||||
}
|
||||
|
||||
fun FirExpression.toResolvedCallableReference(): FirResolvedNamedReference? {
|
||||
return toReference() as? FirResolvedNamedReference
|
||||
return toReference()?.resolved
|
||||
}
|
||||
|
||||
fun FirExpression.toReference(): FirReference? {
|
||||
@@ -69,7 +71,7 @@ fun FirExpression.toResolvedCallableSymbol(): FirCallableSymbol<*>? {
|
||||
}
|
||||
|
||||
fun FirReference.toResolvedCallableSymbol(): FirCallableSymbol<*>? {
|
||||
return (this as? FirResolvedNamedReference)?.resolvedSymbol as? FirCallableSymbol<*>
|
||||
return this.resolvedSymbol as? FirCallableSymbol<*>
|
||||
}
|
||||
|
||||
fun buildErrorLoop(source: KtSourceElement?, diagnostic: ConeDiagnostic): FirErrorLoop {
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolvedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ensureResolved
|
||||
import org.jetbrains.kotlin.name.*
|
||||
|
||||
@@ -63,7 +64,7 @@ class FirConstructorSymbol(
|
||||
val resolvedDelegatedConstructor: FirConstructorSymbol?
|
||||
get() {
|
||||
val delegatedConstructorCall = resolvedDelegatedConstructorCall ?: return null
|
||||
return (delegatedConstructorCall.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirConstructorSymbol
|
||||
return delegatedConstructorCall.calleeReference.resolvedSymbol as? FirConstructorSymbol
|
||||
}
|
||||
|
||||
val resolvedDelegatedConstructorCall: FirDelegatedConstructorCall?
|
||||
|
||||
Reference in New Issue
Block a user