diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.txt index ae86accc976..f91daa17e8c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.txt @@ -1,6 +1,6 @@ FILE: superNotAvailable.kt public final fun R|kotlin/String|.f(): R|kotlin/Unit| { - super<>.#(String()) + super<>@f#.#(String()) super<>.#(String()) } public final fun foo(): R|kotlin/Unit| { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/call/FirNotASupertypeChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/call/FirNotASupertypeChecker.kt index 58d584613bf..40608d88ade 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/call/FirNotASupertypeChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/call/FirNotASupertypeChecker.kt @@ -20,13 +20,14 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs object FirNotASupertypeChecker : FirQualifiedAccessChecker() { override fun check(functionCall: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) { - val surrounding = context.findClosestClass() ?: return + val superReference = functionCall.calleeReference.safeAs() - val targetClass = functionCall.calleeReference.safeAs() + val targetClass = superReference ?.superTypeRef ?.toRegularClass(context.session) ?: return + val surrounding = context.findClosestClass(superReference.labelName) ?: return if (!targetClass.isSupertypeOf(surrounding)) { reporter.report(functionCall.source) } @@ -37,13 +38,14 @@ object FirNotASupertypeChecker : FirQualifiedAccessChecker() { * item like FirRegularClass or FirAnonymousObject * or null if no such item could be found. */ - private fun CheckerContext.findClosestClass(): FirClass<*>? { + private fun CheckerContext.findClosestClass(label: String?): FirClass<*>? { for (it in containingDeclarations.reversed()) { - if ( - it is FirRegularClass || - it is FirAnonymousObject - ) { - return it as FirClass<*> + if (it is FirRegularClass || it is FirAnonymousObject) { + val firClass = it as FirClass<*> + val className = firClass.symbol.classId.shortClassName + if (label == null || (!className.isSpecial && className.identifier == label)) { + return firClass + } } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt index 3b3de00855d..3c29ae3f866 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConversionScope.kt @@ -96,6 +96,20 @@ class Fir2IrConversionScope { return irClass.thisReceiver } + fun dispatchReceiverParameter(label: String): IrValueParameter? { + for (function in functionStack.asReversed()) { + if (!function.name.isSpecial && function.name.identifier == label) { + function.dispatchReceiverParameter?.let { return it } + } + } + for (irClass in classStack.asReversed()) { + if (!irClass.name.isSpecial && irClass.name.identifier == label) { + return irClass.thisReceiver + } + } + return null + } + fun lastDispatchReceiverParameter(): IrValueParameter? { // Use the dispatch receiver of the containing/enclosing functions (from the last to the first) for (function in functionStack.asReversed()) { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index a33267a1fd2..a341e70bf00 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -166,8 +166,12 @@ internal class CallAndReferenceGenerator( ) return typeRef.convertWithOffsets { startOffset, endOffset -> if (qualifiedAccess.calleeReference is FirSuperReference) { + val superReference = qualifiedAccess.calleeReference as FirSuperReference if (typeRef !is FirComposedSuperTypeRef) { - val dispatchReceiver = conversionScope.lastDispatchReceiverParameter() + val label = superReference.labelName + val dispatchReceiver = + if (label != null) conversionScope.dispatchReceiverParameter(label) + else conversionScope.lastDispatchReceiverParameter() if (dispatchReceiver != null) { return@convertWithOffsets IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol) } diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index 0ee3edabfc2..2293b5670ae 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -1143,6 +1143,7 @@ class ExpressionsConverter( * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitSuperExpression */ private fun convertSuperExpression(superExpression: LighterASTNode): FirQualifiedAccessExpression { + val label: String? = superExpression.getLabelName() var superTypeRef: FirTypeRef = implicitType superExpression.forEachChildren { when (it.tokenType) { @@ -1153,6 +1154,7 @@ class ExpressionsConverter( return buildQualifiedAccessExpression { source = superExpression.toFirSourceElement() calleeReference = buildExplicitSuperReference { + labelName = label this.superTypeRef = superTypeRef } } diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 93c712ee8b5..3abb3d85485 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1723,6 +1723,7 @@ class RawFirBuilder( this.source = source calleeReference = buildExplicitSuperReference { this.source + labelName = expression.getLabelName() superTypeRef = superType.toFirOrImplicitType() } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 16af27e23d9..c2624236092 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference import org.jetbrains.kotlin.fir.references.FirThisReference import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate +import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue import org.jetbrains.kotlin.fir.resolve.calls.isSuperReferenceExpression import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor @@ -353,7 +354,12 @@ fun BodyResolveComponents.typeFromCallee(access: T): FirReso } } is FirSuperReference -> { - newCallee.superTypeRef as? FirResolvedTypeRef ?: buildErrorTypeRef { + val labelName = newCallee.labelName + val implicitReceiver = implicitReceiverStack[labelName] as? ImplicitDispatchReceiverValue + val resolvedTypeRef = + if (implicitReceiver != null) implicitReceiver.boundSymbol.phasedFir.superTypeRefs.singleOrNull() as? FirResolvedTypeRef + else newCallee.superTypeRef as? FirResolvedTypeRef + resolvedTypeRef ?: buildErrorTypeRef { source = newCallee.source diagnostic = ConeUnresolvedNameError(Name.identifier("super")) } @@ -375,7 +381,6 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol< } } is FirClassifierSymbol<*> -> { - val fir = (symbol as? AbstractFirBasedSymbol<*>)?.phasedFir // TODO: unhack buildResolvedTypeRef { source = null diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 3ba9fdd0546..7de7d7de330 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.references.builder.buildExplicitSuperReference import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.* +import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue import org.jetbrains.kotlin.fir.resolve.calls.candidate import org.jetbrains.kotlin.fir.resolve.diagnostics.* import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer @@ -89,7 +90,11 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : qualifiedAccessExpression.resultType = callee.superTypeRef } else -> { - val superTypeRefs = implicitReceiverStack.lastDispatchReceiver()?.boundSymbol?.phasedFir?.superTypeRefs + val labelName = callee.labelName + val implicitReceiver = + if (labelName != null) implicitReceiverStack[labelName] as? ImplicitDispatchReceiverValue + else implicitReceiverStack.lastDispatchReceiver() + val superTypeRefs = implicitReceiver?.boundSymbol?.phasedFir?.superTypeRefs val resultType = when { superTypeRefs?.isNotEmpty() != true -> { buildErrorTypeRef { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt index ea60c03fbae..1f6ec77e59e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt @@ -27,7 +27,7 @@ internal class FirDelegatedConstructorCallImpl( override var constructedTypeRef: FirTypeRef, override val isThis: Boolean, ) : FirDelegatedConstructorCall() { - override var calleeReference: FirReference = if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef) + override var calleeReference: FirReference = if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, null, constructedTypeRef) override val isSuper: Boolean get() = !isThis override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt index fb74b52d168..4afaa5de07b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* abstract class FirSuperReference : FirReference() { abstract override val source: FirSourceElement? + abstract val labelName: String? abstract val superTypeRef: FirTypeRef override fun accept(visitor: FirVisitor, data: D): R = visitor.visitSuperReference(this, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt index d91b9304908..1a7b4347e26 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirExplicitSuperReferenceBuilder.kt @@ -21,11 +21,13 @@ import org.jetbrains.kotlin.fir.visitors.* @FirBuilderDsl class FirExplicitSuperReferenceBuilder { var source: FirSourceElement? = null + var labelName: String? = null lateinit var superTypeRef: FirTypeRef fun build(): FirSuperReference { return FirExplicitSuperReference( source, + labelName, superTypeRef, ) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt index 18fda68fb6c..7bab3fc096b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* internal class FirExplicitSuperReference( override val source: FirSourceElement?, + override val labelName: String?, override var superTypeRef: FirTypeRef, ) : FirSuperReference() { override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 3a72bc44037..6bf915f9d37 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -962,6 +962,9 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM print("super<") superReference.superTypeRef.accept(this) print(">") + superReference.labelName?.let { + print("@$it#") + } } override fun visitQualifiedAccess(qualifiedAccess: FirQualifiedAccess) { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index be39864fc37..10cb58d799c 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -105,7 +105,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(delegatedConstructorCall) { default( "calleeReference", - "if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef)" + "if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, null, constructedTypeRef)" ) default("isSuper") { value = "!isThis" diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index c4dcff338c8..46395467a3c 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -521,6 +521,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild } superReference.configure { + +stringField("labelName", nullable = true) +field("superTypeRef", typeRef, withReplace = true) } diff --git a/compiler/testData/codegen/box/classes/kt2566_2.kt b/compiler/testData/codegen/box/classes/kt2566_2.kt index 5590c5ecf74..b119af85615 100644 --- a/compiler/testData/codegen/box/classes/kt2566_2.kt +++ b/compiler/testData/codegen/box/classes/kt2566_2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A { open val foo: String = "OK" } diff --git a/compiler/testData/codegen/box/super/enclosedFun.kt b/compiler/testData/codegen/box/super/enclosedFun.kt index bf2dbdfa208..5f317b46f77 100644 --- a/compiler/testData/codegen/box/super/enclosedFun.kt +++ b/compiler/testData/codegen/box/super/enclosedFun.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface BK { fun x() : Int = 50 } diff --git a/compiler/testData/codegen/box/super/kt3492ClassFun.kt b/compiler/testData/codegen/box/super/kt3492ClassFun.kt index a75140c80b1..1dd8d1b2770 100644 --- a/compiler/testData/codegen/box/super/kt3492ClassFun.kt +++ b/compiler/testData/codegen/box/super/kt3492ClassFun.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A { open fun foo2(): String = "OK" } diff --git a/compiler/testData/codegen/box/super/kt3492ClassProperty.kt b/compiler/testData/codegen/box/super/kt3492ClassProperty.kt index 055d9a4764c..25feedb525f 100644 --- a/compiler/testData/codegen/box/super/kt3492ClassProperty.kt +++ b/compiler/testData/codegen/box/super/kt3492ClassProperty.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A { open val foo: String = "OK" } diff --git a/compiler/testData/codegen/box/super/kt3492TraitFun.kt b/compiler/testData/codegen/box/super/kt3492TraitFun.kt index 08a85b5dfb0..144e86036a3 100644 --- a/compiler/testData/codegen/box/super/kt3492TraitFun.kt +++ b/compiler/testData/codegen/box/super/kt3492TraitFun.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface ATrait { open fun foo2(): String = "OK" } diff --git a/compiler/testData/codegen/box/super/kt3492TraitProperty.kt b/compiler/testData/codegen/box/super/kt3492TraitProperty.kt index f141d566948..c4c3298afcb 100644 --- a/compiler/testData/codegen/box/super/kt3492TraitProperty.kt +++ b/compiler/testData/codegen/box/super/kt3492TraitProperty.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { open val foo: String get() = "OK" diff --git a/compiler/testData/diagnostics/tests/inner/innerThisSuper.fir.kt b/compiler/testData/diagnostics/tests/inner/innerThisSuper.fir.kt index f6902c9ecda..e113a9abac0 100644 --- a/compiler/testData/diagnostics/tests/inner/innerThisSuper.fir.kt +++ b/compiler/testData/diagnostics/tests/inner/innerThisSuper.fir.kt @@ -7,16 +7,16 @@ interface Trait { class Outer : Trait { class Nested { val t = this@Outer.bar() - val s = super@Outer.bar() + val s = super@Outer.bar() inner class NestedInner { val t = this@Outer.bar() - val s = super@Outer.bar() + val s = super@Outer.bar() } } inner class Inner { val t = this@Outer.bar() - val s = super@Outer.bar() + val s = super@Outer.bar() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inner/localThisSuper.fir.kt b/compiler/testData/diagnostics/tests/inner/localThisSuper.fir.kt index 78c356415f1..2f39d731118 100644 --- a/compiler/testData/diagnostics/tests/inner/localThisSuper.fir.kt +++ b/compiler/testData/diagnostics/tests/inner/localThisSuper.fir.kt @@ -13,10 +13,10 @@ class Outer : Trait { inner class Inner { val t = this@Local - val s = super@Local.bar() + val s = super@Local.bar() val tt = this@Outer - val ss = super@Outer.bar() + val ss = super@Outer.bar() } } } diff --git a/compiler/testData/diagnostics/tests/j+k/defaultMethods.fir.kt b/compiler/testData/diagnostics/tests/j+k/defaultMethods.fir.kt index 2655a46b921..d0eeee7ed9c 100644 --- a/compiler/testData/diagnostics/tests/j+k/defaultMethods.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/defaultMethods.fir.kt @@ -24,7 +24,7 @@ interface KotlinInterface : JavaInterface { object { fun run () { - super@KotlinInterface.test() + super@KotlinInterface.test() } } } @@ -35,7 +35,7 @@ interface KotlinInterface : JavaInterface { object { fun run () { - super@KotlinInterface.test() + super@KotlinInterface.test() } } return "" @@ -53,7 +53,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.test() } } } @@ -64,7 +64,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.test() } } return "" @@ -79,7 +79,7 @@ open class KotlinClass : JavaInterface { object { fun run () { - super@KotlinClass.test() + super@KotlinClass.test() } } } @@ -91,7 +91,7 @@ open class KotlinClass : JavaInterface { object { fun run () { - super@KotlinClass.test() + super@KotlinClass.test() } } return "" @@ -106,7 +106,7 @@ class KotlinClassIndirectInheritance : KotlinClass() { object { fun run () { - super@KotlinClassIndirectInheritance.test() + super@KotlinClassIndirectInheritance.test() } } } @@ -118,7 +118,7 @@ class KotlinClassIndirectInheritance : KotlinClass() { object { fun run () { - super@KotlinClassIndirectInheritance.test() + super@KotlinClassIndirectInheritance.test() } } return "" @@ -133,7 +133,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { object { fun run () { - super@KotlinClassIndirectInheritance2.test() + super@KotlinClassIndirectInheritance2.test() } } } @@ -145,7 +145,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { object { fun run () { - super@KotlinClassIndirectInheritance2.test() + super@KotlinClassIndirectInheritance2.test() } } return "" diff --git a/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.fir.kt b/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.fir.kt index e7b765c005a..298332fb21a 100644 --- a/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.fir.kt @@ -26,7 +26,7 @@ interface KotlinInterface : JavaInterface { object { fun run () { - super@KotlinInterface.test() + super@KotlinInterface.test() } } } @@ -37,7 +37,7 @@ interface KotlinInterface : JavaInterface { object { fun run () { - super@KotlinInterface.test() + super@KotlinInterface.test() } } return "" @@ -55,7 +55,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.test() } } } @@ -66,7 +66,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.test() } } return "" @@ -81,7 +81,7 @@ open class KotlinClass : JavaInterface { object { fun run () { - super@KotlinClass.test() + super@KotlinClass.test() } } } @@ -93,7 +93,7 @@ open class KotlinClass : JavaInterface { object { fun run () { - super@KotlinClass.test() + super@KotlinClass.test() } } return "" @@ -108,7 +108,7 @@ class KotlinClassIndirectInheritance : KotlinClass() { object { fun run () { - super@KotlinClassIndirectInheritance.test() + super@KotlinClassIndirectInheritance.test() } } } @@ -120,7 +120,7 @@ class KotlinClassIndirectInheritance : KotlinClass() { object { fun run () { - super@KotlinClassIndirectInheritance.test() + super@KotlinClassIndirectInheritance.test() } } return "" @@ -135,7 +135,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { object { fun run () { - super@KotlinClassIndirectInheritance2.test() + super@KotlinClassIndirectInheritance2.test() } } } @@ -147,7 +147,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { object { fun run () { - super@KotlinClassIndirectInheritance2.test() + super@KotlinClassIndirectInheritance2.test() } } return "" diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt index b5c5e646f71..594f816ce77 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt @@ -7,6 +7,6 @@ class A { constructor(x: Any?) constructor() : this(object { fun bar() = foo() + this@A.foo() + - foobar() + super@A.hashCode() + foobar() + super@A.hashCode() }) } diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt index ea027ec6114..02e40b4f88d 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt @@ -31,7 +31,7 @@ class A() : C(), T { fun test() { super.foo(); super.bar() - super@A.bar() + super@A.bar() super@A.foo() super@B.foo() super@B.foo() diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.fir.kt deleted file mode 100644 index 5381b3d03f4..00000000000 --- a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.fir.kt +++ /dev/null @@ -1,33 +0,0 @@ -open class A { - open fun foo() {} -} - -interface B { - fun bar() {} -} - -interface Q { - fun qux() {} -} - -class C : A(), B { - override fun foo() { - super@C.foo() - } - - override fun bar() { - super@C.bar() - } - - inner class D : A(), Q { - override fun foo() { - super@C.foo() - super@D.foo() - } - - override fun qux() { - super@C.qux() - super@D.qux() - } - } -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.kt b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.kt index a7e2bb47dcb..943e875afc6 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class A { open fun foo() {} } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaults.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaults.fir.kt index bc1be09e34d..e5cd45535bd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaults.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaults.fir.kt @@ -33,11 +33,11 @@ interface KotlinInterface : KInterface { object { fun run () { - super@KotlinInterface.test() - super@KotlinInterface.property + super@KotlinInterface.test() + super@KotlinInterface.property - super@KotlinInterface.testNonDefault() - super@KotlinInterface.propertyNonDefault + super@KotlinInterface.testNonDefault() + super@KotlinInterface.propertyNonDefault } } } @@ -53,11 +53,11 @@ interface KotlinInterface : KInterface { object { fun run () { - super@KotlinInterface.test() - super@KotlinInterface.property + super@KotlinInterface.test() + super@KotlinInterface.property - super@KotlinInterface.testNonDefault() - super@KotlinInterface.propertyNonDefault + super@KotlinInterface.testNonDefault() + super@KotlinInterface.propertyNonDefault } } return "" @@ -72,11 +72,11 @@ interface KotlinInterface : KInterface { object { fun run () { - super@KotlinInterface.test() - super@KotlinInterface.property + super@KotlinInterface.test() + super@KotlinInterface.property - super@KotlinInterface.testNonDefault() - super@KotlinInterface.propertyNonDefault + super@KotlinInterface.testNonDefault() + super@KotlinInterface.propertyNonDefault } } } @@ -91,11 +91,11 @@ interface KotlinInterface : KInterface { object { fun run () { - super@KotlinInterface.test() - super@KotlinInterface.property + super@KotlinInterface.test() + super@KotlinInterface.property - super@KotlinInterface.testNonDefault() - super@KotlinInterface.propertyNonDefault + super@KotlinInterface.testNonDefault() + super@KotlinInterface.propertyNonDefault } } return "" @@ -115,11 +115,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() - super@KotlinInterfaceIndirectInheritance.property + super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.property - super@KotlinInterfaceIndirectInheritance.testNonDefault() - super@KotlinInterfaceIndirectInheritance.propertyNonDefault + super@KotlinInterfaceIndirectInheritance.testNonDefault() + super@KotlinInterfaceIndirectInheritance.propertyNonDefault } } } @@ -135,11 +135,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() - super@KotlinInterfaceIndirectInheritance.property + super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.property - super@KotlinInterfaceIndirectInheritance.testNonDefault() - super@KotlinInterfaceIndirectInheritance.propertyNonDefault + super@KotlinInterfaceIndirectInheritance.testNonDefault() + super@KotlinInterfaceIndirectInheritance.propertyNonDefault } } return "" @@ -154,11 +154,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() - super@KotlinInterfaceIndirectInheritance.property + super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.property - super@KotlinInterfaceIndirectInheritance.testNonDefault() - super@KotlinInterfaceIndirectInheritance.propertyNonDefault + super@KotlinInterfaceIndirectInheritance.testNonDefault() + super@KotlinInterfaceIndirectInheritance.propertyNonDefault } } } @@ -173,11 +173,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { object { fun run () { - super@KotlinInterfaceIndirectInheritance.test() - super@KotlinInterfaceIndirectInheritance.property + super@KotlinInterfaceIndirectInheritance.test() + super@KotlinInterfaceIndirectInheritance.property - super@KotlinInterfaceIndirectInheritance.testNonDefault() - super@KotlinInterfaceIndirectInheritance.propertyNonDefault + super@KotlinInterfaceIndirectInheritance.testNonDefault() + super@KotlinInterfaceIndirectInheritance.propertyNonDefault } } return "" @@ -194,11 +194,11 @@ open class KotlinClass : KInterface { object { fun run () { - super@KotlinClass.test() - super@KotlinClass.property + super@KotlinClass.test() + super@KotlinClass.property - super@KotlinClass.testNonDefault() - super@KotlinClass.propertyNonDefault + super@KotlinClass.testNonDefault() + super@KotlinClass.propertyNonDefault } } } @@ -213,11 +213,11 @@ open class KotlinClass : KInterface { object { fun run () { - super@KotlinClass.test() - super@KotlinClass.property + super@KotlinClass.test() + super@KotlinClass.property - super@KotlinClass.testNonDefault() - super@KotlinClass.propertyNonDefault + super@KotlinClass.testNonDefault() + super@KotlinClass.propertyNonDefault } } @@ -235,11 +235,11 @@ class KotlinClassIndirectInheritance : KotlinClass() { object { fun run () { - super@KotlinClassIndirectInheritance.test() - super@KotlinClassIndirectInheritance.property + super@KotlinClassIndirectInheritance.test() + super@KotlinClassIndirectInheritance.property - super@KotlinClassIndirectInheritance.testNonDefault() - super@KotlinClassIndirectInheritance.propertyNonDefault + super@KotlinClassIndirectInheritance.testNonDefault() + super@KotlinClassIndirectInheritance.propertyNonDefault } } @@ -255,11 +255,11 @@ class KotlinClassIndirectInheritance : KotlinClass() { object { fun run () { - super@KotlinClassIndirectInheritance.test() - super@KotlinClassIndirectInheritance.property + super@KotlinClassIndirectInheritance.test() + super@KotlinClassIndirectInheritance.property - super@KotlinClassIndirectInheritance.testNonDefault() - super@KotlinClassIndirectInheritance.propertyNonDefault + super@KotlinClassIndirectInheritance.testNonDefault() + super@KotlinClassIndirectInheritance.propertyNonDefault } } return "" @@ -276,11 +276,11 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { object { fun run () { - super@KotlinClassIndirectInheritance2.test() - super@KotlinClassIndirectInheritance2.property + super@KotlinClassIndirectInheritance2.test() + super@KotlinClassIndirectInheritance2.property - super@KotlinClassIndirectInheritance2.testNonDefault() - super@KotlinClassIndirectInheritance2.propertyNonDefault + super@KotlinClassIndirectInheritance2.testNonDefault() + super@KotlinClassIndirectInheritance2.propertyNonDefault } } } @@ -295,11 +295,11 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { object { fun run () { - super@KotlinClassIndirectInheritance2.test() - super@KotlinClassIndirectInheritance2.property + super@KotlinClassIndirectInheritance2.test() + super@KotlinClassIndirectInheritance2.property - super@KotlinClassIndirectInheritance2.testNonDefault() - super@KotlinClassIndirectInheritance2.propertyNonDefault + super@KotlinClassIndirectInheritance2.testNonDefault() + super@KotlinClassIndirectInheritance2.propertyNonDefault } } return "" diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.fir.kt deleted file mode 100644 index 7c75e729663..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.fir.kt +++ /dev/null @@ -1,162 +0,0 @@ -// !JVM_DEFAULT_MODE: enable -// !JVM_TARGET: 1.8 -// FILE: JavaInterface.java - -public interface JavaInterface { - default String test() { - return "OK"; - } - - default String testOverride() { - return "OK"; - } -} - -// FILE: 1.kt - -interface KotlinInterface : JavaInterface { - @JvmDefault - fun fooo() { - super.test() - - object { - fun run () { - super@KotlinInterface.test() - } - } - } - - @JvmDefault - val propertyy: String - get() { - super.test() - - object { - fun run () { - super@KotlinInterface.test() - } - } - return "" - } - - @JvmDefault - override fun testOverride(): String { - return "OK"; - } -} - -interface KotlinInterfaceIndirectInheritance : KotlinInterface { - @JvmDefault - fun foooo() { - super.test() - - object { - fun run () { - super@KotlinInterfaceIndirectInheritance.test() - } - } - } - - @JvmDefault - val propertyyy: String - get() { - super.test() - - object { - fun run () { - super@KotlinInterfaceIndirectInheritance.test() - } - } - return "" - } -} - -open class KotlinClass : JavaInterface { - fun foo() { - super.test() - super.testOverride() - - object { - fun run () { - super@KotlinClass.test() - } - } - } - - val property: String - get() { - super.test() - super.testOverride() - - object { - fun run () { - super@KotlinClass.test() - } - } - return "" - } -} - -class KotlinClassIndirectInheritance : KotlinClass() { - fun foo2() { - super.test() - super.testOverride() - - object { - fun run () { - super@KotlinClassIndirectInheritance.test() - } - } - } - - val property2: String - get() { - super.test() - super.testOverride() - - object { - fun run () { - super@KotlinClassIndirectInheritance.test() - } - } - return "" - } -} - -class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { - fun foo() { - super.test() - super.testOverride() - - object { - fun run () { - super@KotlinClassIndirectInheritance2.test() - } - } - } - - val property: String - get() { - super.test() - super.testOverride() - - object { - fun run () { - super@KotlinClassIndirectInheritance2.test() - } - } - return "" - } -} - -fun test() { - KotlinClass().foo() - KotlinClass().property - KotlinClassIndirectInheritance2().foo() - KotlinClassIndirectInheritance2().property - - KotlinClass().test() - KotlinClass().property - KotlinClass().testOverride() - KotlinClassIndirectInheritance().testOverride() -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.kt index b15d257c398..7d4719d6868 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultsWithJava.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !JVM_DEFAULT_MODE: enable // !JVM_TARGET: 1.8 // FILE: JavaInterface.java