K2: Remove unreachable branch in when at SubstitutionOverrideCache
- It happens because FirSyntheticPropertySymbol <: FirPropertySymbol - Also remove functions became unused ^KT-54345 Related
This commit is contained in:
committed by
Space Team
parent
11e4cb12b7
commit
ca5789cec0
-45
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSessionComponent
|
||||
import org.jetbrains.kotlin.fir.caches.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||
import org.jetbrains.kotlin.fir.dispatchReceiverClassLookupTagOrNull
|
||||
import org.jetbrains.kotlin.fir.originalForSubstitutionOverride
|
||||
@@ -321,49 +320,6 @@ class FirClassSubstitutionScope(
|
||||
return FirFakeOverrideGenerator.createSubstitutionOverrideField(session, member, derivedClassLookupTag, newReturnType)
|
||||
}
|
||||
|
||||
fun createSubstitutionOverrideSyntheticProperty(original: FirSyntheticPropertySymbol): FirSyntheticPropertySymbol {
|
||||
if (substitutor == ConeSubstitutor.Empty) return original
|
||||
original.lazyResolveToPhase(FirResolvePhase.TYPES)
|
||||
val member = original.fir as FirSyntheticProperty
|
||||
if (skipPrivateMembers && member.visibility == Visibilities.Private) return original
|
||||
|
||||
val returnType = member.returnTypeRef.coneTypeSafe<ConeKotlinType>()
|
||||
val fakeOverrideSubstitution = runIf(returnType == null) { FakeOverrideSubstitution(substitutor, original) }
|
||||
val newReturnType = returnType?.substitute()
|
||||
|
||||
val newGetterParameterTypes = member.getter.valueParameters.map {
|
||||
it.returnTypeRef.coneType.substitute()
|
||||
}
|
||||
val newSetterParameterTypes = member.setter?.valueParameters?.map {
|
||||
it.returnTypeRef.coneType.substitute()
|
||||
}.orEmpty()
|
||||
|
||||
val newContextReceiverTypes = member.contextReceivers.map {
|
||||
it.typeRef.coneType.substitute()
|
||||
}
|
||||
|
||||
if (original.dispatchReceiverType?.substitute(substitutor) == null &&
|
||||
newReturnType == null &&
|
||||
newGetterParameterTypes.all { it == null } &&
|
||||
newSetterParameterTypes.all { it == null }
|
||||
) {
|
||||
return original
|
||||
}
|
||||
|
||||
return FirFakeOverrideGenerator.createSubstitutionOverrideSyntheticProperty(
|
||||
session,
|
||||
member,
|
||||
derivedClassLookupTag,
|
||||
original,
|
||||
substitutor.substituteOrSelf(dispatchReceiverTypeForSubstitutedMembers) as ConeSimpleKotlinType?,
|
||||
newContextReceiverTypes,
|
||||
newReturnType,
|
||||
newGetterParameterTypes,
|
||||
newSetterParameterTypes,
|
||||
fakeOverrideSubstitution
|
||||
)
|
||||
}
|
||||
|
||||
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
||||
useSiteMemberScope.processDeclaredConstructors process@{ original ->
|
||||
val constructor = substitutionOverrideCache.overridesForConstructors.getValue(original, this)
|
||||
@@ -400,7 +356,6 @@ class FirSubstitutionOverrideStorage(val session: FirSession) : FirSessionCompon
|
||||
when (original) {
|
||||
is FirPropertySymbol -> scope.createSubstitutionOverrideProperty(original)
|
||||
is FirFieldSymbol -> scope.createSubstitutionOverrideField(original)
|
||||
is FirSyntheticPropertySymbol -> scope.createSubstitutionOverrideSyntheticProperty(original)
|
||||
else -> error("symbol $original is not overridable")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-58
@@ -13,8 +13,6 @@ import org.jetbrains.kotlin.fir.declarations.builder.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
|
||||
import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.synthetic.buildSyntheticProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ChainedSubstitutor
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
@@ -26,11 +24,10 @@ import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImplWithoutSource
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImplWithoutSource
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
|
||||
object FirFakeOverrideGenerator {
|
||||
@@ -662,60 +659,6 @@ object FirFakeOverrideGenerator {
|
||||
return symbol
|
||||
}
|
||||
|
||||
fun createSubstitutionOverrideSyntheticProperty(
|
||||
session: FirSession,
|
||||
baseProperty: FirSyntheticProperty,
|
||||
derivedClassLookupTag: ConeClassLikeLookupTag,
|
||||
baseSymbol: FirSyntheticPropertySymbol,
|
||||
newDispatchReceiverType: ConeSimpleKotlinType?,
|
||||
newContextReceiverTypes: List<ConeKotlinType?>?,
|
||||
newReturnType: ConeKotlinType?,
|
||||
newGetterParameterTypes: List<ConeKotlinType?>?,
|
||||
newSetterParameterTypes: List<ConeKotlinType?>?,
|
||||
fakeOverrideSubstitution: FakeOverrideSubstitution?
|
||||
): FirSyntheticPropertySymbol {
|
||||
val getterSymbol = FirNamedFunctionSymbol(baseSymbol.getterId)
|
||||
val getter = createSubstitutionOverrideFunction(
|
||||
getterSymbol,
|
||||
session,
|
||||
baseProperty.getter.delegate,
|
||||
derivedClassLookupTag,
|
||||
newDispatchReceiverType,
|
||||
newReceiverType = null,
|
||||
newContextReceiverTypes,
|
||||
newReturnType,
|
||||
newGetterParameterTypes,
|
||||
newTypeParameters = null,
|
||||
fakeOverrideSubstitution = fakeOverrideSubstitution
|
||||
)
|
||||
val setterSymbol = FirNamedFunctionSymbol(baseSymbol.getterId)
|
||||
val baseSetter = baseProperty.setter
|
||||
val setter = if (baseSetter == null) null else createSubstitutionOverrideFunction(
|
||||
setterSymbol,
|
||||
session,
|
||||
baseSetter.delegate,
|
||||
derivedClassLookupTag,
|
||||
newDispatchReceiverType,
|
||||
newReceiverType = null,
|
||||
newContextReceiverTypes,
|
||||
StandardClassIds.Unit.constructClassLikeType(emptyArray(), isNullable = false),
|
||||
newSetterParameterTypes,
|
||||
newTypeParameters = null,
|
||||
fakeOverrideSubstitution = fakeOverrideSubstitution
|
||||
)
|
||||
return buildSyntheticProperty {
|
||||
moduleData = session.moduleData
|
||||
name = baseProperty.name
|
||||
symbol = baseSymbol.copy()
|
||||
delegateGetter = getter
|
||||
delegateSetter = setter
|
||||
status = baseProperty.status
|
||||
deprecationsProvider = getDeprecationsProviderFromAccessors(session, getter, setter)
|
||||
}.apply {
|
||||
containingClassForStaticMemberAttr = derivedClassLookupTag.takeIf { shouldOverrideSetContainingClass(baseProperty) }
|
||||
}.symbol
|
||||
}
|
||||
|
||||
// Returns a list of type parameters, and a substitutor that should be used for all other types
|
||||
fun createNewTypeParametersAndSubstitutor(
|
||||
useSiteSession: FirSession,
|
||||
|
||||
Reference in New Issue
Block a user