[FIR] Fix light tree's supertype FirDelegatedConstructorCall source
This commit is contained in:
+19
-13
@@ -465,7 +465,7 @@ class DeclarationsConverter(
|
||||
)
|
||||
//parse primary constructor
|
||||
val primaryConstructorWrapper = convertPrimaryConstructor(
|
||||
primaryConstructor, classNode, classWrapper, delegatedConstructorSource,
|
||||
primaryConstructor, selfType.source, classWrapper, delegatedConstructorSource,
|
||||
delegationSpecifiers?.primaryConstructorBody
|
||||
)
|
||||
val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor
|
||||
@@ -572,7 +572,7 @@ class DeclarationsConverter(
|
||||
superTypeCallEntry = superTypeCallEntry
|
||||
)
|
||||
//parse primary constructor
|
||||
convertPrimaryConstructor(primaryConstructor, objectLiteral, classWrapper, delegatedConstructorSource, primaryConstructorBody)
|
||||
convertPrimaryConstructor(primaryConstructor, typeRef.source, classWrapper, delegatedConstructorSource, primaryConstructorBody)
|
||||
?.let { this.declarations += it.firConstructor }
|
||||
|
||||
//parse declarations
|
||||
@@ -643,9 +643,7 @@ class DeclarationsConverter(
|
||||
superTypeCallEntry = enumSuperTypeCallEntry
|
||||
)
|
||||
superTypeRefs += enumClassWrapper.delegatedSuperTypeRef
|
||||
convertPrimaryConstructor(null, enumEntry, enumClassWrapper, null)?.let {
|
||||
declarations += it.firConstructor
|
||||
}
|
||||
convertPrimaryConstructor(null, null, enumClassWrapper, null)?.let { declarations += it.firConstructor }
|
||||
classBodyNode?.also { declarations += convertClassBody(it, enumClassWrapper) }
|
||||
}
|
||||
}
|
||||
@@ -693,7 +691,7 @@ class DeclarationsConverter(
|
||||
*/
|
||||
private fun convertPrimaryConstructor(
|
||||
primaryConstructor: LighterASTNode?,
|
||||
classNode: LighterASTNode,
|
||||
selfTypeSource: FirSourceElement?,
|
||||
classWrapper: ClassWrapper,
|
||||
delegatedConstructorSource: FirLightSourceElement?,
|
||||
body: FirBlock? = null
|
||||
@@ -712,7 +710,7 @@ class DeclarationsConverter(
|
||||
|
||||
val defaultVisibility = classWrapper.defaultConstructorVisibility()
|
||||
val firDelegatedCall = buildDelegatedConstructorCall {
|
||||
source = delegatedConstructorSource
|
||||
source = delegatedConstructorSource ?: selfTypeSource?.fakeElement(FirFakeSourceElementKind.DelegatingConstructorCall)
|
||||
constructedTypeRef = classWrapper.delegatedSuperTypeRef
|
||||
isThis = false
|
||||
extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode)
|
||||
@@ -730,7 +728,7 @@ class DeclarationsConverter(
|
||||
return PrimaryConstructor(
|
||||
buildPrimaryConstructor {
|
||||
source = primaryConstructor?.toFirSourceElement()
|
||||
?: classNode.toFirSourceElement(FirFakeSourceElementKind.ImplicitConstructor)
|
||||
?: selfTypeSource?.fakeElement(FirFakeSourceElementKind.ImplicitConstructor)
|
||||
session = baseSession
|
||||
origin = FirDeclarationOrigin.Source
|
||||
returnTypeRef = classWrapper.delegatedSelfTypeRef
|
||||
@@ -1344,7 +1342,11 @@ class DeclarationsConverter(
|
||||
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 superTypeCallEntry = mutableListOf<FirExpression>()
|
||||
var delegatedSuperTypeRef: FirTypeRef? = null
|
||||
@@ -1356,9 +1358,6 @@ class DeclarationsConverter(
|
||||
when (it.tokenType) {
|
||||
SUPER_TYPE_ENTRY -> {
|
||||
superTypeRefs += convertType(it)
|
||||
if (delegateConstructorSource == null) {
|
||||
delegateConstructorSource = it.toFirSourceElement()
|
||||
}
|
||||
}
|
||||
SUPER_TYPE_CALL_ENTRY -> convertConstructorInvocation(it).apply {
|
||||
delegatedSuperTypeRef = first
|
||||
@@ -1367,7 +1366,14 @@ class DeclarationsConverter(
|
||||
delegateConstructorSource = it.toFirSourceElement(FirFakeSourceElementKind.DelegatingConstructorCall)
|
||||
}
|
||||
DELEGATED_SUPER_TYPE_ENTRY -> {
|
||||
superTypeRefs += convertExplicitDelegation(it, delegateNumber, delegateFields, initializeDelegateStatements, containerSymbol, delegatedTypeRef)
|
||||
superTypeRefs += convertExplicitDelegation(
|
||||
it,
|
||||
delegateNumber,
|
||||
delegateFields,
|
||||
initializeDelegateStatements,
|
||||
containerSymbol,
|
||||
delegatedTypeRef
|
||||
)
|
||||
delegateNumber++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user