Support delegation by interface for inline classes in FIR
#KT-27435 Fixed
This commit is contained in:
+9
@@ -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(
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// WITH_STDLIB
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// LANGUAGE: +InlineClassImplementationByDelegation
|
||||
|
||||
interface I {
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// WITH_STDLIB
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// LANGUAGE: +InlineClassImplementationByDelegation
|
||||
|
||||
interface I {
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// WITH_STDLIB
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// LANGUAGE: +InlineClassImplementationByDelegation
|
||||
|
||||
interface I {
|
||||
|
||||
+4
-4
@@ -9,10 +9,10 @@ class CFoo : IFoo
|
||||
|
||||
val c = CFoo()
|
||||
|
||||
inline class Test1(val x: Any) : <!VALUE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo by FooImpl<!>
|
||||
inline class Test1(val x: Any) : <!VALUE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo<!> by FooImpl
|
||||
|
||||
inline class Test2(val x: IFoo) : <!VALUE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo by x<!>
|
||||
inline class Test2(val x: IFoo) : IFoo by x
|
||||
|
||||
inline class Test3(val x: IFoo) : <!VALUE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo by CFoo()<!>
|
||||
inline class Test3(val x: IFoo) : <!VALUE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo<!> by CFoo()
|
||||
|
||||
inline class Test4(val x: IFoo) : <!VALUE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo by c<!>
|
||||
inline class Test4(val x: IFoo) : <!VALUE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo<!> by c
|
||||
|
||||
Reference in New Issue
Block a user