FIR: make class delegation field a fake source
Previously, the FirFieldImpl generated from class delegation has a real source. This causes troubles in the IDE. This change adds a new fake source kind for class delegation fields.
This commit is contained in:
committed by
TeamCityServer
parent
0b8b20eda0
commit
d09be811f0
+1
-1
@@ -1574,7 +1574,7 @@ class DeclarationsConverter(
|
|||||||
val delegateName = Name.special("<\$\$delegate_${delegateFields.size}>")
|
val delegateName = Name.special("<\$\$delegate_${delegateFields.size}>")
|
||||||
delegateFields.add(
|
delegateFields.add(
|
||||||
buildField {
|
buildField {
|
||||||
source = firExpression!!.source
|
source = firExpression!!.source?.fakeElement(FirFakeSourceElementKind.ClassDelegationField)
|
||||||
declarationSiteSession = baseSession
|
declarationSiteSession = baseSession
|
||||||
origin = FirDeclarationOrigin.Synthetic
|
origin = FirDeclarationOrigin.Synthetic
|
||||||
name = delegateName
|
name = delegateName
|
||||||
|
|||||||
@@ -566,7 +566,8 @@ open class RawFirBuilder(
|
|||||||
val delegateExpression = { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate")
|
val delegateExpression = { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate")
|
||||||
container.superTypeRefs += type
|
container.superTypeRefs += type
|
||||||
val delegateName = Name.special("<\$\$delegate_${delegateFields.size}>")
|
val delegateName = Name.special("<\$\$delegate_${delegateFields.size}>")
|
||||||
val delegateSource = superTypeListEntry.delegateExpression?.toFirSourceElement()
|
val delegateSource =
|
||||||
|
superTypeListEntry.delegateExpression?.toFirSourceElement(FirFakeSourceElementKind.ClassDelegationField)
|
||||||
val delegateField = buildField {
|
val delegateField = buildField {
|
||||||
source = delegateSource
|
source = delegateSource
|
||||||
declarationSiteSession = baseSession
|
declarationSiteSession = baseSession
|
||||||
|
|||||||
@@ -170,6 +170,10 @@ sealed class FirFakeSourceElementKind : FirSourceElementKind() {
|
|||||||
// for java annotations constructor implicit parameters are generated
|
// for java annotations constructor implicit parameters are generated
|
||||||
// with a fake source which refers to declared annotation methods
|
// with a fake source which refers to declared annotation methods
|
||||||
object ImplicitAnnotationAnnotationConstructorParameter : FirFakeSourceElementKind()
|
object ImplicitAnnotationAnnotationConstructorParameter : FirFakeSourceElementKind()
|
||||||
|
|
||||||
|
// for the implicit field storing the delegated object for class delegation
|
||||||
|
// with a fake source that refers to the KtExpression that creates the delegate
|
||||||
|
object ClassDelegationField : FirFakeSourceElementKind()
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class FirSourceElement {
|
sealed class FirSourceElement {
|
||||||
|
|||||||
Reference in New Issue
Block a user