diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInlineClassDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInlineClassDeclarationChecker.kt index fb9f4816fe5..f47ebfe6797 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInlineClassDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInlineClassDeclarationChecker.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.KtRealSourceElementKind +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.diagnostics.reportOn @@ -17,6 +18,8 @@ import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol import org.jetbrains.kotlin.fir.analysis.diagnostics.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.utils.* +import org.jetbrains.kotlin.fir.expressions.toResolvedCallableReference +import org.jetbrains.kotlin.fir.expressions.toResolvedCallableSymbol import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol @@ -95,6 +98,12 @@ object FirInlineClassDeclarationChecker : FirRegularClassChecker() { } is FirField -> { if (innerDeclaration.isSynthetic) { + val symbol = innerDeclaration.initializer?.toResolvedCallableSymbol() + if (context.languageVersionSettings.supportsFeature(LanguageFeature.InlineClassImplementationByDelegation) && + symbol != null && symbol == primaryConstructorParameter?.symbol + ) { + continue + } val delegatedTypeRefSource = (innerDeclaration.returnTypeRef as FirResolvedTypeRef).delegatedTypeRef?.source withSuppressedDiagnostics(innerDeclaration, context) { context -> reporter.reportOn( diff --git a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/default.kt b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/default.kt index 6fba5219962..9507a9dea3a 100644 --- a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/default.kt +++ b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/default.kt @@ -1,7 +1,6 @@ // WITH_STDLIB // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // LANGUAGE: +InlineClassImplementationByDelegation interface I { diff --git a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt index 0786aa24ba2..9f94a9a50fc 100644 --- a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt +++ b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt @@ -1,7 +1,6 @@ // WITH_STDLIB // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // LANGUAGE: +InlineClassImplementationByDelegation interface I { diff --git a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/simple.kt b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/simple.kt index 55639b8cd0d..551bcf53c4f 100644 --- a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/simple.kt +++ b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/simple.kt @@ -1,7 +1,6 @@ // WITH_STDLIB // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // LANGUAGE: +InlineClassImplementationByDelegation interface I { diff --git a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassCanImplementInterfaceByDelegation.fir.kt b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassCanImplementInterfaceByDelegation.fir.kt index 626aefbf6f7..7d9a7525a89 100644 --- a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassCanImplementInterfaceByDelegation.fir.kt +++ b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassCanImplementInterfaceByDelegation.fir.kt @@ -9,10 +9,10 @@ class CFoo : IFoo val c = CFoo() -inline class Test1(val x: Any) : IFoo by FooImpl +inline class Test1(val x: Any) : IFoo by FooImpl -inline class Test2(val x: IFoo) : IFoo by x +inline class Test2(val x: IFoo) : IFoo by x -inline class Test3(val x: IFoo) : IFoo by CFoo() +inline class Test3(val x: IFoo) : IFoo by CFoo() -inline class Test4(val x: IFoo) : IFoo by c +inline class Test4(val x: IFoo) : IFoo by c