IR: extract & rename getTopLevelDeclaration() to IrLazyFunctionBase
This commit is contained in:
committed by
Space Team
parent
7420008af9
commit
f075c9d50b
@@ -123,18 +123,10 @@ abstract class AbstractFir2IrLazyFunction<F : FirCallableDeclaration>(
|
||||
private fun tryLoadIr(): Boolean {
|
||||
if (!isInline || isFakeOverride) return false
|
||||
if (!extensions.irNeedsDeserialization) return false
|
||||
val toplevel = getToplevel()
|
||||
val toplevel = getTopLevelDeclaration()
|
||||
return (toplevel as? DeserializableClass)?.loadIr() ?: false
|
||||
}
|
||||
|
||||
private fun getToplevel(): IrDeclaration {
|
||||
var current: IrDeclaration = this
|
||||
while (current.parent !is IrPackageFragment) {
|
||||
current = current.parent as IrDeclaration
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val JVM_STATIC_CLASS_ID = ClassId.topLevel(JVM_STATIC_ANNOTATION_FQ_NAME)
|
||||
}
|
||||
|
||||
@@ -113,18 +113,10 @@ class IrLazyFunction(
|
||||
private fun tryLoadIr(): Boolean {
|
||||
if (!stubGenerator.extensions.irDeserializationEnabled) return false
|
||||
if (!isInline || isFakeOverride) return false
|
||||
val toplevel = getToplevel()
|
||||
val toplevel = getTopLevelDeclaration()
|
||||
return (toplevel as? DeserializableClass)?.loadIr() ?: false
|
||||
}
|
||||
|
||||
private fun getToplevel(): IrDeclaration {
|
||||
var current: IrDeclaration = this
|
||||
while (current.parent !is IrPackageFragment) {
|
||||
current = current.parent as IrDeclaration
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
+9
-3
@@ -9,9 +9,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -22,6 +20,14 @@ interface IrLazyFunctionBase : IrLazyDeclarationBase, IrTypeParametersContainer
|
||||
|
||||
val initialSignatureFunction: IrFunction?
|
||||
|
||||
fun getTopLevelDeclaration(): IrDeclaration {
|
||||
var current: IrDeclaration = this
|
||||
while (current.parent !is IrPackageFragment) {
|
||||
current = current.parent as IrDeclaration
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
||||
fun createInitialSignatureFunction(): Lazy<IrFunction?> =
|
||||
// Need SYNCHRONIZED; otherwise two stubs generated in parallel may fight for the same symbol.
|
||||
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
|
||||
Reference in New Issue
Block a user