[FIR] Remove redundant default values for functions in FirClassSubstitutionScope
This commit is contained in:
+30
-26
@@ -19,8 +19,6 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ChainedSubstitutor
|
|||||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.chain
|
import org.jetbrains.kotlin.fir.resolve.substitution.chain
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
||||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||||
@@ -285,10 +283,10 @@ class FirClassSubstitutionScope(
|
|||||||
fakeOverrideSymbol: FirFunctionSymbol<FirSimpleFunction>,
|
fakeOverrideSymbol: FirFunctionSymbol<FirSimpleFunction>,
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
baseFunction: FirSimpleFunction,
|
baseFunction: FirSimpleFunction,
|
||||||
newReceiverType: ConeKotlinType? = null,
|
newReceiverType: ConeKotlinType?,
|
||||||
newReturnType: ConeKotlinType? = null,
|
newReturnType: ConeKotlinType?,
|
||||||
newParameterTypes: List<ConeKotlinType?>? = null,
|
newParameterTypes: List<ConeKotlinType?>?,
|
||||||
newTypeParameters: List<FirTypeParameter>? = null,
|
newTypeParameters: List<FirTypeParameter>?,
|
||||||
isExpect: Boolean = baseFunction.isExpect,
|
isExpect: Boolean = baseFunction.isExpect,
|
||||||
): FirSimpleFunction {
|
): FirSimpleFunction {
|
||||||
// TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl
|
// TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl
|
||||||
@@ -338,10 +336,10 @@ class FirClassSubstitutionScope(
|
|||||||
fakeOverrideSymbol: FirConstructorSymbol,
|
fakeOverrideSymbol: FirConstructorSymbol,
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
baseConstructor: FirConstructor,
|
baseConstructor: FirConstructor,
|
||||||
newReturnType: ConeKotlinType? = null,
|
newReturnType: ConeKotlinType?,
|
||||||
newParameterTypes: List<ConeKotlinType?>? = null,
|
newParameterTypes: List<ConeKotlinType?>?,
|
||||||
newTypeParameters: List<FirTypeParameterRef>? = null,
|
newTypeParameters: List<FirTypeParameterRef>?,
|
||||||
isExpect: Boolean = baseConstructor.isExpect
|
isExpect: Boolean
|
||||||
): FirConstructor {
|
): FirConstructor {
|
||||||
// TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl
|
// TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl
|
||||||
// As second alternative, we can invent some light-weight kind of FirRegularClass
|
// As second alternative, we can invent some light-weight kind of FirRegularClass
|
||||||
@@ -355,7 +353,7 @@ class FirClassSubstitutionScope(
|
|||||||
resolvePhase = baseConstructor.resolvePhase
|
resolvePhase = baseConstructor.resolvePhase
|
||||||
|
|
||||||
typeParameters += configureAnnotationsTypeParametersAndSignature(
|
typeParameters += configureAnnotationsTypeParametersAndSignature(
|
||||||
session, baseConstructor, newParameterTypes, newTypeParameters, null, newReturnType
|
session, baseConstructor, newParameterTypes, newTypeParameters, newReceiverType = null, newReturnType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,8 +363,8 @@ class FirClassSubstitutionScope(
|
|||||||
baseFunction: FirFunction<*>,
|
baseFunction: FirFunction<*>,
|
||||||
newParameterTypes: List<ConeKotlinType?>?,
|
newParameterTypes: List<ConeKotlinType?>?,
|
||||||
newTypeParameters: List<FirTypeParameterRef>?,
|
newTypeParameters: List<FirTypeParameterRef>?,
|
||||||
newReceiverType: ConeKotlinType? = null,
|
newReceiverType: ConeKotlinType?,
|
||||||
newReturnType: ConeKotlinType? = null
|
newReturnType: ConeKotlinType?
|
||||||
): List<FirTypeParameterRef> {
|
): List<FirTypeParameterRef> {
|
||||||
return when {
|
return when {
|
||||||
baseFunction.typeParameters.isEmpty() -> {
|
baseFunction.typeParameters.isEmpty() -> {
|
||||||
@@ -397,8 +395,8 @@ class FirClassSubstitutionScope(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
baseFunction: FirFunction<*>,
|
baseFunction: FirFunction<*>,
|
||||||
newParameterTypes: List<ConeKotlinType?>?,
|
newParameterTypes: List<ConeKotlinType?>?,
|
||||||
newReceiverType: ConeKotlinType? = null,
|
newReceiverType: ConeKotlinType?,
|
||||||
newReturnType: ConeKotlinType? = null
|
newReturnType: ConeKotlinType?
|
||||||
) {
|
) {
|
||||||
annotations += baseFunction.annotations
|
annotations += baseFunction.annotations
|
||||||
returnTypeRef = replaceReturnTypeIfResolved(baseFunction, newReturnType)
|
returnTypeRef = replaceReturnTypeIfResolved(baseFunction, newReturnType)
|
||||||
@@ -420,7 +418,7 @@ class FirClassSubstitutionScope(
|
|||||||
private fun replaceReturnTypeIfResolved(
|
private fun replaceReturnTypeIfResolved(
|
||||||
base: FirCallableDeclaration<*>,
|
base: FirCallableDeclaration<*>,
|
||||||
newReturnType: ConeKotlinType?
|
newReturnType: ConeKotlinType?
|
||||||
) = if (base.returnTypeRef is FirResolvedTypeRef)
|
): FirTypeRef = if (base.returnTypeRef is FirResolvedTypeRef)
|
||||||
base.returnTypeRef.withReplacedConeType(newReturnType)
|
base.returnTypeRef.withReplacedConeType(newReturnType)
|
||||||
else
|
else
|
||||||
base.returnTypeRef
|
base.returnTypeRef
|
||||||
@@ -480,8 +478,8 @@ class FirClassSubstitutionScope(
|
|||||||
private fun FirPropertyBuilder.configureAnnotationsTypeParametersAndSignature(
|
private fun FirPropertyBuilder.configureAnnotationsTypeParametersAndSignature(
|
||||||
baseProperty: FirProperty,
|
baseProperty: FirProperty,
|
||||||
newTypeParameters: List<FirTypeParameter>?,
|
newTypeParameters: List<FirTypeParameter>?,
|
||||||
newReceiverType: ConeKotlinType? = null,
|
newReceiverType: ConeKotlinType?,
|
||||||
newReturnType: ConeKotlinType? = null
|
newReturnType: ConeKotlinType?
|
||||||
): List<FirTypeParameter> {
|
): List<FirTypeParameter> {
|
||||||
return when {
|
return when {
|
||||||
baseProperty.typeParameters.isEmpty() -> {
|
baseProperty.typeParameters.isEmpty() -> {
|
||||||
@@ -526,20 +524,20 @@ class FirClassSubstitutionScope(
|
|||||||
|
|
||||||
private fun FirPropertyBuilder.configureAnnotationsAndSignature(
|
private fun FirPropertyBuilder.configureAnnotationsAndSignature(
|
||||||
baseProperty: FirProperty,
|
baseProperty: FirProperty,
|
||||||
newReceiverType: ConeKotlinType? = null,
|
newReceiverType: ConeKotlinType?,
|
||||||
newReturnType: ConeKotlinType? = null
|
newReturnType: ConeKotlinType?
|
||||||
) {
|
) {
|
||||||
annotations += baseProperty.annotations
|
annotations += baseProperty.annotations
|
||||||
returnTypeRef = replaceReturnTypeIfResolved(baseProperty, newReturnType)
|
returnTypeRef = replaceReturnTypeIfResolved(baseProperty, newReturnType)
|
||||||
receiverTypeRef = baseProperty.receiverTypeRef?.withReplacedConeType(newReceiverType)
|
receiverTypeRef = baseProperty.receiverTypeRef?.withReplacedConeType(newReceiverType)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createFakeOverrideField(
|
private fun createFakeOverrideField(
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
baseField: FirField,
|
baseField: FirField,
|
||||||
baseSymbol: FirFieldSymbol,
|
baseSymbol: FirFieldSymbol,
|
||||||
newReturnType: ConeKotlinType? = null,
|
newReturnType: ConeKotlinType?,
|
||||||
derivedClassId: ClassId? = null
|
derivedClassId: ClassId?
|
||||||
): FirFieldSymbol {
|
): FirFieldSymbol {
|
||||||
val symbol = FirFieldSymbol(
|
val symbol = FirFieldSymbol(
|
||||||
CallableId(derivedClassId ?: baseSymbol.callableId.classId!!, baseField.name)
|
CallableId(derivedClassId ?: baseSymbol.callableId.classId!!, baseField.name)
|
||||||
@@ -564,12 +562,18 @@ class FirClassSubstitutionScope(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
baseProperty: FirSyntheticProperty,
|
baseProperty: FirSyntheticProperty,
|
||||||
baseSymbol: FirAccessorSymbol,
|
baseSymbol: FirAccessorSymbol,
|
||||||
newReturnType: ConeKotlinType? = null,
|
newReturnType: ConeKotlinType?,
|
||||||
newParameterTypes: List<ConeKotlinType?>? = null
|
newParameterTypes: List<ConeKotlinType?>?
|
||||||
): FirAccessorSymbol {
|
): FirAccessorSymbol {
|
||||||
val functionSymbol = FirNamedFunctionSymbol(baseSymbol.accessorId)
|
val functionSymbol = FirNamedFunctionSymbol(baseSymbol.accessorId)
|
||||||
val function = createFakeOverrideFunction(
|
val function = createFakeOverrideFunction(
|
||||||
functionSymbol, session, baseProperty.getter.delegate, null, newReturnType, newParameterTypes
|
functionSymbol,
|
||||||
|
session,
|
||||||
|
baseProperty.getter.delegate,
|
||||||
|
newReceiverType = null,
|
||||||
|
newReturnType,
|
||||||
|
newParameterTypes,
|
||||||
|
newTypeParameters = null
|
||||||
)
|
)
|
||||||
return buildSyntheticProperty {
|
return buildSyntheticProperty {
|
||||||
this.session = session
|
this.session = session
|
||||||
|
|||||||
Reference in New Issue
Block a user