[FIR] Fix implementation of primaryConstructorSymbol utility
Originally it used list of declarations, which is incorrect, because some constructors may be contributed by compiler plugin. And those constructors will be contained only in scope
This commit is contained in:
committed by
Space Team
parent
93b0a90172
commit
efb96e31fb
@@ -704,7 +704,7 @@ private fun findDefaultValue(source: KtLightSourceElement): KtLightSourceElement
|
||||
|
||||
fun ConeKotlinType.getInlineClassUnderlyingType(session: FirSession): ConeKotlinType {
|
||||
require(this.isSingleFieldValueClass(session))
|
||||
return toRegularClassSymbol(session)!!.primaryConstructorSymbol()!!.valueParameterSymbols[0].resolvedReturnTypeRef.coneType
|
||||
return toRegularClassSymbol(session)!!.primaryConstructorSymbol(session)!!.valueParameterSymbols[0].resolvedReturnTypeRef.coneType
|
||||
}
|
||||
|
||||
fun FirNamedFunctionSymbol.directOverriddenFunctions(session: FirSession, scopeSession: ScopeSession): List<FirNamedFunctionSymbol> {
|
||||
|
||||
+2
-2
@@ -168,7 +168,7 @@ object FirAnnotationClassDeclarationChecker : FirRegularClassChecker() {
|
||||
}
|
||||
|
||||
private fun checkCyclesInParameters(annotation: FirRegularClassSymbol, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val primaryConstructor = annotation.primaryConstructorSymbol() ?: return
|
||||
val primaryConstructor = annotation.primaryConstructorSymbol(context.session) ?: return
|
||||
val checker = CycleChecker(annotation, context.session)
|
||||
for (valueParameter in primaryConstructor.valueParameterSymbols) {
|
||||
if (checker.parameterHasCycle(annotation, valueParameter)) {
|
||||
@@ -182,7 +182,7 @@ object FirAnnotationClassDeclarationChecker : FirRegularClassChecker() {
|
||||
private val annotationsWithCycle = mutableSetOf(targetAnnotation)
|
||||
|
||||
fun annotationHasCycle(annotation: FirRegularClassSymbol): Boolean {
|
||||
val primaryConstructor = annotation.primaryConstructorSymbol() ?: return false
|
||||
val primaryConstructor = annotation.primaryConstructorSymbol(session) ?: return false
|
||||
for (valueParameter in primaryConstructor.valueParameterSymbols) {
|
||||
if (parameterHasCycle(annotation, valueParameter)) return true
|
||||
}
|
||||
|
||||
+4
-7
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.analysis.checkers.modality
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
@@ -96,13 +97,9 @@ internal val FirBasedSymbol<*>.isLocalMember: Boolean
|
||||
internal val FirCallableSymbol<*>.isExtensionMember: Boolean
|
||||
get() = resolvedReceiverTypeRef != null && dispatchReceiverType != null
|
||||
|
||||
fun FirClassSymbol<*>.primaryConstructorSymbol(): FirConstructorSymbol? {
|
||||
for (declarationSymbol in this.declarationSymbols) {
|
||||
if (declarationSymbol is FirConstructorSymbol && declarationSymbol.isPrimary) {
|
||||
return declarationSymbol
|
||||
}
|
||||
}
|
||||
return null
|
||||
@OptIn(SymbolInternals::class)
|
||||
fun FirClassSymbol<*>.primaryConstructorSymbol(session: FirSession): FirConstructorSymbol? {
|
||||
return fir.primaryConstructorIfAny(session)
|
||||
}
|
||||
|
||||
fun FirTypeRef.needsMultiFieldValueClassFlattening(session: FirSession) = with(session.typeContext) {
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ class FirSerializablePropertiesProvider(session: FirSession) : FirExtensionSessi
|
||||
.let { restoreCorrectOrderFromClassProtoExtension(classSymbol, it) }
|
||||
|
||||
val isExternallySerializable = classSymbol.isEnumClass ||
|
||||
primaryConstructorProperties.size == (classSymbol.primaryConstructorSymbol()?.valueParameterSymbols?.size ?: 0)
|
||||
primaryConstructorProperties.size == (classSymbol.primaryConstructorSymbol(session)?.valueParameterSymbols?.size ?: 0)
|
||||
|
||||
val (serializableConstructorProperties, serializableStandaloneProperties) = serializableProperties.partition { it.propertySymbol in primaryConstructorProperties }
|
||||
return FirSerializableProperties(
|
||||
|
||||
Reference in New Issue
Block a user