[IR] Rename IrFakeOverride[Function|Property] to Ir[Function|Property]WithLateBinding
^KT-53663
This commit is contained in:
+1
-1
@@ -260,7 +260,7 @@ internal class LambdaMetafactoryArgumentsBuilder(
|
||||
val fakeClass = context.irFactory.buildClass { name = Name.special("<fake>") }
|
||||
fakeClass.parent = context.ir.symbols.kotlinJvmInternalInvokeDynamicPackage
|
||||
val fakeInstanceMethod = buildFakeOverrideMember(samType, samMethod, fakeClass) as IrSimpleFunction
|
||||
(fakeInstanceMethod as IrFakeOverrideFunction).acquireSymbol(IrSimpleFunctionSymbolImpl())
|
||||
(fakeInstanceMethod as IrFunctionWithLateBinding).acquireSymbol(IrSimpleFunctionSymbolImpl())
|
||||
fakeInstanceMethod.overriddenSymbols = listOf(samMethod.symbol)
|
||||
|
||||
// Compute signature adaptation constraints for a fake instance method signature against all relevant overrides.
|
||||
|
||||
+2
-2
@@ -13,9 +13,9 @@ import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
|
||||
/**
|
||||
* A leaf IR tree element.
|
||||
* @sample org.jetbrains.kotlin.ir.generator.IrTree.fakeOverrideFunction
|
||||
* @sample org.jetbrains.kotlin.ir.generator.IrTree.functionWithLateBinding
|
||||
*/
|
||||
interface IrFakeOverrideFunction : IrDeclaration {
|
||||
interface IrFunctionWithLateBinding : IrDeclaration {
|
||||
override val symbol: IrSimpleFunctionSymbol
|
||||
|
||||
var modality: Modality
|
||||
+2
-2
@@ -13,9 +13,9 @@ import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
|
||||
/**
|
||||
* A leaf IR tree element.
|
||||
* @sample org.jetbrains.kotlin.ir.generator.IrTree.fakeOverrideProperty
|
||||
* @sample org.jetbrains.kotlin.ir.generator.IrTree.propertyWithLateBinding
|
||||
*/
|
||||
interface IrFakeOverrideProperty : IrDeclaration {
|
||||
interface IrPropertyWithLateBinding : IrDeclaration {
|
||||
override val symbol: IrPropertySymbol
|
||||
|
||||
var modality: Modality
|
||||
@@ -108,7 +108,7 @@ interface IrFactory {
|
||||
containerSource: DeserializedContainerSource? = null,
|
||||
): IrSimpleFunction
|
||||
|
||||
fun createFakeOverrideFunction(
|
||||
fun createFunctionWithLateBinding(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -153,7 +153,7 @@ interface IrFactory {
|
||||
containerSource: DeserializedContainerSource? = null
|
||||
): IrProperty
|
||||
|
||||
fun createFakeOverrideProperty(
|
||||
fun createPropertyWithLateBinding(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
|
||||
@@ -132,7 +132,7 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
||||
containerSource, factory = this
|
||||
)
|
||||
|
||||
override fun createFakeOverrideFunction(
|
||||
override fun createFunctionWithLateBinding(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -148,7 +148,7 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrSimpleFunction =
|
||||
IrFakeOverrideFunctionImpl(
|
||||
IrFunctionWithLateBindingImpl(
|
||||
startOffset, endOffset, origin, name, visibility, modality, returnType,
|
||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
factory = this
|
||||
@@ -188,7 +188,7 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
||||
containerSource, factory = this
|
||||
)
|
||||
|
||||
override fun createFakeOverrideProperty(
|
||||
override fun createPropertyWithLateBinding(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -202,7 +202,7 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrProperty =
|
||||
IrFakeOverridePropertyImpl(
|
||||
IrPropertyWithLateBindingImpl(
|
||||
startOffset, endOffset, origin, name, visibility, modality,
|
||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
factory = this
|
||||
|
||||
+4
-4
@@ -199,7 +199,7 @@ class IrFactoryImplForJsIC(override val stageController: StageController) : Abst
|
||||
).register()
|
||||
}
|
||||
|
||||
override fun createFakeOverrideFunction(
|
||||
override fun createFunctionWithLateBinding(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -215,7 +215,7 @@ class IrFactoryImplForJsIC(override val stageController: StageController) : Abst
|
||||
isInfix: Boolean,
|
||||
isExpect: Boolean
|
||||
): IrSimpleFunction {
|
||||
return super.createFakeOverrideFunction(
|
||||
return super.createFunctionWithLateBinding(
|
||||
startOffset,
|
||||
endOffset,
|
||||
origin,
|
||||
@@ -289,7 +289,7 @@ class IrFactoryImplForJsIC(override val stageController: StageController) : Abst
|
||||
).register()
|
||||
}
|
||||
|
||||
override fun createFakeOverrideProperty(
|
||||
override fun createPropertyWithLateBinding(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -303,7 +303,7 @@ class IrFactoryImplForJsIC(override val stageController: StageController) : Abst
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean
|
||||
): IrProperty {
|
||||
return super.createFakeOverrideProperty(
|
||||
return super.createPropertyWithLateBinding(
|
||||
startOffset,
|
||||
endOffset,
|
||||
origin,
|
||||
|
||||
@@ -101,7 +101,7 @@ class IrFunctionImpl(
|
||||
}
|
||||
}
|
||||
|
||||
class IrFakeOverrideFunctionImpl(
|
||||
class IrFunctionWithLateBindingImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -121,7 +121,7 @@ class IrFakeOverrideFunctionImpl(
|
||||
startOffset, endOffset, origin, name, visibility, returnType, isInline,
|
||||
isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect,
|
||||
containerSource = null,
|
||||
), IrFakeOverrideFunction {
|
||||
), IrFunctionWithLateBinding {
|
||||
override val isFakeOverride: Boolean
|
||||
get() = true
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class IrPropertyImpl(
|
||||
get() = symbol.descriptor
|
||||
}
|
||||
|
||||
class IrFakeOverridePropertyImpl(
|
||||
class IrPropertyWithLateBindingImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -94,7 +94,7 @@ class IrFakeOverridePropertyImpl(
|
||||
) : IrPropertyCommonImpl(
|
||||
startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
containerSource = null,
|
||||
), IrFakeOverrideProperty {
|
||||
), IrPropertyWithLateBinding {
|
||||
override val isFakeOverride: Boolean
|
||||
get() = true
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class FakeOverrideCopier(
|
||||
}
|
||||
|
||||
override fun visitSimpleFunction(declaration: IrSimpleFunction): IrSimpleFunction =
|
||||
declaration.factory.createFakeOverrideFunction(
|
||||
declaration.factory.createFunctionWithLateBinding(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
symbolRenamer.getFunctionName(declaration.symbol),
|
||||
@@ -68,7 +68,7 @@ class FakeOverrideCopier(
|
||||
|
||||
|
||||
override fun visitProperty(declaration: IrProperty): IrProperty =
|
||||
declaration.factory.createFakeOverrideProperty(
|
||||
declaration.factory.createPropertyWithLateBinding(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
declaration.name,
|
||||
|
||||
@@ -24,14 +24,14 @@ abstract class FakeOverrideBuilderStrategy(private val friendModules: Map<String
|
||||
|
||||
fun linkFakeOverride(fakeOverride: IrOverridableMember, compatibilityMode: Boolean) {
|
||||
when (fakeOverride) {
|
||||
is IrFakeOverrideFunction -> linkFunctionFakeOverride(fakeOverride, compatibilityMode)
|
||||
is IrFakeOverrideProperty -> linkPropertyFakeOverride(fakeOverride, compatibilityMode)
|
||||
is IrFunctionWithLateBinding -> linkFunctionFakeOverride(fakeOverride, compatibilityMode)
|
||||
is IrPropertyWithLateBinding -> linkPropertyFakeOverride(fakeOverride, compatibilityMode)
|
||||
else -> error("Unexpected fake override: $fakeOverride")
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun linkFunctionFakeOverride(declaration: IrFakeOverrideFunction, compatibilityMode: Boolean)
|
||||
protected abstract fun linkPropertyFakeOverride(declaration: IrFakeOverrideProperty, compatibilityMode: Boolean)
|
||||
protected abstract fun linkFunctionFakeOverride(declaration: IrFunctionWithLateBinding, compatibilityMode: Boolean)
|
||||
protected abstract fun linkPropertyFakeOverride(declaration: IrPropertyWithLateBinding, compatibilityMode: Boolean)
|
||||
}
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class) // Because of the LazyIR, have to use descriptors here.
|
||||
@@ -376,7 +376,7 @@ class IrOverridingUtil(
|
||||
newModality: Modality,
|
||||
newVisibility: DescriptorVisibility
|
||||
): IrSimpleFunction? {
|
||||
require(this is IrFakeOverrideFunction) {
|
||||
require(this is IrFunctionWithLateBinding) {
|
||||
"Unexpected fake override accessor kind: $this"
|
||||
}
|
||||
// For descriptors it gets INVISIBLE_FAKE.
|
||||
@@ -405,13 +405,13 @@ class IrOverridingUtil(
|
||||
|
||||
val fakeOverride = mostSpecific.apply {
|
||||
when (this) {
|
||||
is IrFakeOverrideProperty -> {
|
||||
is IrPropertyWithLateBinding -> {
|
||||
this.visibility = visibility
|
||||
this.modality = modality
|
||||
this.getter = this.getter?.updateAccessorModalityAndVisibility(modality, visibility)
|
||||
this.setter = this.setter?.updateAccessorModalityAndVisibility(modality, visibility)
|
||||
}
|
||||
is IrFakeOverrideFunction -> {
|
||||
is IrFunctionWithLateBinding -> {
|
||||
this.visibility = visibility
|
||||
this.modality = modality
|
||||
}
|
||||
|
||||
@@ -1103,11 +1103,11 @@ val IrFunction.allParametersCount: Int
|
||||
// TODO: merge it with FakeOverrideBuilder.
|
||||
private class FakeOverrideBuilderForLowerings : FakeOverrideBuilderStrategy(emptyMap()) {
|
||||
|
||||
override fun linkFunctionFakeOverride(declaration: IrFakeOverrideFunction, compatibilityMode: Boolean) {
|
||||
override fun linkFunctionFakeOverride(declaration: IrFunctionWithLateBinding, compatibilityMode: Boolean) {
|
||||
declaration.acquireSymbol(IrSimpleFunctionSymbolImpl())
|
||||
}
|
||||
|
||||
override fun linkPropertyFakeOverride(declaration: IrFakeOverrideProperty, compatibilityMode: Boolean) {
|
||||
override fun linkPropertyFakeOverride(declaration: IrPropertyWithLateBinding, compatibilityMode: Boolean) {
|
||||
val propertySymbol = IrPropertySymbolImpl()
|
||||
declaration.getter?.let { it.correspondingPropertySymbol = propertySymbol }
|
||||
declaration.setter?.let { it.correspondingPropertySymbol = propertySymbol }
|
||||
@@ -1116,11 +1116,11 @@ private class FakeOverrideBuilderForLowerings : FakeOverrideBuilderStrategy(empt
|
||||
|
||||
declaration.getter?.let {
|
||||
it.correspondingPropertySymbol = declaration.symbol
|
||||
linkFunctionFakeOverride(it as? IrFakeOverrideFunction ?: error("Unexpected fake override getter: $it"), compatibilityMode)
|
||||
linkFunctionFakeOverride(it as? IrFunctionWithLateBinding ?: error("Unexpected fake override getter: $it"), compatibilityMode)
|
||||
}
|
||||
declaration.setter?.let {
|
||||
it.correspondingPropertySymbol = declaration.symbol
|
||||
linkFunctionFakeOverride(it as? IrFakeOverrideFunction ?: error("Unexpected fake override setter: $it"), compatibilityMode)
|
||||
linkFunctionFakeOverride(it as? IrFunctionWithLateBinding ?: error("Unexpected fake override setter: $it"), compatibilityMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ object IrTree : AbstractTreeBuilder() {
|
||||
baseGetter = code("error(\"Should never be called\")")
|
||||
}
|
||||
}
|
||||
val fakeOverrideFunction: ElementConfig by element(Declaration) {
|
||||
val functionWithLateBinding: ElementConfig by element(Declaration) {
|
||||
typeKind = TypeKind.Interface
|
||||
|
||||
parent(declaration)
|
||||
@@ -291,7 +291,7 @@ object IrTree : AbstractTreeBuilder() {
|
||||
)
|
||||
}
|
||||
}
|
||||
val fakeOverrideProperty: ElementConfig by element(Declaration) {
|
||||
val propertyWithLateBinding: ElementConfig by element(Declaration) {
|
||||
typeKind = TypeKind.Interface
|
||||
|
||||
parent(declaration)
|
||||
|
||||
+6
-6
@@ -112,12 +112,12 @@ class FakeOverrideBuilder(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun linkFunctionFakeOverride(declaration: IrFakeOverrideFunction, compatibilityMode: Boolean) {
|
||||
override fun linkFunctionFakeOverride(declaration: IrFunctionWithLateBinding, compatibilityMode: Boolean) {
|
||||
val signature = composeSignature(declaration, compatibilityMode)
|
||||
declareFunctionFakeOverride(declaration, signature)
|
||||
}
|
||||
|
||||
override fun linkPropertyFakeOverride(declaration: IrFakeOverrideProperty, compatibilityMode: Boolean) {
|
||||
override fun linkPropertyFakeOverride(declaration: IrPropertyWithLateBinding, compatibilityMode: Boolean) {
|
||||
// To compute a signature for a property with type parameters,
|
||||
// we must have its accessor's correspondingProperty pointing to the property's symbol.
|
||||
// See IrMangleComputer.mangleTypeParameterReference() for details.
|
||||
@@ -139,18 +139,18 @@ class FakeOverrideBuilder(
|
||||
|
||||
declaration.getter?.let {
|
||||
it.correspondingPropertySymbol = declaration.symbol
|
||||
linkFunctionFakeOverride(it as? IrFakeOverrideFunction ?: error("Unexpected fake override getter: $it"), compatibilityMode)
|
||||
linkFunctionFakeOverride(it as? IrFunctionWithLateBinding ?: error("Unexpected fake override getter: $it"), compatibilityMode)
|
||||
}
|
||||
declaration.setter?.let {
|
||||
it.correspondingPropertySymbol = declaration.symbol
|
||||
linkFunctionFakeOverride(it as? IrFakeOverrideFunction ?: error("Unexpected fake override setter: $it"), compatibilityMode)
|
||||
linkFunctionFakeOverride(it as? IrFunctionWithLateBinding ?: error("Unexpected fake override setter: $it"), compatibilityMode)
|
||||
}
|
||||
}
|
||||
|
||||
private fun composeSignature(declaration: IrDeclaration, compatibleMode: Boolean) =
|
||||
fakeOverrideDeclarationTable.signaturer.composeSignatureForDeclaration(declaration, compatibleMode)
|
||||
|
||||
private fun declareFunctionFakeOverride(declaration: IrFakeOverrideFunction, signature: IdSignature) {
|
||||
private fun declareFunctionFakeOverride(declaration: IrFunctionWithLateBinding, signature: IdSignature) {
|
||||
val parent = declaration.parentAsClass
|
||||
val symbol = linker.tryReferencingSimpleFunctionByLocalSignature(parent, signature)
|
||||
?: symbolTable.referenceSimpleFunction(signature, false)
|
||||
@@ -160,7 +160,7 @@ class FakeOverrideBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
private fun declarePropertyFakeOverride(declaration: IrFakeOverrideProperty, signature: IdSignature) {
|
||||
private fun declarePropertyFakeOverride(declaration: IrPropertyWithLateBinding, signature: IdSignature) {
|
||||
val parent = declaration.parentAsClass
|
||||
val symbol = linker.tryReferencingPropertyByLocalSignature(parent, signature)
|
||||
?: symbolTable.referenceProperty(signature, false)
|
||||
|
||||
Reference in New Issue
Block a user