IR: make IrDeclarationWithVisibility.visibility mutable
It was mutable anyway in many subclasses. This is needed in order to avoid depending on concrete IR implementations in the JVM IR backend where it's necessary to be able to change visibility.
This commit is contained in:
@@ -72,8 +72,11 @@ class Fir2IrLazySimpleFunction(
|
||||
override val name: Name
|
||||
get() = fir.name
|
||||
|
||||
override val visibility: Visibility
|
||||
override var visibility: Visibility
|
||||
get() = fir.visibility
|
||||
set(_) {
|
||||
error("Mutating Fir2Ir lazy elements is not possible")
|
||||
}
|
||||
|
||||
override val modality: Modality
|
||||
get() = fir.modality!!
|
||||
|
||||
+1
-2
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.ir.builders.irReturn
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
@@ -97,7 +96,7 @@ private class ToArrayLowering(private val context: JvmBackendContext) : ClassLow
|
||||
}
|
||||
|
||||
private fun IrClass.findOrCreate(indirectSubclass: Boolean, matcher: (IrSimpleFunction) -> Boolean, fallback: () -> IrSimpleFunction) {
|
||||
val existing = functions.find(matcher) as? IrFunctionImpl
|
||||
val existing = functions.find(matcher)
|
||||
if (existing != null) {
|
||||
// This is an explicit override of a method defined in `kotlin.collections.AbstractCollection`
|
||||
// or `java.util.Collection`. From here on, the frontend will check the existence of implementations;
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -28,8 +31,6 @@ interface IrClass :
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ClassDescriptor
|
||||
|
||||
override var visibility: Visibility
|
||||
|
||||
val kind: ClassKind
|
||||
var modality: Modality
|
||||
val isCompanion: Boolean
|
||||
@@ -54,16 +55,3 @@ fun IrClass.addMember(member: IrDeclaration) {
|
||||
fun IrClass.addAll(members: List<IrDeclaration>) {
|
||||
declarations.addAll(members)
|
||||
}
|
||||
|
||||
fun IrClass.getInstanceInitializerMembers() =
|
||||
declarations.filter {
|
||||
when (it) {
|
||||
is IrAnonymousInitializer ->
|
||||
true
|
||||
is IrProperty ->
|
||||
it.backingField?.initializer != null
|
||||
is IrField ->
|
||||
it.initializer != null
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,12 @@
|
||||
package org.jetbrains.kotlin.ir.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
|
||||
|
||||
interface IrConstructor : IrFunction, IrSymbolDeclaration<IrConstructorSymbol> {
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ClassConstructorDescriptor
|
||||
|
||||
override var visibility: Visibility
|
||||
|
||||
val isPrimary: Boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ interface IrOverridableDeclaration<S : IrSymbol> : IrDeclaration {
|
||||
}
|
||||
|
||||
interface IrDeclarationWithVisibility : IrDeclaration {
|
||||
val visibility: Visibility
|
||||
var visibility: Visibility
|
||||
}
|
||||
|
||||
interface IrDeclarationWithName : IrDeclaration {
|
||||
|
||||
@@ -38,7 +38,7 @@ class IrFieldImpl(
|
||||
override val symbol: IrFieldSymbol,
|
||||
override val name: Name,
|
||||
override val type: IrType,
|
||||
override val visibility: Visibility,
|
||||
override var visibility: Visibility,
|
||||
override val isFinal: Boolean,
|
||||
override val isExternal: Boolean,
|
||||
override val isStatic: Boolean
|
||||
|
||||
@@ -33,7 +33,7 @@ abstract class IrPropertyCommonImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val name: Name,
|
||||
override val visibility: Visibility,
|
||||
override var visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
override val isVar: Boolean,
|
||||
override val isConst: Boolean,
|
||||
@@ -113,7 +113,7 @@ class IrPropertyImpl(
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrPropertySymbol,
|
||||
override val name: Name,
|
||||
override val visibility: Visibility,
|
||||
override var visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
override val isVar: Boolean,
|
||||
override val isConst: Boolean,
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class IrTypeAliasImpl(
|
||||
endOffset: Int,
|
||||
override val symbol: IrTypeAliasSymbol,
|
||||
override val name: Name,
|
||||
override val visibility: Visibility,
|
||||
override var visibility: Visibility,
|
||||
override val expandedType: IrType,
|
||||
override val isActual: Boolean,
|
||||
origin: IrDeclarationOrigin
|
||||
|
||||
@@ -32,7 +32,7 @@ class IrLazyField(
|
||||
override val symbol: IrFieldSymbol,
|
||||
override val descriptor: PropertyDescriptor,
|
||||
override val name: Name,
|
||||
override val visibility: Visibility,
|
||||
override var visibility: Visibility,
|
||||
override val isFinal: Boolean,
|
||||
override val isExternal: Boolean,
|
||||
override val isStatic: Boolean,
|
||||
|
||||
@@ -27,7 +27,7 @@ class IrLazyProperty(
|
||||
override val symbol: IrPropertySymbol,
|
||||
override val descriptor: PropertyDescriptor,
|
||||
override val name: Name,
|
||||
override val visibility: Visibility,
|
||||
override var visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
override val isVar: Boolean,
|
||||
override val isConst: Boolean,
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class IrLazyTypeAlias(
|
||||
override val symbol: IrTypeAliasSymbol,
|
||||
override val descriptor: TypeAliasDescriptor,
|
||||
override val name: Name,
|
||||
override val visibility: Visibility,
|
||||
override var visibility: Visibility,
|
||||
override val isActual: Boolean,
|
||||
stubGenerator: DeclarationStubGenerator,
|
||||
typeTranslator: TypeTranslator
|
||||
|
||||
Reference in New Issue
Block a user