K2: minor, remove misleading FirMemberDeclaration.containerSource

"Container source" means "the source of the container". So, if you
called this extension on a class (`FirClassLikeDeclaration`), it was
reasonable to assume that you would get the source of its _containing
class_, whereas the function actually returned the source of the class
itself.

Instead of inventing another name for this function, I've decided to
inline and remove it because it has only one usage.
This commit is contained in:
Alexander Udalov
2023-08-03 16:01:25 +02:00
committed by Space Team
parent 54a5f7d8f2
commit 1d5ade1166
2 changed files with 8 additions and 9 deletions
@@ -49,12 +49,6 @@ var <T> T.danglingTypeConstraints: List<DanglingTypeConstraint>?
// ----------------------------------- Utils -----------------------------------
val FirMemberDeclaration.containerSource: SourceElement?
get() = when (this) {
is FirCallableDeclaration -> containerSource
is FirClassLikeDeclaration -> sourceElement
}
val FirProperty.hasExplicitBackingField: Boolean
get() = backingField != null && backingField !is FirDefaultPropertyBackingField
@@ -7,8 +7,10 @@ package org.jetbrains.kotlin.backend.konan.descriptors
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
import org.jetbrains.kotlin.fir.declarations.utils.containerSource
import org.jetbrains.kotlin.fir.declarations.utils.sourceElement
import org.jetbrains.kotlin.fir.lazy.AbstractFir2IrLazyDeclaration
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
@@ -62,8 +64,11 @@ private fun DeclarationDescriptor.isFromFirDeserializedInteropLibrary(): Boolean
// - K2 metadata deserializer doesn't set containerSource for property accessors.
val topLevelDeclaration = declaration.findTopLevelDeclaration().propertyIfAccessor()
val firDeclaration = (topLevelDeclaration as? AbstractFir2IrLazyDeclaration<*>)?.fir ?: return false
val containerSource = (firDeclaration as? FirMemberDeclaration)?.containerSource
val firDeclaration = (topLevelDeclaration as? AbstractFir2IrLazyDeclaration<*>)?.fir as? FirMemberDeclaration ?: return false
val containerSource = when (firDeclaration) {
is FirCallableDeclaration -> firDeclaration.containerSource
is FirClassLikeDeclaration -> firDeclaration.sourceElement
}
return containerSource is KlibDeserializedContainerSource && containerSource.isFromNativeInteropLibrary
}