[FIR] add support for implementation by delgation
This commit handles "subclass: super-interface by delegate-expression". During Psi2Fir, for each delegate, we add to the subclass a synthetic field (which has type super-interface), and an assignment of the delegate-expression to the synthetic field in the primary constructor, so that the delegate-expression can be resolved and transformed along the way. During Fir2Ir, we look up delegatable members from the super-interface and generate corresponding functions/properties for the subclass. TODO: support for generic delegatable members and generic super-interface.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
1d45dc8d81
commit
d163853c97
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.FirRegularClassBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirFileImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
@@ -119,4 +119,7 @@ var FirProperty.isFromVararg: Boolean? by FirDeclarationDataRegistry.data(IsFrom
|
||||
|
||||
fun FirAnnotatedDeclaration.hasAnnotation(classId: ClassId): Boolean {
|
||||
return annotations.any { it.annotationTypeRef.coneTypeSafe<ConeClassLikeType>()?.classId == classId }
|
||||
}
|
||||
}
|
||||
|
||||
inline val FirDeclaration.isSynthetic: Boolean
|
||||
get() = origin == FirDeclarationOrigin.Synthetic
|
||||
|
||||
Reference in New Issue
Block a user