[FIR] Fix light tree's supertype FirDelegatedConstructorCall source

This commit is contained in:
Nick
2020-08-04 13:26:40 +03:00
committed by Mikhail Glukhikh
parent a59cedcd39
commit 207027b84c
@@ -465,7 +465,7 @@ class DeclarationsConverter(
) )
//parse primary constructor //parse primary constructor
val primaryConstructorWrapper = convertPrimaryConstructor( val primaryConstructorWrapper = convertPrimaryConstructor(
primaryConstructor, classNode, classWrapper, delegatedConstructorSource, primaryConstructor, selfType.source, classWrapper, delegatedConstructorSource,
delegationSpecifiers?.primaryConstructorBody delegationSpecifiers?.primaryConstructorBody
) )
val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor
@@ -572,7 +572,7 @@ class DeclarationsConverter(
superTypeCallEntry = superTypeCallEntry superTypeCallEntry = superTypeCallEntry
) )
//parse primary constructor //parse primary constructor
convertPrimaryConstructor(primaryConstructor, objectLiteral, classWrapper, delegatedConstructorSource, primaryConstructorBody) convertPrimaryConstructor(primaryConstructor, typeRef.source, classWrapper, delegatedConstructorSource, primaryConstructorBody)
?.let { this.declarations += it.firConstructor } ?.let { this.declarations += it.firConstructor }
//parse declarations //parse declarations
@@ -643,9 +643,7 @@ class DeclarationsConverter(
superTypeCallEntry = enumSuperTypeCallEntry superTypeCallEntry = enumSuperTypeCallEntry
) )
superTypeRefs += enumClassWrapper.delegatedSuperTypeRef superTypeRefs += enumClassWrapper.delegatedSuperTypeRef
convertPrimaryConstructor(null, enumEntry, enumClassWrapper, null)?.let { convertPrimaryConstructor(null, null, enumClassWrapper, null)?.let { declarations += it.firConstructor }
declarations += it.firConstructor
}
classBodyNode?.also { declarations += convertClassBody(it, enumClassWrapper) } classBodyNode?.also { declarations += convertClassBody(it, enumClassWrapper) }
} }
} }
@@ -693,7 +691,7 @@ class DeclarationsConverter(
*/ */
private fun convertPrimaryConstructor( private fun convertPrimaryConstructor(
primaryConstructor: LighterASTNode?, primaryConstructor: LighterASTNode?,
classNode: LighterASTNode, selfTypeSource: FirSourceElement?,
classWrapper: ClassWrapper, classWrapper: ClassWrapper,
delegatedConstructorSource: FirLightSourceElement?, delegatedConstructorSource: FirLightSourceElement?,
body: FirBlock? = null body: FirBlock? = null
@@ -712,7 +710,7 @@ class DeclarationsConverter(
val defaultVisibility = classWrapper.defaultConstructorVisibility() val defaultVisibility = classWrapper.defaultConstructorVisibility()
val firDelegatedCall = buildDelegatedConstructorCall { val firDelegatedCall = buildDelegatedConstructorCall {
source = delegatedConstructorSource source = delegatedConstructorSource ?: selfTypeSource?.fakeElement(FirFakeSourceElementKind.DelegatingConstructorCall)
constructedTypeRef = classWrapper.delegatedSuperTypeRef constructedTypeRef = classWrapper.delegatedSuperTypeRef
isThis = false isThis = false
extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode) extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode)
@@ -730,7 +728,7 @@ class DeclarationsConverter(
return PrimaryConstructor( return PrimaryConstructor(
buildPrimaryConstructor { buildPrimaryConstructor {
source = primaryConstructor?.toFirSourceElement() source = primaryConstructor?.toFirSourceElement()
?: classNode.toFirSourceElement(FirFakeSourceElementKind.ImplicitConstructor) ?: selfTypeSource?.fakeElement(FirFakeSourceElementKind.ImplicitConstructor)
session = baseSession session = baseSession
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
returnTypeRef = classWrapper.delegatedSelfTypeRef returnTypeRef = classWrapper.delegatedSelfTypeRef
@@ -1344,7 +1342,11 @@ class DeclarationsConverter(
val primaryConstructorBody: FirBlock? val primaryConstructorBody: FirBlock?
) )
private fun convertDelegationSpecifiers(delegationSpecifiers: LighterASTNode, containerSymbol: AbstractFirBasedSymbol<*>, delegatedTypeRef: FirTypeRef): DelegationSpecifiers { private fun convertDelegationSpecifiers(
delegationSpecifiers: LighterASTNode,
containerSymbol: AbstractFirBasedSymbol<*>,
delegatedTypeRef: FirTypeRef
): DelegationSpecifiers {
val superTypeRefs = mutableListOf<FirTypeRef>() val superTypeRefs = mutableListOf<FirTypeRef>()
val superTypeCallEntry = mutableListOf<FirExpression>() val superTypeCallEntry = mutableListOf<FirExpression>()
var delegatedSuperTypeRef: FirTypeRef? = null var delegatedSuperTypeRef: FirTypeRef? = null
@@ -1356,9 +1358,6 @@ class DeclarationsConverter(
when (it.tokenType) { when (it.tokenType) {
SUPER_TYPE_ENTRY -> { SUPER_TYPE_ENTRY -> {
superTypeRefs += convertType(it) superTypeRefs += convertType(it)
if (delegateConstructorSource == null) {
delegateConstructorSource = it.toFirSourceElement()
}
} }
SUPER_TYPE_CALL_ENTRY -> convertConstructorInvocation(it).apply { SUPER_TYPE_CALL_ENTRY -> convertConstructorInvocation(it).apply {
delegatedSuperTypeRef = first delegatedSuperTypeRef = first
@@ -1367,7 +1366,14 @@ class DeclarationsConverter(
delegateConstructorSource = it.toFirSourceElement(FirFakeSourceElementKind.DelegatingConstructorCall) delegateConstructorSource = it.toFirSourceElement(FirFakeSourceElementKind.DelegatingConstructorCall)
} }
DELEGATED_SUPER_TYPE_ENTRY -> { DELEGATED_SUPER_TYPE_ENTRY -> {
superTypeRefs += convertExplicitDelegation(it, delegateNumber, delegateFields, initializeDelegateStatements, containerSymbol, delegatedTypeRef) superTypeRefs += convertExplicitDelegation(
it,
delegateNumber,
delegateFields,
initializeDelegateStatements,
containerSymbol,
delegatedTypeRef
)
delegateNumber++ delegateNumber++
} }
} }