FIR: Add context receivers from the containing class to constructors

This commit is contained in:
Denis.Zharkov
2022-03-09 15:37:53 +03:00
committed by teamcity
parent b2d5bf3eae
commit 202413c2f4
6 changed files with 8 additions and 33 deletions
@@ -528,6 +528,7 @@ class DeclarationsConverter(
)
//parse primary constructor
val primaryConstructorWrapper = convertPrimaryConstructor(
classNode,
primaryConstructor,
selfType.source,
classWrapper,
@@ -670,6 +671,7 @@ class DeclarationsConverter(
)
//parse primary constructor
convertPrimaryConstructor(
objectDeclaration,
primaryConstructor,
delegatedSelfType.source,
classWrapper,
@@ -760,6 +762,7 @@ class DeclarationsConverter(
)
superTypeRefs += enumClassWrapper.delegatedSuperTypeRef
convertPrimaryConstructor(
enumEntry,
null,
enumEntry.toFirSourceElement(),
enumClassWrapper,
@@ -822,6 +825,7 @@ class DeclarationsConverter(
* primaryConstructor branch
*/
private fun convertPrimaryConstructor(
classNode: LighterASTNode,
primaryConstructor: LighterASTNode?,
selfTypeSource: KtSourceElement?,
classWrapper: ClassWrapper,
@@ -896,6 +900,7 @@ class DeclarationsConverter(
this.valueParameters += valueParameters.map { it.firValueParameter }
delegatedConstructor = firDelegatedCall
this.body = null
this.contextReceivers.addAll(convertContextReceivers(classNode))
}.apply {
containingClassForStaticMemberAttr = currentDispatchReceiverType()!!.lookupTag
}, valueParameters
@@ -894,6 +894,7 @@ open class RawFirBuilder(
symbol = FirConstructorSymbol(callableIdForClassConstructor())
delegatedConstructor = firDelegatedCall
typeParameters += constructorTypeParametersFromConstructedClass(ownerTypeParameters)
this.contextReceivers.addAll(convertContextReceivers(owner.contextReceivers))
this@toFirConstructor?.extractAnnotationsTo(this)
this@toFirConstructor?.extractValueParametersTo(this, ValueParameterDeclaration.PRIMARY_CONSTRUCTOR)
this.body = body