Fir2Ir: handle enum entries in Fir2IrProvider
NB: only the easy path works for sure. Need to have a look at: - enum entry members - Java enum entries
This commit is contained in:
committed by
Alexander Udalov
parent
0653ba7313
commit
ff2f6fe5e5
@@ -93,6 +93,12 @@ class FirIrProvider(val fir2IrComponents: Fir2IrComponents) : IrProvider {
|
|||||||
firCandidates = listOf(firClass)
|
firCandidates = listOf(firClass)
|
||||||
parent = firParentClass?.let { classifierStorage.getIrClassSymbol(it.symbol).owner } ?: packageFragment
|
parent = firParentClass?.let { classifierStorage.getIrClassSymbol(it.symbol).owner } ?: packageFragment
|
||||||
}
|
}
|
||||||
|
SymbolKind.ENUM_ENTRY_SYMBOL -> {
|
||||||
|
val lastName = Name.guessByFirstCharacter(nameSegments.last())
|
||||||
|
val firCandidate = firClass.declarations.singleOrNull { (it as? FirEnumEntry)?.name == lastName }
|
||||||
|
firCandidates = firCandidate?.let { listOf(it) } ?: return null
|
||||||
|
parent = classifierStorage.getIrClassSymbol(firClass.symbol).owner
|
||||||
|
}
|
||||||
SymbolKind.CONSTRUCTOR_SYMBOL -> {
|
SymbolKind.CONSTRUCTOR_SYMBOL -> {
|
||||||
val constructors = mutableListOf<FirConstructor>()
|
val constructors = mutableListOf<FirConstructor>()
|
||||||
scope.processDeclaredConstructors { constructors.add(it.fir) }
|
scope.processDeclaredConstructors { constructors.add(it.fir) }
|
||||||
@@ -139,6 +145,7 @@ class FirIrProvider(val fir2IrComponents: Fir2IrComponents) : IrProvider {
|
|||||||
|
|
||||||
return when (kind) {
|
return when (kind) {
|
||||||
SymbolKind.CLASS_SYMBOL -> classifierStorage.getIrClassSymbol((firDeclaration as FirRegularClass).symbol).owner
|
SymbolKind.CLASS_SYMBOL -> classifierStorage.getIrClassSymbol((firDeclaration as FirRegularClass).symbol).owner
|
||||||
|
SymbolKind.ENUM_ENTRY_SYMBOL -> classifierStorage.createIrEnumEntry(firDeclaration as FirEnumEntry, parent as IrClass)
|
||||||
SymbolKind.CONSTRUCTOR_SYMBOL -> {
|
SymbolKind.CONSTRUCTOR_SYMBOL -> {
|
||||||
val firConstructor = firDeclaration as FirConstructor
|
val firConstructor = firDeclaration as FirConstructor
|
||||||
declarationStorage.getOrCreateIrConstructor(firConstructor, parent as IrClass)
|
declarationStorage.getOrCreateIrConstructor(firConstructor, parent as IrClass)
|
||||||
@@ -163,7 +170,7 @@ class FirIrProvider(val fir2IrComponents: Fir2IrComponents) : IrProvider {
|
|||||||
candidates.firstOrNull { candidate ->
|
candidates.firstOrNull { candidate ->
|
||||||
if (hash == null) {
|
if (hash == null) {
|
||||||
// We don't compute id for type aliases and classes.
|
// We don't compute id for type aliases and classes.
|
||||||
candidate is FirClass || candidate is FirTypeAlias
|
candidate is FirClass || candidate is FirEnumEntry || candidate is FirTypeAlias
|
||||||
} else {
|
} else {
|
||||||
// The next line should have singleOrNull, but in some cases we get multiple references to the same FIR declaration.
|
// The next line should have singleOrNull, but in some cases we get multiple references to the same FIR declaration.
|
||||||
with(fir2IrComponents.signatureComposer.mangler) { candidate.signatureMangle(compatibleMode = false) == hash }
|
with(fir2IrComponents.signatureComposer.mangler) { candidate.signatureMangle(compatibleMode = false) == hash }
|
||||||
|
|||||||
Reference in New Issue
Block a user