[FIR, IR] Convert FirDefaultArgumentsInExpectActualizedByFakeOverrideChecker into ExpectActualCheckingCompatibility
FirDefaultArgumentsInExpectActualizedByFakeOverrideChecker is an adhoc checker which can be converted to ExpectActualCheckingCompatibility to reuse common expect-actual checking infrastructure. ^KT-62913 Fixed Review: https://jetbrains.team/p/kt/reviews/13094/timeline Tests that were broken by one of my previous commits are now fixed: - actualFakeOverride_paramsAreCompatibleViaSharedMethodWithDefaultParams.kt - inheritedJavaMembers.kt DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE diagnostic disappeared in delegation.fir.kt because only one AbstractExpectActualChecker incompatibility can be reported at a time (DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE is now reported not by adhoc checker but by common AbstractExpectActualChecker). It would be nice to report both of them, but it's a separate issue KT-62631 delegation2 test makes sure that DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE is reported when NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS is fixed
This commit is contained in:
+17
-3
@@ -50,7 +50,7 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
// 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
|
||||
override val shouldCheckAbsenceOfDefaultParamsInActual: Boolean
|
||||
override val shouldCheckDefaultParams: Boolean
|
||||
get() = false
|
||||
|
||||
private inline fun <R> CallableSymbolMarker.processIr(
|
||||
@@ -298,8 +298,16 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
onEnumEntry = { emptyList() }
|
||||
)
|
||||
|
||||
override fun FunctionSymbolMarker.allOverriddenDeclarationsRecursive(): Sequence<CallableSymbolMarker> =
|
||||
throw NotImplementedError("Not implemented because it's unused")
|
||||
override fun FunctionSymbolMarker.allRecursivelyOverriddenDeclarationsIncludingSelf(): Sequence<CallableSymbolMarker> =
|
||||
when (val node = asIr()) {
|
||||
is IrConstructor -> sequenceOf(this)
|
||||
is IrSimpleFunction -> (sequenceOf(this) + node.overriddenSymbols)
|
||||
// Tests work even if you don't filter out fake-overrides. Filtering fake-overrides is needed because
|
||||
// the returned descriptors are compared by `equals`. And `equals` for fake-overrides is weird.
|
||||
// I didn't manage to invent a test that would check this condition
|
||||
.filter { !it.asIr().isFakeOverride }
|
||||
else -> error("Unknown IR node: $node")
|
||||
}
|
||||
|
||||
override val FunctionSymbolMarker.valueParameters: List<ValueParameterSymbolMarker>
|
||||
get() = asIr().valueParameters.map { it.symbol }
|
||||
@@ -313,6 +321,9 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
override val ValueParameterSymbolMarker.hasDefaultValue: Boolean
|
||||
get() = asIr().hasDefaultValue()
|
||||
|
||||
override val ValueParameterSymbolMarker.hasDefaultValueNonRecursive: Boolean
|
||||
get() = asIr().defaultValue != null
|
||||
|
||||
override fun CallableSymbolMarker.isAnnotationConstructor(): Boolean {
|
||||
val irConstructor = safeAsIr<IrConstructor>() ?: return false
|
||||
return irConstructor.constructedClass.isAnnotationClass
|
||||
@@ -458,6 +469,9 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
return asIr().isFakeOverride
|
||||
}
|
||||
|
||||
override val CallableSymbolMarker.isDelegatedMember: Boolean
|
||||
get() = asIr().origin == IrDeclarationOrigin.DELEGATED_MEMBER
|
||||
|
||||
override val CallableSymbolMarker.hasStableParameterNames: Boolean
|
||||
get() {
|
||||
var ir = asIr()
|
||||
|
||||
Reference in New Issue
Block a user