Skip to content

Commit

Permalink
[FIR] Don't add annotations from IR plugin to metadata of synthetic f…
Browse files Browse the repository at this point in the history
…unctions

Synthetic functions (like delegated or data class members) might have
  offsets equal to offsets of some real declaration, which may cause
  clashes with some real declarations with added annotations. Ideally
  we shouldn't use offsets as keys at all, but it will be addressed
  later (KT-72957)

^KT-72804
  • Loading branch information
demiurg906 authored and Space Team committed Nov 11, 2024
1 parent 0f1c7a7 commit 545c7a8
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir.backend

import org.jetbrains.kotlin.GeneratedDeclarationKey
import org.jetbrains.kotlin.KtFakeSourceElementKind
import org.jetbrains.kotlin.KtSourceElement
import org.jetbrains.kotlin.backend.common.extensions.IrGeneratedDeclarationsRegistrar
import org.jetbrains.kotlin.descriptors.Modality
Expand Down Expand Up @@ -509,6 +510,12 @@ class Fir2IrIrGeneratedDeclarationsRegistrar(private val components: Fir2IrCompo
}

private fun extractGeneratedIrDeclarations(declaration: FirDeclaration): List<IrConstructorCall> {
when (declaration.origin) {
is FirDeclarationOrigin.Synthetic,
is FirDeclarationOrigin.Delegated
-> return emptyList()
else -> {}
}
val firFile = declaration.containingFile() ?: return emptyList()
val fileFqName = firFile.packageFqName.child(Name.identifier(firFile.name)).asString()
val source = declaration.source ?: return emptyList()
Expand Down

0 comments on commit 545c7a8

Please sign in to comment.