[IR] Fix positioning of actual annotations diagnostic when reported on value

`parentsWithSelf` returns empty sequence if receiver is not a
`IrDeclarationParent`.

^KT-60668
^KT-60936
This commit is contained in:
Roman Efremov
2023-07-24 14:12:33 +02:00
committed by Space Team
parent ab1c0e3c48
commit 58a30d524c
2 changed files with 5 additions and 4 deletions
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.backend.common.actualizer
import org.jetbrains.kotlin.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf
import org.jetbrains.kotlin.backend.common.lower.parents
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
@@ -61,7 +61,8 @@ internal class IrExpectActualAnnotationMatchingChecker(
private fun getTypealiasSymbolIfActualizedViaTypealias(expectSymbol: IrSymbol): IrTypeAliasSymbol? {
val expectDeclaration = expectSymbol.owner as IrDeclaration
val topLevelExpectClass = expectDeclaration.parentsWithSelf.filterIsInstance<IrClass>().lastOrNull() ?: return null
val parentsWithSelf = sequenceOf(expectDeclaration) + expectDeclaration.parents
val topLevelExpectClass = parentsWithSelf.filterIsInstance<IrClass>().lastOrNull() ?: return null
val classId = topLevelExpectClass.classIdOrFail
return classActualizationInfo.actualTypeAliases[classId]
}
@@ -62,10 +62,10 @@ class MethodsInsideTypealiasImpl {
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual typealias <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>MethodsInsideTypealias<!> = MethodsInsideTypealiasImpl<!>
class ValueInsideTypealiasImpl {
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>val value: String = ""<!>
val value: String = ""
}
actual typealias <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>ValueInsideTypealias<!> = ValueInsideTypealiasImpl
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual typealias <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>ValueInsideTypealias<!> = ValueInsideTypealiasImpl<!>
class ConstructorInsideTypealiasImpl