[IR] Mark utilities, which use IrDeclarationContainer.declarations with @IrSymbolInternals
Only those utilities are marked because only them are accessible in fir2ir. And in other modules it's allowed to access .declarations from anywhere
This commit is contained in:
committed by
Space Team
parent
78a705a1bc
commit
38a7f2bc07
@@ -185,6 +185,8 @@ val IrDeclaration.fileEntry: IrFileEntry
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
fun IrClass.companionObject(): IrClass? =
|
fun IrClass.companionObject(): IrClass? =
|
||||||
this.declarations.singleOrNull { it is IrClass && it.isCompanion } as IrClass?
|
this.declarations.singleOrNull { it is IrClass && it.isCompanion } as IrClass?
|
||||||
|
|
||||||
@@ -282,6 +284,8 @@ class NaiveSourceBasedFileEntryImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
private fun IrClass.getPropertyDeclaration(name: String): IrProperty? {
|
private fun IrClass.getPropertyDeclaration(name: String): IrProperty? {
|
||||||
val properties = declarations.filterIsInstanceAnd<IrProperty> { it.name.asString() == name }
|
val properties = declarations.filterIsInstanceAnd<IrProperty> { it.name.asString() == name }
|
||||||
if (properties.size > 1) {
|
if (properties.size > 1) {
|
||||||
@@ -296,10 +300,14 @@ private fun IrClass.getPropertyDeclaration(name: String): IrProperty? {
|
|||||||
fun IrClass.getSimpleFunction(name: String): IrSimpleFunctionSymbol? =
|
fun IrClass.getSimpleFunction(name: String): IrSimpleFunctionSymbol? =
|
||||||
findDeclaration<IrSimpleFunction> { it.name.asString() == name }?.symbol
|
findDeclaration<IrSimpleFunction> { it.name.asString() == name }?.symbol
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
fun IrClass.getPropertyGetter(name: String): IrSimpleFunctionSymbol? =
|
fun IrClass.getPropertyGetter(name: String): IrSimpleFunctionSymbol? =
|
||||||
getPropertyDeclaration(name)?.getter?.symbol
|
getPropertyDeclaration(name)?.getter?.symbol
|
||||||
?: getSimpleFunction("<get-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
?: getSimpleFunction("<get-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
fun IrClass.getPropertySetter(name: String): IrSimpleFunctionSymbol? =
|
fun IrClass.getPropertySetter(name: String): IrSimpleFunctionSymbol? =
|
||||||
getPropertyDeclaration(name)?.setter?.symbol
|
getPropertyDeclaration(name)?.setter?.symbol
|
||||||
?: getSimpleFunction("<set-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
?: getSimpleFunction("<set-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
||||||
|
|||||||
@@ -225,39 +225,61 @@ val IrProperty.isSimpleProperty: Boolean
|
|||||||
(setterFun == null || setterFun.origin == IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR)
|
(setterFun == null || setterFun.origin == IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClass.functions: Sequence<IrSimpleFunction>
|
val IrClass.functions: Sequence<IrSimpleFunction>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrSimpleFunction>()
|
get() = declarations.asSequence().filterIsInstance<IrSimpleFunction>()
|
||||||
|
|
||||||
|
// This declaration accesses IrBasedSymbol.owner, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClass.superClass: IrClass?
|
val IrClass.superClass: IrClass?
|
||||||
get() = superTypes
|
get() = superTypes
|
||||||
.firstOrNull { !it.isInterface() && !it.isAny() }
|
.firstOrNull { !it.isInterface() && !it.isAny() }
|
||||||
?.classOrNull
|
?.classOrNull
|
||||||
?.owner
|
?.owner
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClassSymbol.functions: Sequence<IrSimpleFunctionSymbol>
|
val IrClassSymbol.functions: Sequence<IrSimpleFunctionSymbol>
|
||||||
get() = owner.functions.map { it.symbol }
|
get() = owner.functions.map { it.symbol }
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClass.constructors: Sequence<IrConstructor>
|
val IrClass.constructors: Sequence<IrConstructor>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrConstructor>()
|
get() = declarations.asSequence().filterIsInstance<IrConstructor>()
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClass.defaultConstructor: IrConstructor?
|
val IrClass.defaultConstructor: IrConstructor?
|
||||||
get() = constructors.firstOrNull { ctor -> ctor.valueParameters.all { it.defaultValue != null } }
|
get() = constructors.firstOrNull { ctor -> ctor.valueParameters.all { it.defaultValue != null } }
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClassSymbol.constructors: Sequence<IrConstructorSymbol>
|
val IrClassSymbol.constructors: Sequence<IrConstructorSymbol>
|
||||||
get() = owner.constructors.map { it.symbol }
|
get() = owner.constructors.map { it.symbol }
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClass.fields: Sequence<IrField>
|
val IrClass.fields: Sequence<IrField>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrField>()
|
get() = declarations.asSequence().filterIsInstance<IrField>()
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClassSymbol.fields: Sequence<IrFieldSymbol>
|
val IrClassSymbol.fields: Sequence<IrFieldSymbol>
|
||||||
get() = owner.fields.map { it.symbol }
|
get() = owner.fields.map { it.symbol }
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClass.primaryConstructor: IrConstructor?
|
val IrClass.primaryConstructor: IrConstructor?
|
||||||
get() = this.declarations.singleOrNull { it is IrConstructor && it.isPrimary } as IrConstructor?
|
get() = this.declarations.singleOrNull { it is IrConstructor && it.isPrimary } as IrConstructor?
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrClass.invokeFun: IrSimpleFunction?
|
val IrClass.invokeFun: IrSimpleFunction?
|
||||||
get() = declarations.filterIsInstance<IrSimpleFunction>().singleOrNull { it.name.asString() == "invoke" }
|
get() = declarations.filterIsInstance<IrSimpleFunction>().singleOrNull { it.name.asString() == "invoke" }
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
val IrDeclarationContainer.properties: Sequence<IrProperty>
|
val IrDeclarationContainer.properties: Sequence<IrProperty>
|
||||||
get() = declarations.asSequence().filterIsInstance<IrProperty>()
|
get() = declarations.asSequence().filterIsInstance<IrProperty>()
|
||||||
|
|
||||||
@@ -447,6 +469,8 @@ fun IrFunction.isExternalOrInheritedFromExternal(): Boolean {
|
|||||||
return isEffectivelyExternal() || (this is IrSimpleFunction && isExternalOrInheritedFromExternalImpl(this))
|
return isEffectivelyExternal() || (this is IrSimpleFunction && isExternalOrInheritedFromExternalImpl(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
inline fun <reified T : IrDeclaration> IrDeclarationContainer.findDeclaration(predicate: (T) -> Boolean): T? =
|
inline fun <reified T : IrDeclaration> IrDeclarationContainer.findDeclaration(predicate: (T) -> Boolean): T? =
|
||||||
declarations.find { it is T && predicate(it) } as? T
|
declarations.find { it is T && predicate(it) } as? T
|
||||||
|
|
||||||
@@ -1169,6 +1193,8 @@ fun IrFunction.isMethodOfAny(): Boolean =
|
|||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This declaration accesses IrDeclarationContainer.declarations, which is marked with this opt-in
|
||||||
|
@IrSymbolInternals
|
||||||
fun IrDeclarationContainer.simpleFunctions() = declarations.flatMap {
|
fun IrDeclarationContainer.simpleFunctions() = declarations.flatMap {
|
||||||
when (it) {
|
when (it) {
|
||||||
is IrSimpleFunction -> listOf(it)
|
is IrSimpleFunction -> listOf(it)
|
||||||
|
|||||||
Reference in New Issue
Block a user