IR: do not inherit IrFakeOverride* from IrFunction/IrProperty
This will help to reduce boilerplate after making the latter classes. Without this change, IrFunctionCommonImpl would not be able to be a class because it would introduce a diamond class hierarchy, and thus that would require copying all its contents to IrFunctionImpl and IrFakeOverrideFunctionImpl.
This commit is contained in:
+1
-1
@@ -185,7 +185,7 @@ object IrFactoryImpl : IrFactory {
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrFakeOverrideProperty =
|
||||
): IrProperty =
|
||||
IrFakeOverridePropertyImpl(
|
||||
startOffset, endOffset, origin, name, visibility, modality,
|
||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
|
||||
+2
-1
@@ -104,10 +104,11 @@ class IrFakeOverrideFunctionImpl(
|
||||
get() = _symbol?.descriptor ?: WrappedSimpleFunctionDescriptor()
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
override fun acquireSymbol(symbol: IrSimpleFunctionSymbol) {
|
||||
override fun acquireSymbol(symbol: IrSimpleFunctionSymbol): IrSimpleFunction {
|
||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||
_symbol = symbol
|
||||
symbol.bind(this)
|
||||
(symbol.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -103,10 +103,11 @@ class IrFakeOverridePropertyImpl(
|
||||
get() = _symbol?.descriptor ?: WrappedPropertyDescriptor()
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
override fun acquireSymbol(symbol: IrPropertySymbol) {
|
||||
override fun acquireSymbol(symbol: IrPropertySymbol): IrProperty {
|
||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||
_symbol = symbol
|
||||
symbol.bind(this)
|
||||
(symbol.descriptor as? WrappedPropertyDescriptor)?.bind(this)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ object PersistentIrFactory : IrFactory {
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrFakeOverrideProperty =
|
||||
): IrProperty =
|
||||
PersistentIrFakeOverrideProperty(
|
||||
startOffset, endOffset, origin, name, visibility, modality,
|
||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
|
||||
|
||||
+2
-1
@@ -133,10 +133,11 @@ internal class PersistentIrFakeOverrideFunction(
|
||||
get() = _symbol?.descriptor ?: WrappedSimpleFunctionDescriptor()
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
override fun acquireSymbol(symbol: IrSimpleFunctionSymbol) {
|
||||
override fun acquireSymbol(symbol: IrSimpleFunctionSymbol): IrSimpleFunction {
|
||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||
_symbol = symbol
|
||||
symbol.bind(this)
|
||||
(symbol.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -140,10 +140,11 @@ internal class PersistentIrFakeOverrideProperty(
|
||||
get() = _symbol?.descriptor ?: WrappedPropertyDescriptor()
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
override fun acquireSymbol(symbol: IrPropertySymbol) {
|
||||
override fun acquireSymbol(symbol: IrPropertySymbol): IrProperty {
|
||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||
_symbol = symbol
|
||||
symbol.bind(this)
|
||||
(symbol.descriptor as? WrappedPropertyDescriptor)?.bind(this)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ interface IrFactory {
|
||||
isDelegated: Boolean,
|
||||
isExternal: Boolean,
|
||||
isExpect: Boolean,
|
||||
): IrFakeOverrideProperty
|
||||
): IrProperty
|
||||
|
||||
fun createTypeAlias(
|
||||
startOffset: Int,
|
||||
|
||||
+3
-3
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.ir.declarations
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
|
||||
interface IrFakeOverrideFunction : IrSimpleFunction {
|
||||
override var modality: Modality
|
||||
interface IrFakeOverrideFunction : IrSymbolDeclaration<IrSimpleFunctionSymbol> {
|
||||
var modality: Modality
|
||||
|
||||
fun acquireSymbol(symbol: IrSimpleFunctionSymbol)
|
||||
fun acquireSymbol(symbol: IrSimpleFunctionSymbol): IrSimpleFunction
|
||||
}
|
||||
|
||||
+5
-3
@@ -8,8 +8,10 @@ package org.jetbrains.kotlin.ir.declarations
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
|
||||
interface IrFakeOverrideProperty : IrProperty {
|
||||
override var modality: Modality
|
||||
interface IrFakeOverrideProperty : IrSymbolDeclaration<IrPropertySymbol> {
|
||||
var modality: Modality
|
||||
var getter: IrSimpleFunction?
|
||||
var setter: IrSimpleFunction?
|
||||
|
||||
fun acquireSymbol(symbol: IrPropertySymbol)
|
||||
fun acquireSymbol(symbol: IrPropertySymbol): IrProperty
|
||||
}
|
||||
|
||||
+1
-7
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.backend.common.overrides
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
|
||||
@@ -31,9 +30,6 @@ import org.jetbrains.kotlin.ir.types.IrTypeProjection
|
||||
import org.jetbrains.kotlin.ir.types.extractTypeParameters
|
||||
import org.jetbrains.kotlin.ir.types.getClass
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
interface PlatformFakeOverrideClassFilter {
|
||||
@@ -124,7 +120,6 @@ class FakeOverrideBuilder(
|
||||
|
||||
symbolTable.declareSimpleFunctionFromLinker(WrappedSimpleFunctionDescriptor(), signature) {
|
||||
declaration.acquireSymbol(it)
|
||||
declaration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +131,7 @@ class FakeOverrideBuilder(
|
||||
// To break this loop we use temp symbol in correspondingProperty.
|
||||
|
||||
val tempSymbol = IrPropertySymbolImpl(WrappedPropertyDescriptor()).also {
|
||||
it.bind(declaration)
|
||||
it.bind(declaration as IrProperty)
|
||||
}
|
||||
declaration.getter?.let {
|
||||
it.correspondingPropertySymbol = tempSymbol
|
||||
@@ -149,7 +144,6 @@ class FakeOverrideBuilder(
|
||||
|
||||
symbolTable.declarePropertyFromLinker(WrappedPropertyDescriptor(), signature) {
|
||||
declaration.acquireSymbol(it)
|
||||
declaration
|
||||
}
|
||||
|
||||
declaration.getter?.let {
|
||||
|
||||
Reference in New Issue
Block a user