[FIR, IR] Cleanup: drop unused allowClassActualizationWithWiderVisibility & allowTransitiveSupertypesActualization
These flags were used when ExpectActualMatchingContext was reused in K1.
This commit is contained in:
-6
@@ -49,12 +49,6 @@ class FirExpectActualMatchingContextImpl private constructor(
|
||||
override val shouldCheckDefaultParams: Boolean
|
||||
get() = true
|
||||
|
||||
override val allowClassActualizationWithWiderVisibility: Boolean
|
||||
get() = true
|
||||
|
||||
override val allowTransitiveSupertypesActualization: Boolean
|
||||
get() = true
|
||||
|
||||
override val expectScopeSession: ScopeSession
|
||||
// todo KT-63773 design a way for managing scope sessions for common scopes during matching.
|
||||
// Right now we create a new session every time
|
||||
|
||||
-6
@@ -41,12 +41,6 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
val typeContext: IrTypeSystemContext,
|
||||
val expectToActualClassMap: Map<ClassId, IrClassSymbol>
|
||||
) : ExpectActualMatchingContext<IrSymbol>, TypeSystemContext by typeContext {
|
||||
override val allowClassActualizationWithWiderVisibility: Boolean
|
||||
get() = true
|
||||
|
||||
override val allowTransitiveSupertypesActualization: Boolean
|
||||
get() = true
|
||||
|
||||
// This incompatibility is often suppressed in the source code (e.g. in kotlin-stdlib).
|
||||
// The backend must be able to do expect-actual matching to emit bytecode
|
||||
// That's why we disable the checker here. Probably, this checker can be enabled once KT-60426 is fixed
|
||||
|
||||
-31
@@ -161,36 +161,6 @@ object AbstractExpectActualChecker {
|
||||
expectClassSymbol: RegularClassSymbolMarker,
|
||||
actualClassSymbol: RegularClassSymbolMarker,
|
||||
substitutor: TypeSubstitutorMarker,
|
||||
): Boolean {
|
||||
return when (allowTransitiveSupertypesActualization) {
|
||||
false -> areCompatibleSupertypesOneByOne(expectClassSymbol, actualClassSymbol, substitutor)
|
||||
true -> areCompatibleSupertypesTransitive(expectClassSymbol, actualClassSymbol, substitutor)
|
||||
}
|
||||
}
|
||||
|
||||
context(ExpectActualMatchingContext<*>)
|
||||
private fun areCompatibleSupertypesOneByOne(
|
||||
expectClassSymbol: RegularClassSymbolMarker,
|
||||
actualClassSymbol: RegularClassSymbolMarker,
|
||||
substitutor: TypeSubstitutorMarker,
|
||||
): Boolean {
|
||||
// Subtract kotlin.Any from supertypes because it's implicitly added if no explicit supertype is specified,
|
||||
// and not added if an explicit supertype _is_ specified
|
||||
val expectSupertypes = expectClassSymbol.superTypes.filterNot { it.typeConstructor().isAnyConstructor() }
|
||||
val actualSupertypes = actualClassSymbol.superTypes.filterNot { it.typeConstructor().isAnyConstructor() }
|
||||
return expectSupertypes.all { expectSupertype ->
|
||||
val substitutedExpectType = substitutor.safeSubstitute(expectSupertype)
|
||||
actualSupertypes.any { actualSupertype ->
|
||||
areCompatibleExpectActualTypes(substitutedExpectType, actualSupertype, parameterOfAnnotationComparisonMode = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context(ExpectActualMatchingContext<*>)
|
||||
private fun areCompatibleSupertypesTransitive(
|
||||
expectClassSymbol: RegularClassSymbolMarker,
|
||||
actualClassSymbol: RegularClassSymbolMarker,
|
||||
substitutor: TypeSubstitutorMarker,
|
||||
): Boolean {
|
||||
val expectSupertypes = expectClassSymbol.superTypes.filterNot { it.typeConstructor().isAnyConstructor() }
|
||||
val actualType = actualClassSymbol.defaultType
|
||||
@@ -505,7 +475,6 @@ object AbstractExpectActualChecker {
|
||||
val expectVisibility = expectClassSymbol.visibility
|
||||
val actualVisibility = actualClassSymbol.visibility
|
||||
if (expectVisibility == actualVisibility) return true
|
||||
if (!allowClassActualizationWithWiderVisibility) return false
|
||||
val result = Visibilities.compare(actualVisibility, expectVisibility)
|
||||
return result != null && result > 0
|
||||
}
|
||||
|
||||
-19
@@ -42,25 +42,6 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
|
||||
// - coroutines
|
||||
val shouldCheckDefaultParams: Boolean
|
||||
|
||||
/**
|
||||
* This flag determines, how visibilities for classes/typealiases will be matched
|
||||
* - `false` means that visibilities should be identical
|
||||
* - `true` means that visibility of actual class should be the same or wider comparing to expect visibility
|
||||
* this means that following actualizations will be additionally allowed:
|
||||
* - protected -> public
|
||||
* - internal -> public
|
||||
*/
|
||||
val allowClassActualizationWithWiderVisibility: Boolean
|
||||
get() = false
|
||||
|
||||
/**
|
||||
* This flag determines strategy for matching supertypes between expect and actual class
|
||||
* - `false` means that expect and actual supertypes are matched one by one
|
||||
* - `true` means that type of actual class should be subtype of each expect supertype of the expect class
|
||||
*/
|
||||
val allowTransitiveSupertypesActualization: Boolean
|
||||
get() = false
|
||||
|
||||
val RegularClassSymbolMarker.classId: ClassId
|
||||
val TypeAliasSymbolMarker.classId: ClassId
|
||||
val CallableSymbolMarker.callableId: CallableId
|
||||
|
||||
Reference in New Issue
Block a user