[FIR] Introduce ownTypeParameterSymbols
This commit is contained in:
committed by
Space Team
parent
3afed72027
commit
c7d535ff46
+1
-6
@@ -15,13 +15,10 @@ import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.getChild
|
||||
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.toResolvedTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
@@ -81,10 +78,8 @@ object FirClassLiteralChecker : FirGetClassCallChecker() {
|
||||
if (argument.typeArguments.isNotEmpty() && !resolvedFullyExpandedType.isAllowedInClassLiteral(context)) {
|
||||
val symbol = argument.symbol
|
||||
symbol?.lazyResolveToPhase(FirResolvePhase.TYPES)
|
||||
@OptIn(SymbolInternals::class)
|
||||
val typeParameters = (symbol?.fir as? FirTypeParameterRefsOwner)?.typeParameters
|
||||
// Among type parameter references, only count actual type parameter while discarding [FirOuterClassTypeParameterRef]
|
||||
val expectedTypeArgumentSize = typeParameters?.count { it is FirTypeParameter } ?: 0
|
||||
val expectedTypeArgumentSize = symbol?.ownTypeParameterSymbols?.size ?: 0
|
||||
if (expectedTypeArgumentSize != argument.typeArguments.size) {
|
||||
if (symbol != null) {
|
||||
reporter.reportOn(argument.source, FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS, expectedTypeArgumentSize, symbol, context)
|
||||
|
||||
@@ -44,6 +44,9 @@ sealed class FirClassLikeSymbol<D : FirClassLikeDeclaration>(
|
||||
val typeParameterSymbols: List<FirTypeParameterSymbol>
|
||||
get() = fir.typeParameters.map { it.symbol }
|
||||
|
||||
val ownTypeParameterSymbols: List<FirTypeParameterSymbol>
|
||||
get() = fir.typeParameters.mapNotNull { (it as? FirTypeParameter)?.symbol }
|
||||
|
||||
override fun toString(): String = "${this::class.simpleName} ${classId.asString()}"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user