K2: expand type before isSomeType checks properly

Related to KT-60229
This commit is contained in:
Mikhail Glukhikh
2023-07-13 14:27:48 +02:00
committed by Space Team
parent 51e8a72f47
commit 00b4ae6ae9
30 changed files with 140 additions and 73 deletions
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.fir.psi
import org.jetbrains.kotlin.fir.references.*
import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnmatchedTypeArgumentsError
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.resolve.providers.toSymbol
import org.jetbrains.kotlin.fir.resolve.scope
import org.jetbrains.kotlin.fir.resolve.toSymbol
@@ -261,7 +262,7 @@ internal object FirReferenceResolveHelper {
return buildList {
scope.processFunctionsByName(OperatorNameConventions.EQUALS) { functionSymbol ->
val parameterSymbol = functionSymbol.valueParameterSymbols.singleOrNull()
if (parameterSymbol != null && parameterSymbol.fir.returnTypeRef.isNullableAny) {
if (parameterSymbol != null && parameterSymbol.fir.returnTypeRef.coneType.fullyExpandedType(session).isNullableAny) {
add(functionSymbol.buildSymbol(symbolBuilder))
}
}
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.fir.types.isNullableAny
import org.jetbrains.kotlin.fir.analysis.checkers.typeParameterSymbols
import org.jetbrains.kotlin.fir.types.UnexpandedTypeCheck
/**
* [KtFirTypeParameterSymbolBase] provides shared implementations for [KtFirTypeParameterSymbol] and [KtFirPsiJavaTypeParameterSymbol].
@@ -29,6 +30,7 @@ internal sealed class KtFirTypeParameterSymbolBase : KtTypeParameterSymbol(), Kt
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
}
@OptIn(UnexpandedTypeCheck::class)
override val upperBounds: List<KtType> by cached {
firSymbol.resolvedBounds.mapNotNull { type ->
if (type.isNullableAny) return@mapNotNull null