[FIR] Copy java enum entry during enhancement instead of mutating it

#KT-57949 Fixed
This commit is contained in:
Kirill Rakhman
2023-11-15 17:20:23 +01:00
committed by Space Team
parent f5168527ae
commit 49e786f088
3 changed files with 38 additions and 4 deletions
@@ -109,10 +109,14 @@ class FirSignatureEnhancement(
)
val newReturnTypeRef = enhanceReturnType(firElement, emptyList(), firElement.computeDefaultQualifiers(), predefinedInfo)
return firElement.symbol.apply {
this.fir.replaceReturnTypeRef(newReturnTypeRef)
session.lookupTracker?.recordTypeResolveAsLookup(newReturnTypeRef, this.fir.source, null)
}
return buildEnumEntryCopy(firElement) {
symbol = FirEnumEntrySymbol(firElement.symbol.callableId)
returnTypeRef = newReturnTypeRef
origin = FirDeclarationOrigin.Enhancement
}.apply {
session.lookupTracker?.recordTypeResolveAsLookup(newReturnTypeRef, this.source, null)
}.symbol
}
is FirField -> {
if (firElement.returnTypeRef !is FirJavaTypeRef) return original