IR: symbol -> target in IrDeclarationReference, working only in JVM for now
diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt
index 1eadd8f..c675ed2 100644
--- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt
+++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt
@@ -27,7 +27,6 @@
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
-import org.jetbrains.kotlin.fir.visitors.FirVisitor
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.builders.*
@@ -355,7 +354,7 @@
if (firOverriddenSymbol != null && this is IrSimpleFunction && firFunctionSymbol != null) {
val overriddenSymbol = declarationStorage.getIrFunctionSymbol(firOverriddenSymbol)
if (overriddenSymbol is IrSimpleFunctionSymbol) {
- overriddenSymbols += overriddenSymbol
+ overridden += overriddenSymbol
}
}
body = firFunction?.body?.convertToIrBlockBody()
@@ -547,7 +546,7 @@
if (firOverriddenSymbol != null && backingField != null) {
val overriddenSymbol = declarationStorage.getIrPropertyOrFieldSymbol(firOverriddenSymbol.fir.backingFieldSymbol)
if (overriddenSymbol is IrFieldSymbol) {
- backingField.overriddenSymbols += overriddenSymbol
+ backingField.overridden += overriddenSymbol
}
}
}
@@ -556,14 +555,14 @@
property.getter, this, propertyType, property.getter is FirDefaultPropertyGetter, property.getter == null
)
getter?.apply {
- overriddenProperty?.owner?.getter?.symbol?.let { overriddenSymbols += it }
+ overriddenProperty?.owner?.getter?.symbol?.let { overridden += it }
}
if (property.isVar) {
setter?.setPropertyAccessorContent(
property.setter, this, propertyType, property.setter is FirDefaultPropertySetter, property.setter == null
)
setter?.apply {
- overriddenProperty?.owner?.setter?.symbol?.let { overriddenSymbols += it }
+ overriddenProperty?.owner?.setter?.symbol?.let { overridden += it }
}
}
property.annotations.forEach {
@@ -739,7 +738,7 @@
}
}
} else {
- val name = if (this is IrCallImpl) symbol.owner.name else "???"
+ val name = if (this is IrCallImpl) target.name else "???"
IrErrorCallExpressionImpl(
startOffset, endOffset, type,
"Cannot bind $argumentsCount arguments to $name call with $valueArgumentsCount parameters"
@@ -762,14 +761,13 @@
private fun IrExpression.applyReceivers(qualifiedAccess: FirQualifiedAccess): IrExpression {
return when (this) {
is IrCallImpl -> {
- val ownerFunction = symbol.owner
- if (ownerFunction.dispatchReceiverParameter != null) {
+ if (target.dispatchReceiverParameter != null) {
dispatchReceiver = qualifiedAccess.dispatchReceiver.takeIf { it !is FirNoReceiverExpression }?.toIrExpression()
?: qualifiedAccess.explicitReceiver?.toIrExpression() // NB: this applies to the situation when call is unresolved
if (dispatchReceiver == null) {
throw AssertionError()
}
- } else if (ownerFunction.extensionReceiverParameter != null) {
+ } else if (target.extensionReceiverParameter != null) {
extensionReceiver = qualifiedAccess.extensionReceiver.takeIf { it !is FirNoReceiverExpression }?.toIrExpression()
?: qualifiedAccess.explicitReceiver?.toIrExpression()
if (extensionReceiver == null) {
@@ -779,8 +777,7 @@
this
}
is IrFieldExpressionBase -> {
- val ownerField = symbol.owner
- if (!ownerField.isStatic) {
+ if (!target.isStatic) {
receiver = qualifiedAccess.dispatchReceiver.takeIf { it !is FirNoReceiverExpression }?.toIrExpression()
?: qualifiedAccess.explicitReceiver?.toIrExpression()
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CheckIrElementVisitor.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CheckIrElementVisitor.kt
index 0611257..0ec103e 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CheckIrElementVisitor.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CheckIrElementVisitor.kt
@@ -25,7 +25,6 @@
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.*
-import org.jetbrains.kotlin.ir.types.defaultType
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
@@ -63,7 +62,8 @@
ensureTypesEqual(type, expectedType)
}
- private fun IrSymbol.ensureBound(expression: IrExpression) {
+ private fun IrSymbolOwner.ensureBound(expression: IrExpression) {
+ if (this !is IrSymbol) return
if (!this.isBound && expression.type !is IrDynamicType) {
reportError(expression, "Unbound symbol ${this}")
}
@@ -102,7 +102,7 @@
override fun visitGetObjectValue(expression: IrGetObjectValue) {
super.visitGetObjectValue(expression)
- expression.ensureTypeIs(expression.symbol.createType(false, emptyList()))
+ expression.ensureTypeIs(expression.target.createType(false, emptyList()))
}
// TODO: visitGetEnumValue
@@ -110,7 +110,7 @@
override fun visitGetValue(expression: IrGetValue) {
super.visitGetValue(expression)
- expression.ensureTypeIs(expression.symbol.owner.type)
+ expression.ensureTypeIs(expression.target.type)
}
override fun visitSetVariable(expression: IrSetVariable) {
@@ -122,7 +122,7 @@
override fun visitGetField(expression: IrGetField) {
super.visitGetField(expression)
- val fieldType = expression.symbol.owner.type
+ val fieldType = expression.target.type
// TODO: We don't have the proper type substitution yet, so skip generics for now.
if (fieldType is IrSimpleType &&
fieldType.classifier is IrClassSymbol &&
@@ -141,14 +141,14 @@
override fun visitCall(expression: IrCall) {
super.visitCall(expression)
- val function = expression.symbol.owner
+ val function = expression.target
if (function.dispatchReceiverParameter?.type is IrDynamicType) {
reportError(expression, "Dispatch receivers with 'dynamic' type are not allowed")
}
// TODO: Why don't we check parameters as well?
- val returnType = expression.symbol.owner.returnType
+ val returnType = expression.target.returnType
// TODO: We don't have the proper type substitution yet, so skip generics for now.
if (returnType is IrSimpleType &&
returnType.classifier is IrClassSymbol &&
@@ -158,7 +158,7 @@
expression.ensureTypeIs(returnType)
}
- expression.superQualifierSymbol?.ensureBound(expression)
+ expression.irSuperQualifier?.ensureBound(expression)
}
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall) {
@@ -177,7 +177,7 @@
super.visitInstanceInitializerCall(expression)
expression.ensureTypeIs(irBuiltIns.unitType)
- expression.classSymbol.ensureBound(expression)
+ expression.irClass.ensureBound(expression)
}
override fun visitTypeOperator(expression: IrTypeOperatorCall) {
@@ -228,7 +228,7 @@
super.visitReturn(expression)
expression.ensureTypeIs(irBuiltIns.nothingType)
- expression.returnTargetSymbol.ensureBound(expression)
+ expression.irReturnTarget.ensureBound(expression)
}
override fun visitThrow(expression: IrThrow) {
@@ -294,15 +294,15 @@
return
}
- expression.symbol.ensureBound(expression)
+ expression.target.ensureBound(expression)
}
override fun visitDeclaration(declaration: IrDeclaration) {
super.visitDeclaration(declaration)
if (declaration is IrOverridableDeclaration<*>) {
- for (overriddenSymbol in declaration.overriddenSymbols) {
- val overriddenDeclaration = overriddenSymbol.owner as? IrDeclarationWithVisibility ?: continue
+ for (overridden in declaration.overridden) {
+ val overriddenDeclaration = overridden as? IrDeclarationWithVisibility ?: continue
if (overriddenDeclaration.visibility == Visibilities.PRIVATE) {
reportError(declaration, "Overrides private declaration $overriddenDeclaration")
}
@@ -313,13 +313,13 @@
override fun visitFunctionAccess(expression: IrFunctionAccessExpression) {
super.visitFunctionAccess(expression)
- expression.symbol.ensureBound(expression)
+ expression.target.ensureBound(expression)
}
override fun visitFunctionReference(expression: IrFunctionReference) {
super.visitFunctionReference(expression)
- expression.symbol.ensureBound(expression)
+ expression.target.ensureBound(expression)
}
override fun visitPropertyReference(expression: IrPropertyReference) {
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/DeepCopyIrTreeWithDeclarations.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/DeepCopyIrTreeWithDeclarations.kt
index aa5e680..a56a935 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/DeepCopyIrTreeWithDeclarations.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/DeepCopyIrTreeWithDeclarations.kt
@@ -22,10 +22,7 @@
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrLoop
-import org.jetbrains.kotlin.ir.util.DeepCopyIrTreeWithSymbols
-import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper
-import org.jetbrains.kotlin.ir.util.DeepCopyTypeRemapper
-import org.jetbrains.kotlin.ir.util.DescriptorsRemapper
+import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.acceptVoid
@Suppress("UNCHECKED_CAST")
@@ -52,5 +49,5 @@
}
},
null
- ) as T
+ ).desymbolize() as T
}
\ No newline at end of file
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/IrElementTransformerVoidWithContext.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/IrElementTransformerVoidWithContext.kt
index ad511d1..7021e5e 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/IrElementTransformerVoidWithContext.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/IrElementTransformerVoidWithContext.kt
@@ -20,10 +20,6 @@
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.builders.Scope
import org.jetbrains.kotlin.ir.declarations.*
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
@@ -34,7 +30,7 @@
private val scopeStack = mutableListOf<ScopeWithIr>()
protected open fun createScope(declaration: IrSymbolOwner): ScopeWithIr =
- ScopeWithIr(Scope(declaration.symbol), declaration)
+ ScopeWithIr(Scope(declaration), declaration)
final override fun visitFile(declaration: IrFile): IrFile {
scopeStack.push(createScope(declaration))
@@ -72,9 +68,9 @@
}
protected val currentFile get() = scopeStack.lastOrNull { it.irElement is IrFile }!!.irElement as IrFile
- protected val currentClass get() = scopeStack.lastOrNull { it.scope.scopeOwnerSymbol is IrClassSymbol }
- protected val currentFunction get() = scopeStack.lastOrNull { it.scope.scopeOwnerSymbol is IrFunctionSymbol }
- protected val currentProperty get() = scopeStack.lastOrNull { it.scope.scopeOwnerSymbol is IrPropertySymbol }
+ protected val currentClass get() = scopeStack.lastOrNull { it.scope.irScopeOwner is IrClass }
+ protected val currentFunction get() = scopeStack.lastOrNull { it.scope.irScopeOwner is IrFunction }
+ protected val currentProperty get() = scopeStack.lastOrNull { it.scope.irScopeOwner is IrProperty }
protected val currentScope get() = scopeStack.peek()
protected val parentScope get() = if (scopeStack.size < 2) null else scopeStack[scopeStack.size - 2]
protected val allScopes get() = scopeStack
@@ -109,7 +105,7 @@
private val scopeStack = mutableListOf<ScopeWithIr>()
protected open fun createScope(declaration: IrSymbolOwner): ScopeWithIr =
- ScopeWithIr(Scope(declaration.symbol), declaration)
+ ScopeWithIr(Scope(declaration), declaration)
final override fun visitFile(declaration: IrFile) {
scopeStack.push(createScope(declaration))
@@ -142,10 +138,10 @@
scopeStack.pop()
}
- protected val currentFile get() = scopeStack.lastOrNull { it.scope.scopeOwnerSymbol is IrFileSymbol }
- protected val currentClass get() = scopeStack.lastOrNull { it.scope.scopeOwnerSymbol is IrClassSymbol }
- protected val currentFunction get() = scopeStack.lastOrNull { it.scope.scopeOwnerSymbol is IrFunctionSymbol }
- protected val currentProperty get() = scopeStack.lastOrNull { it.scope.scopeOwnerSymbol is IrPropertySymbol }
+ protected val currentFile get() = scopeStack.lastOrNull { it.scope.irScopeOwner is IrFile }
+ protected val currentClass get() = scopeStack.lastOrNull { it.scope.irScopeOwner is IrClass }
+ protected val currentFunction get() = scopeStack.lastOrNull { it.scope.irScopeOwner is IrFunction }
+ protected val currentProperty get() = scopeStack.lastOrNull { it.scope.irScopeOwner is IrProperty }
protected val currentScope get() = scopeStack.peek()
protected val parentScope get() = if (scopeStack.size < 2) null else scopeStack[scopeStack.size - 2]
protected val allScopes get() = scopeStack
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/TailRecursionCallsCollector.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/TailRecursionCallsCollector.kt
index fa19575..a5fb6cc 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/TailRecursionCallsCollector.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/TailRecursionCallsCollector.kt
@@ -62,7 +62,7 @@
}
override fun visitReturn(expression: IrReturn, data: ElementKind) {
- val valueKind = if (expression.returnTargetSymbol == irFunction.symbol) {
+ val valueKind = if (expression.irReturnTarget == irFunction) {
ElementKind.TAIL_STATEMENT
} else {
ElementKind.NOT_SURE
@@ -98,18 +98,18 @@
}
// Is it a recursive call?
- if (expression.symbol != irFunction.symbol) {
+ if (expression.target != irFunction) {
return
}
// TODO: check type arguments
- if (irFunction.overriddenSymbols.isNotEmpty() && expression.usesDefaultArguments()) {
+ if (irFunction.overridden.isNotEmpty() && expression.usesDefaultArguments()) {
// Overridden functions using default arguments at tail call are not included: KT-4285
return
}
expression.dispatchReceiver?.let {
- if (it !is IrGetValue || it.symbol.owner != irFunction.dispatchReceiverParameter) {
+ if (it !is IrGetValue || it.target != irFunction.dispatchReceiverParameter) {
// A tail call is not allowed to change dispatch receiver
// class C {
// fun foo(other: C) {
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/descriptors/WrappedDescriptors.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/descriptors/WrappedDescriptors.kt
index 7e9dd1e..b6f6e4e 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/descriptors/WrappedDescriptors.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/descriptors/WrappedDescriptors.kt
@@ -46,12 +46,12 @@
}
private fun IrConstructorCall.toAnnotationDescriptor(): AnnotationDescriptor {
- assert(symbol.owner.parentAsClass.isAnnotationClass) {
+ assert(target.parentAsClass.isAnnotationClass) {
"Expected call to constructor of annotation class but was: ${this.dump()}"
}
return AnnotationDescriptorImpl(
- symbol.owner.parentAsClass.defaultType.toKotlinType(),
- symbol.owner.valueParameters.map { it.name to getValueArgument(it.index) }
+ target.parentAsClass.defaultType.toKotlinType(),
+ target.valueParameters.map { it.name to getValueArgument(it.index) }
.filter { it.second != null }
.associate { it.first to it.second!!.toConstantValue() },
/*TODO*/ SourceElement.NO_SOURCE
@@ -81,7 +81,7 @@
}
}
- this is IrGetEnumValue -> EnumValue(symbol.owner.parentAsClass.descriptor.classId!!, symbol.owner.name)
+ this is IrGetEnumValue -> EnumValue(target.parentAsClass.descriptor.classId!!, target.name)
this is IrClassReference -> KClassValue(classType.classifierOrFail.descriptor.classId!!, /*TODO*/0)
@@ -381,7 +381,7 @@
var originalDescriptor: FunctionDescriptor? = null
- override fun getOverriddenDescriptors() = owner.overriddenSymbols.map { it.descriptor }
+ override fun getOverriddenDescriptors() = owner.overridden.map { it.descriptor }
override fun getContainingDeclaration(): DeclarationDescriptor = getContainingDeclaration(owner)
@@ -965,7 +965,7 @@
override fun hasSynthesizedParameterNames() = false
override fun getOverriddenDescriptors(): MutableCollection<out PropertyDescriptor> =
- owner.overriddenSymbols.map { it.descriptor }.toMutableList()
+ owner.overridden.map { it.descriptor }.toMutableList()
override fun copy(
newOwner: DeclarationDescriptor?,
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt
index 159855a..38cef50 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt
@@ -14,12 +14,7 @@
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
-import org.jetbrains.kotlin.ir.declarations.IrFunction
-import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
-import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
+import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable
@@ -60,16 +55,16 @@
name: Name,
vararg packageNameSegments: String = arrayOf("kotlin"),
condition: (SimpleFunctionDescriptor) -> Boolean
- ): IrSimpleFunctionSymbol =
+ ): IrSimpleFunction =
symbolTable.referenceSimpleFunction(
builtInsPackage(*packageNameSegments).getContributedFunctions(name, NoLookupLocation.FROM_BACKEND)
.first(condition)
- )
+ ).owner
- private fun getClass(name: Name, vararg packageNameSegments: String = arrayOf("kotlin")): IrClassSymbol =
+ private fun getClass(name: Name, vararg packageNameSegments: String = arrayOf("kotlin")): IrClass =
symbolTable.referenceClass(
builtInsPackage(*packageNameSegments).getContributedClassifier(name, NoLookupLocation.FROM_BACKEND) as ClassDescriptor
- )
+ ).owner
/**
* Use this table to reference external dependencies.
@@ -77,15 +72,15 @@
open val externalSymbolTable: ReferenceSymbolTable
get() = symbolTable
- abstract val ThrowNullPointerException: IrFunctionSymbol
- abstract val ThrowNoWhenBranchMatchedException: IrFunctionSymbol
- abstract val ThrowTypeCastException: IrFunctionSymbol
+ abstract val ThrowNullPointerException: IrFunction
+ abstract val ThrowNoWhenBranchMatchedException: IrFunction
+ abstract val ThrowTypeCastException: IrFunction
- abstract val ThrowUninitializedPropertyAccessException: IrSimpleFunctionSymbol
+ abstract val ThrowUninitializedPropertyAccessException: IrSimpleFunction
- abstract val stringBuilder: IrClassSymbol
+ abstract val stringBuilder: IrClass
- abstract val defaultConstructorMarker: IrClassSymbol
+ abstract val defaultConstructorMarker: IrClass
val iterator = getClass(Name.identifier("Iterator"), "kotlin", "collections")
@@ -142,11 +137,11 @@
val array = symbolTable.referenceClass(builtIns.array)
private fun primitiveArrayClass(type: PrimitiveType) =
- symbolTable.referenceClass(builtIns.getPrimitiveArrayClassDescriptor(type))
+ symbolTable.referenceClass(builtIns.getPrimitiveArrayClassDescriptor(type)).owner
private fun unsignedArrayClass(unsignedType: UnsignedType) =
builtIns.builtInsModule.findClassAcrossModuleDependencies(unsignedType.arrayClassId)
- ?.let { symbolTable.referenceClass(it) }
+ ?.let { symbolTable.referenceClass(it).owner }
val byteArray = primitiveArrayClass(PrimitiveType.BYTE)
val charArray = primitiveArrayClass(PrimitiveType.CHAR)
@@ -182,51 +177,51 @@
val mutableIterator = symbolTable.referenceClass(builtIns.mutableIterator)
val mutableListIterator = symbolTable.referenceClass(builtIns.mutableListIterator)
- abstract val copyRangeTo: Map<ClassDescriptor, IrSimpleFunctionSymbol>
+ abstract val copyRangeTo: Map<ClassDescriptor, IrSimpleFunction>
- abstract val coroutineImpl: IrClassSymbol
+ abstract val coroutineImpl: IrClass
- abstract val coroutineSuspendedGetter: IrSimpleFunctionSymbol
+ abstract val coroutineSuspendedGetter: IrSimpleFunction
- abstract val getContinuation: IrSimpleFunctionSymbol
+ abstract val getContinuation: IrSimpleFunction
- abstract val coroutineContextGetter: IrSimpleFunctionSymbol
+ abstract val coroutineContextGetter: IrSimpleFunction
- abstract val suspendCoroutineUninterceptedOrReturn: IrSimpleFunctionSymbol
+ abstract val suspendCoroutineUninterceptedOrReturn: IrSimpleFunction
- abstract val coroutineGetContext: IrSimpleFunctionSymbol
+ abstract val coroutineGetContext: IrSimpleFunction
- abstract val returnIfSuspended: IrSimpleFunctionSymbol
+ abstract val returnIfSuspended: IrSimpleFunction
- private val binaryOperatorCache = mutableMapOf<Triple<Name, KotlinType, KotlinType>, IrSimpleFunctionSymbol>()
+ private val binaryOperatorCache = mutableMapOf<Triple<Name, KotlinType, KotlinType>, IrSimpleFunction>()
- fun getBinaryOperator(name: Name, lhsType: KotlinType, rhsType: KotlinType): IrSimpleFunctionSymbol {
+ fun getBinaryOperator(name: Name, lhsType: KotlinType, rhsType: KotlinType): IrSimpleFunction {
val key = Triple(name, lhsType, rhsType)
return binaryOperatorCache.getOrPut(key) {
symbolTable.referenceSimpleFunction(
lhsType.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND)
.first { it.valueParameters.size == 1 && it.valueParameters[0].type == rhsType }
- )
+ ).owner
}
}
- private val unaryOperatorCache = mutableMapOf<Pair<Name, KotlinType>, IrSimpleFunctionSymbol>()
+ private val unaryOperatorCache = mutableMapOf<Pair<Name, KotlinType>, IrSimpleFunction>()
- fun getUnaryOperator(name: Name, receiverType: KotlinType): IrSimpleFunctionSymbol {
+ fun getUnaryOperator(name: Name, receiverType: KotlinType): IrSimpleFunction {
val key = name to receiverType
return unaryOperatorCache.getOrPut(key) {
symbolTable.referenceSimpleFunction(
receiverType.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND)
.first { it.valueParameters.isEmpty() }
- )
+ ).owner
}
}
val intAnd = getBinaryOperator(OperatorNameConventions.AND, builtIns.intType, builtIns.intType)
val intPlusInt = getBinaryOperator(OperatorNameConventions.PLUS, builtIns.intType, builtIns.intType)
- open fun functionN(n: Int): IrClassSymbol = symbolTable.referenceClass(builtIns.getFunction(n))
- open fun suspendFunctionN(n: Int): IrClassSymbol = symbolTable.referenceClass(builtIns.getSuspendFunction(n))
+ open fun functionN(n: Int): IrClass = symbolTable.referenceClass(builtIns.getFunction(n))
+ open fun suspendFunctionN(n: Int): IrClass = symbolTable.referenceClass(builtIns.getSuspendFunction(n))
val extensionToString = getSimpleFunction(Name.identifier("toString")) {
it.dispatchReceiverParameter == null && it.extensionReceiverParameter != null &&
@@ -240,22 +235,20 @@
}
companion object {
- fun isLateinitIsInitializedPropertyGetter(symbol: IrFunctionSymbol): Boolean =
- symbol is IrSimpleFunctionSymbol && symbol.owner.let { function ->
- function.name.asString() == "<get-isInitialized>" &&
- function.isTopLevel &&
- function.getPackageFragment()!!.fqName.asString() == "kotlin" &&
- function.valueParameters.isEmpty() &&
- symbol.owner.extensionReceiverParameter?.type?.classOrNull?.owner.let { receiverClass ->
- receiverClass?.fqNameWhenAvailable?.toUnsafe() == KotlinBuiltIns.FQ_NAMES.kProperty0
- }
- }
+ fun isLateinitIsInitializedPropertyGetter(function: IrFunction): Boolean =
+ function is IrSimpleFunction &&
+ function.name.asString() == "<get-isInitialized>" &&
+ function.isTopLevel &&
+ function.getPackageFragment()!!.fqName.asString() == "kotlin" &&
+ function.valueParameters.isEmpty() &&
+ function.extensionReceiverParameter?.type?.classOrNull?.owner.let { receiverClass ->
+ receiverClass?.fqNameWhenAvailable?.toUnsafe() == KotlinBuiltIns.FQ_NAMES.kProperty0
+ }
- fun isTypeOfIntrinsic(symbol: IrFunctionSymbol): Boolean =
- symbol is IrSimpleFunctionSymbol && symbol.owner.let { function ->
- function.name.asString() == "typeOf" &&
- function.valueParameters.isEmpty() &&
- (function.parent as? IrPackageFragment)?.fqName == KOTLIN_REFLECT_FQ_NAME
- }
+ fun isTypeOfIntrinsic(function: IrFunction): Boolean =
+ function is IrSimpleFunction &&
+ function.name.asString() == "typeOf" &&
+ function.valueParameters.isEmpty() &&
+ (function.parent as? IrPackageFragment)?.fqName == KOTLIN_REFLECT_FQ_NAME
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrInlineUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrInlineUtils.kt
index cb23885..de8cbc4 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrInlineUtils.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrInlineUtils.kt
@@ -27,7 +27,7 @@
if (this !is IrBlock || statements.size != 2)
return null
val (function, reference) = statements
- if (function !is IrSimpleFunction || reference !is IrFunctionReference || function.symbol != reference.symbol)
+ if (function !is IrSimpleFunction || reference !is IrFunctionReference || function != reference.target)
return null
if ((0 until reference.valueArgumentsCount).any { reference.getValueArgument(it) != null })
return null
@@ -42,11 +42,11 @@
require(body != null)
val argumentMap = valueParameters.zip(arguments).toMap()
val blockSymbol = IrReturnableBlockSymbolImpl(descriptor)
- val block = IrReturnableBlockImpl(startOffset, endOffset, returnType, blockSymbol, null, symbol)
+ val block = IrReturnableBlockImpl(startOffset, endOffset, returnType, blockSymbol, null, this)
val remapper = object : VariableRemapper(argumentMap) {
override fun visitReturn(expression: IrReturn): IrExpression = super.visitReturn(
- if (expression.returnTargetSymbol == symbol)
- IrReturnImpl(expression.startOffset, expression.endOffset, expression.type, blockSymbol, expression.value)
+ if (expression.irReturnTarget == this@inline)
+ IrReturnImpl(expression.startOffset, expression.endOffset, expression.type, block, expression.value)
else
expression
)
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt
index 7887bee..2fe2e62 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt
@@ -83,26 +83,26 @@
listOf(
IrDelegatingConstructorCallImpl(
startOffset, endOffset, irBuiltIns.unitType,
- superConstructor.symbol, superConstructor.descriptor,
+ superConstructor, superConstructor.descriptor,
0, superConstructor.valueParameters.size
).apply {
constructor.valueParameters.forEachIndexed { idx, parameter ->
- putValueArgument(idx, IrGetValueImpl(startOffset, endOffset, parameter.type, parameter.symbol))
+ putValueArgument(idx, IrGetValueImpl(startOffset, endOffset, parameter.type, parameter))
}
},
- IrInstanceInitializerCallImpl(startOffset, endOffset, this.symbol, irBuiltIns.unitType)
+ IrInstanceInitializerCallImpl(startOffset, endOffset, this, irBuiltIns.unitType)
)
)
}
}
-val IrCall.isSuspend get() = (symbol.owner as? IrSimpleFunction)?.isSuspend == true
-val IrFunctionReference.isSuspend get() = (symbol.owner as? IrSimpleFunction)?.isSuspend == true
+val IrCall.isSuspend get() = (target as? IrSimpleFunction)?.isSuspend == true
+val IrFunctionReference.isSuspend get() = (target as? IrSimpleFunction)?.isSuspend == true
val IrSimpleFunction.isOverridable: Boolean
get() = visibility != Visibilities.PRIVATE && modality != Modality.FINAL && (parent as? IrClass)?.isFinalClass != true
-val IrSimpleFunction.isOverridableOrOverrides: Boolean get() = isOverridable || overriddenSymbols.isNotEmpty()
+val IrSimpleFunction.isOverridableOrOverrides: Boolean get() = isOverridable || overridden.isNotEmpty()
fun IrReturnTarget.returnType(context: CommonBackendContext) =
when (this) {
@@ -117,9 +117,8 @@
// For an annotation, get the annotation class.
fun IrCall.getAnnotationClass(): IrClass {
- val callable = symbol.owner
- assert(callable is IrConstructor) { "Constructor call expected, got ${ir2string(this)}" }
- val annotationClass = callable.parentAsClass
+ assert(target is IrConstructor) { "Constructor call expected, got ${ir2string(this)}" }
+ val annotationClass = target.parentAsClass
assert(annotationClass.isAnnotationClass) { "Annotation class expected, got ${ir2string(annotationClass)}" }
return annotationClass
}
@@ -365,7 +364,7 @@
IrValueParameterSymbolImpl(thisReceiverDescriptor),
Name.identifier("<this>"),
index = -1,
- type = this.symbol.typeWith(this.typeParameters.map { it.defaultType }),
+ type = this.typeWith(this.typeParameters.map { it.defaultType }),
varargElementType = null,
isCrossinline = false,
isNoinline = false
@@ -450,7 +449,7 @@
val overriddenFunctions = declarations
.flatMap { it.toList() }
- .flatMap { it.overriddenSymbols.map { it.owner } }
+ .flatMap { it.overridden }
.toSet()
val unoverriddenSuperFunctions = superTypes
@@ -485,7 +484,7 @@
).apply {
descriptor.bind(this)
parent = this@addFakeOverrides
- overriddenSymbols += overriddenFunctions.map { it.symbol }
+ overridden += overriddenFunctions
copyParameterDeclarationsFrom(irFunction)
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/SharedVariablesManager.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/SharedVariablesManager.kt
index 6eb4043..8368cf2 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/SharedVariablesManager.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/SharedVariablesManager.kt
@@ -10,14 +10,13 @@
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrGetValue
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
interface SharedVariablesManager {
fun declareSharedVariable(originalDeclaration: IrVariable): IrVariable
fun defineSharedValue(originalDeclaration: IrVariable, sharedVariableDeclaration: IrVariable): IrStatement
- fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue): IrExpression
+ fun getSharedValue(sharedVariable: IrVariable, originalGet: IrGetValue): IrExpression
- fun setSharedValue(sharedVariableSymbol: IrVariableSymbol, originalSet: IrSetVariable): IrExpression
+ fun setSharedValue(sharedVariable: IrVariable, originalSet: IrSetVariable): IrExpression
}
\ No newline at end of file
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt
index b68e3ca..15da1fa 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt
@@ -23,16 +23,12 @@
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrInstanceInitializerCallImpl
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
-import org.jetbrains.kotlin.ir.types.IrType
-import org.jetbrains.kotlin.ir.types.classifierOrFail
+import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
-import org.jetbrains.kotlin.ir.types.typeWith
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.*
import org.jetbrains.kotlin.name.Name
@@ -43,7 +39,7 @@
protected object DECLARATION_ORIGIN_COROUTINE_IMPL : IrDeclarationOriginImpl("COROUTINE_IMPL")
protected abstract val stateMachineMethodName: Name
- protected abstract fun getCoroutineBaseClass(function: IrFunction): IrClassSymbol
+ protected abstract fun getCoroutineBaseClass(function: IrFunction): IrClass
protected abstract fun nameForCoroutineClass(function: IrFunction): Name
protected abstract fun buildStateMachine(
@@ -84,7 +80,7 @@
// Suppress since it is used in native
@Suppress("MemberVisibilityCanBePrivate")
protected fun IrCall.isReturnIfSuspendedCall() =
- symbol.owner.run { fqNameWhenAvailable == context.internalPackageFqn.child(Name.identifier("returnIfSuspended")) }
+ target.run { fqNameWhenAvailable == context.internalPackageFqn.child(Name.identifier("returnIfSuspended")) }
private fun tryTransformSuspendFunction(element: IrElement) =
if (element is IrSimpleFunction && element.isSuspend && element.modality != Modality.ABSTRACT)
@@ -101,7 +97,7 @@
expression.acceptChildrenVoid(this)
if (expression.isSuspend) {
- suspendLambdas[expression.symbol.owner] = expression
+ suspendLambdas[expression.target] = expression
}
}
})
@@ -115,16 +111,16 @@
if (!expression.isSuspend)
return expression
- val coroutine = builtCoroutines[expression.symbol.owner]
+ val coroutine = builtCoroutines[expression.target]
?: throw Error("Non-local callable reference to suspend lambda: $expression")
val constructorParameters = coroutine.coroutineConstructor.valueParameters
val expressionArguments = expression.getArguments().map { it.second }
assert(constructorParameters.size == expressionArguments.size) {
"Inconsistency between callable reference to suspend lambda and the corresponding coroutine"
}
- val irBuilder = context.createIrBuilder(expression.symbol, expression.startOffset, expression.endOffset)
+ val irBuilder = context.createIrBuilder(expression.target, expression.startOffset, expression.endOffset)
irBuilder.run {
- return irCall(coroutine.coroutineConstructor.symbol).apply {
+ return irCall(coroutine.coroutineConstructor).apply {
expressionArguments.forEachIndexed { index, argument ->
putValueArgument(index, argument)
}
@@ -215,15 +211,15 @@
}
private val symbols = context.ir.symbols
- private val getContinuationSymbol = symbols.getContinuation
- private val continuationClassSymbol = getContinuationSymbol.owner.returnType.classifierOrFail as IrClassSymbol
+ private val getContinuation = symbols.getContinuation
+ private val continuationClass = getContinuation.returnType.getClass()!!
private fun removeReturnIfSuspendedCallAndSimplifyDelegatingCall(irFunction: IrFunction, delegatingCall: IrCall) {
val returnValue =
if (delegatingCall.isReturnIfSuspendedCall())
delegatingCall.getValueArgument(0)!!
else delegatingCall
- context.createIrBuilder(irFunction.symbol).run {
+ context.createIrBuilder(irFunction).run {
val statements = (irFunction.body as IrBlockBody).statements
val lastStatement = statements.last()
assert(lastStatement == delegatingCall || lastStatement is IrReturn) { "Unexpected statement $lastStatement" }
@@ -237,11 +233,11 @@
if (functionReference == null) {
// It is not a lambda - replace original function with a call to constructor of the built coroutine.
- val irBuilder = context.createIrBuilder(irFunction.symbol, irFunction.startOffset, irFunction.endOffset)
+ val irBuilder = context.createIrBuilder(irFunction, irFunction.startOffset, irFunction.endOffset)
irFunction.body = irBuilder.irBlockBody(irFunction) {
val constructor = coroutine.coroutineConstructor
generateCoroutineStart(coroutine.stateMachineFunction,
- irCallConstructor(constructor.symbol, irFunction.typeParameters.map {
+ irCallConstructor(constructor, irFunction.typeParameters.map {
IrSimpleTypeImpl(it.symbol, true, emptyList(), emptyList())
}).apply {
val functionParameters = irFunction.explicitParameters
@@ -251,8 +247,8 @@
putValueArgument(
functionParameters.size,
irCall(
- getContinuationSymbol,
- getContinuationSymbol.owner.returnType,
+ getContinuation,
+ getContinuation.returnType,
listOf(irFunction.returnType)
)
)
@@ -302,7 +298,7 @@
}
private val coroutineClassThis = coroutineClass.thisReceiver!!
- private val continuationType = continuationClassSymbol.typeWith(irFunction.returnType)
+ private val continuationType = continuationClass.typeWith(irFunction.returnType)
// Save all arguments to fields.
private val argumentToPropertiesMap = functionParameters.associate {
@@ -310,15 +306,15 @@
}
private val coroutineBaseClass = getCoroutineBaseClass(irFunction)
- private val coroutineBaseClassConstructor = coroutineBaseClass.owner.constructors.single { it.valueParameters.size == 1 }
- private val create1Function = coroutineBaseClass.owner.simpleFunctions()
+ private val coroutineBaseClassConstructor = coroutineBaseClass.constructors.single { it.valueParameters.size == 1 }
+ private val create1Function = coroutineBaseClass.simpleFunctions()
.single { it.name.asString() == "create" && it.valueParameters.size == 1 }
private val create1CompletionParameter = create1Function.valueParameters[0]
private val coroutineConstructors = mutableListOf<IrConstructor>()
fun build(): BuiltCoroutine {
- val superTypes = mutableListOf(coroutineBaseClass.owner.defaultType)
+ val superTypes = mutableListOf(coroutineBaseClass.defaultType)
var suspendFunctionClass: IrClass? = null
var functionClass: IrClass? = null
val suspendFunctionClassTypeArguments: List<IrType>?
@@ -326,19 +322,19 @@
if (unboundFunctionParameters != null) {
// Suspend lambda inherits SuspendFunction.
val numberOfParameters = unboundFunctionParameters.size
- suspendFunctionClass = symbols.suspendFunctionN(numberOfParameters).owner
+ suspendFunctionClass = symbols.suspendFunctionN(numberOfParameters)
val unboundParameterTypes = unboundFunctionParameters.map { it.type }
suspendFunctionClassTypeArguments = unboundParameterTypes + irFunction.returnType
superTypes += suspendFunctionClass.typeWith(suspendFunctionClassTypeArguments)
- functionClass = symbols.functionN(numberOfParameters + 1).owner
+ functionClass = symbols.functionN(numberOfParameters + 1)
functionClassTypeArguments = unboundParameterTypes + continuationType + context.irBuiltIns.anyNType
superTypes += functionClass.typeWith(functionClassTypeArguments)
}
val coroutineConstructor = buildConstructor()
- val superInvokeSuspendFunction = coroutineBaseClass.owner.simpleFunctions().single { it.name == stateMachineMethodName }
+ val superInvokeSuspendFunction = coroutineBaseClass.simpleFunctions().single { it.name == stateMachineMethodName }
val invokeSuspendMethod = buildInvokeSuspendMethod(superInvokeSuspendFunction, coroutineClass)
var coroutineFactoryConstructor: IrConstructor? = null
@@ -347,24 +343,23 @@
// Suspend lambda - create factory methods.
coroutineFactoryConstructor = buildFactoryConstructor(boundFunctionParameters!!)
- val createFunctionSymbol = coroutineBaseClass.owner.simpleFunctions()
+ val createFunction = coroutineBaseClass.simpleFunctions()
.atMostOne { it.name.asString() == "create" && it.valueParameters.size == unboundFunctionParameters!!.size + 1 }
- ?.symbol
createMethod = buildCreateMethod(
unboundArgs = unboundFunctionParameters!!,
- superFunctionSymbol = createFunctionSymbol,
+ superFunction = createFunction,
coroutineConstructor = coroutineConstructor
)
- val invokeFunctionSymbol =
- functionClass!!.simpleFunctions().single { it.name.asString() == "invoke" }.symbol
- val suspendInvokeFunctionSymbol =
- suspendFunctionClass!!.simpleFunctions().single { it.name.asString() == "invoke" }.symbol
+ val invokeFunction =
+ functionClass!!.simpleFunctions().single { it.name.asString() == "invoke" }
+ val suspendInvokeFunction =
+ suspendFunctionClass!!.simpleFunctions().single { it.name.asString() == "invoke" }
buildInvokeMethod(
- suspendFunctionInvokeFunctionSymbol = suspendInvokeFunctionSymbol,
- functionInvokeFunctionSymbol = invokeFunctionSymbol,
+ suspendFunctionInvokeFunction = suspendInvokeFunction,
+ functionInvokeFunction = invokeFunction,
createFunction = createMethod,
stateMachineFunction = invokeSuspendMethod
)
@@ -414,7 +409,7 @@
+irDelegatingConstructorCall(coroutineBaseClassConstructor).apply {
putValueArgument(0, irGet(completionParameter))
}
- +IrInstanceInitializerCallImpl(startOffset, endOffset, coroutineClass.symbol, context.irBuiltIns.unitType)
+ +IrInstanceInitializerCallImpl(startOffset, endOffset, coroutineClass, context.irBuiltIns.unitType)
functionParameters.forEachIndexed { index, parameter ->
+irSetField(
@@ -454,7 +449,7 @@
putValueArgument(0, irNull()) // Completion.
}
+IrInstanceInitializerCallImpl(
- startOffset, endOffset, coroutineClass.symbol,
+ startOffset, endOffset, coroutineClass,
context.irBuiltIns.unitType
)
// Save all arguments to fields.
@@ -470,7 +465,7 @@
private fun buildCreateMethod(
unboundArgs: List<IrValueParameter>,
- superFunctionSymbol: IrSimpleFunctionSymbol?,
+ superFunction: IrSimpleFunction?,
coroutineConstructor: IrConstructor
) = WrappedSimpleFunctionDescriptor().let { d ->
IrFunctionImpl(
@@ -502,9 +497,9 @@
this.createDispatchReceiverParameter()
- superFunctionSymbol?.let {
- overriddenSymbols += it.owner.overriddenSymbols
- overriddenSymbols += it
+ superFunction?.let {
+ overridden += it.overridden
+ overridden += it
}
val thisReceiver = this.dispatchReceiverParameter!!
@@ -533,8 +528,8 @@
}
private fun buildInvokeMethod(
- suspendFunctionInvokeFunctionSymbol: IrSimpleFunctionSymbol,
- functionInvokeFunctionSymbol: IrSimpleFunctionSymbol,
+ suspendFunctionInvokeFunction: IrSimpleFunction,
+ functionInvokeFunction: IrSimpleFunction,
createFunction: IrFunction,
stateMachineFunction: IrFunction
) = WrappedSimpleFunctionDescriptor().let { d ->
@@ -569,8 +564,8 @@
this.createDispatchReceiverParameter()
- overriddenSymbols += functionInvokeFunctionSymbol
- overriddenSymbols += suspendFunctionInvokeFunctionSymbol
+ overridden += functionInvokeFunction
+ overridden += suspendFunctionInvokeFunction
val thisReceiver = dispatchReceiverParameter!!
@@ -583,7 +578,7 @@
}
putValueArgument(
valueParameters.size,
- irCall(getContinuationSymbol, getContinuationSymbol.owner.returnType, listOf(returnType))
+ irCall(getContinuation, getContinuation.returnType, listOf(returnType))
)
})
}
@@ -623,7 +618,7 @@
this.createDispatchReceiverParameter()
- overriddenSymbols += stateMachineFunction.symbol
+ overridden += stateMachineFunction
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt
index 994c2a5..52630af 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt
@@ -10,10 +10,6 @@
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrStringConcatenationImpl
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
-import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
-import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
@@ -49,10 +45,10 @@
this.useAsValue(parameter)
protected open fun IrExpression.useAsDispatchReceiver(expression: IrFunctionAccessExpression): IrExpression =
- this.useAsArgument(expression.symbol.owner.dispatchReceiverParameter!!)
+ this.useAsArgument(expression.target.dispatchReceiverParameter!!)
protected open fun IrExpression.useAsExtensionReceiver(expression: IrFunctionAccessExpression): IrExpression =
- this.useAsArgument(expression.symbol.owner.extensionReceiverParameter!!)
+ this.useAsArgument(expression.target.extensionReceiverParameter!!)
protected open fun IrExpression.useAsValueArgument(
expression: IrFunctionAccessExpression,
@@ -66,11 +62,11 @@
private fun IrExpression.useForField(field: IrField): IrExpression =
this.useAs(field.type)
- protected open fun IrExpression.useAsReturnValue(returnTarget: IrReturnTargetSymbol): IrExpression =
+ protected open fun IrExpression.useAsReturnValue(returnTarget: IrReturnTarget): IrExpression =
when (returnTarget) {
- is IrSimpleFunctionSymbol -> this.useAs(returnTarget.owner.returnType)
- is IrConstructorSymbol -> this.useAs(irBuiltIns.unitType)
- is IrReturnableBlockSymbol -> this.useAs(returnTarget.owner.type)
+ is IrSimpleFunction -> this.useAs(returnTarget.returnType)
+ is IrConstructor -> this.useAs(irBuiltIns.unitType)
+ is IrReturnableBlock -> this.useAs(returnTarget.type)
else -> error(returnTarget)
}
@@ -99,7 +95,7 @@
extensionReceiver = extensionReceiver?.useAsExtensionReceiver(expression)
for (index in descriptor.valueParameters.indices) {
val argument = getValueArgument(index) ?: continue
- val parameter = symbol.owner.valueParameters[index]
+ val parameter = target.valueParameters[index]
putValueArgument(index, argument.useAsValueArgument(expression, parameter))
}
}
@@ -143,7 +139,7 @@
override fun visitReturn(expression: IrReturn): IrExpression {
expression.transformChildrenVoid(this)
- expression.value = expression.value.useAsReturnValue(expression.returnTargetSymbol)
+ expression.value = expression.value.useAsReturnValue(expression.irReturnTarget)
return expression
}
@@ -151,7 +147,7 @@
override fun visitSetVariable(expression: IrSetVariable): IrExpression {
expression.transformChildrenVoid(this)
- expression.value = expression.value.useForVariable(expression.symbol.owner)
+ expression.value = expression.value.useForVariable(expression.target)
return expression
}
@@ -159,7 +155,7 @@
override fun visitSetField(expression: IrSetField): IrExpression {
expression.transformChildrenVoid(this)
- expression.value = expression.value.useForField(expression.symbol.owner)
+ expression.value = expression.value.useForField(expression.target)
return expression
}
@@ -261,7 +257,7 @@
declaration.body?.let {
if (it is IrExpressionBody) {
- it.expression = it.expression.useAsReturnValue(declaration.symbol)
+ it.expression = it.expression.useAsReturnValue(declaration)
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt
index 2ec7f11..5d0cb71 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt
@@ -13,11 +13,11 @@
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.declarations.IrFile
+import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.getClass
import org.jetbrains.kotlin.ir.types.toKotlinType
import org.jetbrains.kotlin.ir.util.constructedClass
@@ -33,12 +33,12 @@
}
// Array(size, init) -> Array(size)
- private fun arrayInlineToSizeConstructor(irConstructor: IrConstructor): IrFunctionSymbol? {
- val clazz = irConstructor.constructedClass.symbol
+ private fun arrayInlineToSizeConstructor(irConstructor: IrConstructor): IrFunction? {
+ val clazz = irConstructor.constructedClass
return when {
irConstructor.valueParameters.size != 2 -> null
- clazz == context.irBuiltIns.arrayClass -> context.ir.symbols.arrayOfNulls // Array<T> has no unary constructor: it can only exist for Array<T?>
- context.irBuiltIns.primitiveArrays.contains(clazz) -> clazz.constructors.single { it.owner.valueParameters.size == 1 }
+ clazz == context.irBuiltIns.arrayClass.owner -> context.ir.symbols.arrayOfNulls // Array<T> has no unary constructor: it can only exist for Array<T?>
+ context.irBuiltIns.primitiveArrays.contains(clazz.symbol) -> clazz.constructors.single { it.valueParameters.size == 1 }
else -> null
}
}
@@ -53,7 +53,7 @@
}
override fun visitConstructorCall(expression: IrConstructorCall): IrExpression {
- val sizeConstructor = arrayInlineToSizeConstructor(expression.symbol.owner)
+ val sizeConstructor = arrayInlineToSizeConstructor(expression.target)
?: return super.visitConstructorCall(expression)
// inline fun <reified T> Array(size: Int, invokable: (Int) -> T): Array<T> {
// val result = arrayOfNulls<T>(size)
@@ -66,7 +66,7 @@
val size = expression.getValueArgument(0)!!.transform(this, null)
val invokable = expression.getValueArgument(1)!!.transform(this, null)
val scope = currentScope!!.scope
- return context.createIrBuilder(scope.scopeOwnerSymbol).irBlock(expression.startOffset, expression.endOffset) {
+ return context.createIrBuilder(scope.irScopeOwner).irBlock(expression.startOffset, expression.endOffset) {
val index = irTemporaryVar(irInt(0))
val sizeVar = irTemporary(size)
val result = irTemporary(irCall(sizeConstructor, expression.type).apply {
@@ -85,7 +85,7 @@
body = irBlock {
val tempIndex = irTemporary(irGet(index))
val value = lambda?.inline(listOf(tempIndex)) ?: irCallOp(
- invoke.symbol,
+ invoke,
invoke.returnType,
irGet(invokableVar!!),
irGet(tempIndex)
@@ -96,7 +96,7 @@
putValueArgument(1, value)
}
val inc = index.type.getClass()!!.functions.single { it.name == OperatorNameConventions.INC }
- +irSetVar(index.symbol, irCallOp(inc.symbol, index.type, irGet(index)))
+ +irSetVar(index, irCallOp(inc, index.type, irGet(index)))
}
}
+irGet(result)
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ClosureAnnotator.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ClosureAnnotator.kt
index 80f5f28..a5c8614 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ClosureAnnotator.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ClosureAnnotator.kt
@@ -26,13 +26,12 @@
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
import org.jetbrains.kotlin.ir.expressions.IrValueAccessExpression
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.util.isLocal
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import kotlin.collections.set
-class Closure(val capturedValues: List<IrValueSymbol> = emptyList())
+class Closure(val capturedValues: List<IrValueDeclaration> = emptyList())
class ClosureAnnotator(irFile: IrFile) {
private val closureBuilders = mutableMapOf<IrDeclaration, ClosureBuilder>()
@@ -53,7 +52,7 @@
}
private class ClosureBuilder(val owner: IrDeclaration) {
- val capturedValues = mutableSetOf<IrValueSymbol>()
+ val capturedValues = mutableSetOf<IrValueDeclaration>()
private val declaredValues = mutableSetOf<IrValueDeclaration>()
private val includes = mutableSetOf<ClosureBuilder>()
@@ -65,11 +64,11 @@
* variables declared in the node.
*/
fun buildClosure(): Closure {
- val result = mutableSetOf<IrValueSymbol>().apply { addAll(capturedValues) }
+ val result = mutableSetOf<IrValueDeclaration>().apply { addAll(capturedValues) }
includes.forEach { builder ->
if (!builder.processed) {
builder.processed = true
- builder.buildClosure().capturedValues.filterTo(result) { isExternal(it.owner) }
+ builder.buildClosure().capturedValues.filterTo(result) { isExternal(it) }
}
}
// TODO: We can save the closure and reuse it.
@@ -86,8 +85,8 @@
declaredValues.add(valueDeclaration)
}
- fun seeVariable(value: IrValueSymbol) {
- if (isExternal(value.owner))
+ fun seeVariable(value: IrValueDeclaration) {
+ if (isExternal(value))
capturedValues.add(value)
}
@@ -162,7 +161,7 @@
}
override fun visitVariableAccess(expression: IrValueAccessExpression) {
- closuresStack.peek()?.seeVariable(expression.symbol)
+ closuresStack.peek()?.seeVariable(expression.target)
super.visitVariableAccess(expression)
}
@@ -173,18 +172,18 @@
override fun visitFunctionAccess(expression: IrFunctionAccessExpression) {
super.visitFunctionAccess(expression)
- processMemberAccess(expression.symbol.owner)
+ processMemberAccess(expression.target)
}
override fun visitFunctionReference(expression: IrFunctionReference) {
super.visitFunctionReference(expression)
- processMemberAccess(expression.symbol.owner)
+ processMemberAccess(expression.target)
}
override fun visitPropertyReference(expression: IrPropertyReference) {
super.visitPropertyReference(expression)
- expression.getter?.let { processMemberAccess(it.owner) }
- expression.setter?.let { processMemberAccess(it.owner) }
+ expression.getter?.let { processMemberAccess(it) }
+ expression.setter?.let { processMemberAccess(it) }
}
private fun processMemberAccess(declaration: IrDeclaration) {
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt
index a0aa64e..5fd462ed 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt
@@ -17,8 +17,6 @@
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
@@ -69,7 +67,7 @@
irFunction.generateDefaultsFunction(context, IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER, skipInlineMethods, skipExternalMethods)
log { "$irFunction -> $newIrFunction" }
- val builder = context.createIrBuilder(newIrFunction.symbol)
+ val builder = context.createIrBuilder(newIrFunction)
newIrFunction.body = builder.irBlockBody(newIrFunction) {
val params = mutableListOf<IrVariable>()
@@ -87,7 +85,7 @@
val parameter = newIrFunction.valueParameters[valueParameter.index]
val argument = if (valueParameter.defaultValue != null) {
- val kIntAnd = symbols.intAnd.owner
+ val kIntAnd = symbols.intAnd
val condition = irNotEquals(irCall(kIntAnd).apply {
dispatchReceiver = irGet(maskParameter(newIrFunction, valueParameter.index / 32))
putValueArgument(0, irInt(1 shl (valueParameter.index % 32)))
@@ -98,9 +96,9 @@
expressionBody.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetValue(expression: IrGetValue): IrExpression {
- log { "GetValue: ${expression.symbol.owner}" }
- val valueSymbol = variables[expression.symbol.owner] ?: return expression
- return irGet(valueSymbol)
+ log { "GetValue: ${expression.target}" }
+ val value = variables[expression.target] ?: return expression
+ return irGet(value)
}
})
@@ -126,7 +124,7 @@
startOffset = irFunction.startOffset,
endOffset = irFunction.endOffset,
type = context.irBuiltIns.unitType,
- symbol = irFunction.symbol, descriptor = irFunction.symbol.descriptor,
+ target = irFunction, descriptor = irFunction.descriptor,
typeArgumentsCount = newIrFunction.parentAsClass.typeParameters.size + newIrFunction.typeParameters.size
).apply {
passTypeArgumentsFrom(newIrFunction.parentAsClass)
@@ -153,7 +151,7 @@
newIrFunction: IrFunction,
params: MutableList<IrVariable>
): IrExpression {
- val dispatchCall = irCall(irFunction.symbol).apply {
+ val dispatchCall = irCall(irFunction).apply {
passTypeArgumentsFrom(newIrFunction)
dispatchReceiver = newIrFunction.dispatchReceiverParameter?.let { irGet(it) }
extensionReceiver = newIrFunction.extensionReceiverParameter?.let { irGet(it) }
@@ -213,9 +211,9 @@
private fun visitFunctionAccessExpression(
expression: IrFunctionAccessExpression,
- builder: (IrFunctionSymbol) -> IrFunctionAccessExpression
+ builder: (IrFunction) -> IrFunctionAccessExpression
): IrExpression {
- val functionDeclaration = expression.symbol.owner
+ val functionDeclaration = expression.target
if (!functionDeclaration.needsDefaultArgumentsLowering(skipInline, skipExternalMethods))
return expression
@@ -224,16 +222,15 @@
if (argumentsCount == functionDeclaration.valueParameters.size)
return expression
- val (symbol, params) = parametersForCall(expression)
- val descriptor = symbol.descriptor
- val declaration = symbol.owner
+ val (declaration, params) = parametersForCall(expression)
+ val descriptor = declaration.descriptor
for (i in 0 until expression.typeArgumentsCount) {
log { "$descriptor [$i]: $expression.getTypeArgument(i)" }
}
declaration.typeParameters.forEach { log { "$declaration[${it.index}] : $it" } }
- return builder(symbol).apply {
+ return builder(declaration).apply {
this.copyTypeArgumentsFrom(expression)
params.forEach {
@@ -257,7 +254,7 @@
startOffset = expression.startOffset,
endOffset = expression.endOffset,
type = context.irBuiltIns.unitType,
- symbol = it as IrConstructorSymbol,
+ target = it as IrConstructor,
descriptor = it.descriptor,
typeArgumentsCount = expression.typeArgumentsCount
)
@@ -272,7 +269,7 @@
expression.startOffset,
expression.endOffset,
expression.type,
- it as IrConstructorSymbol,
+ it as IrConstructor,
DEFAULT_DISPATCH_CALL
)
}
@@ -286,7 +283,7 @@
expression.startOffset,
expression.endOffset,
expression.type,
- it as IrConstructorSymbol
+ it as IrConstructor
)
}
}
@@ -299,11 +296,11 @@
startOffset = expression.startOffset,
endOffset = expression.endOffset,
type = expression.type,
- symbol = it,
+ target = it,
descriptor = it.descriptor,
typeArgumentsCount = expression.typeArgumentsCount,
origin = DEFAULT_DISPATCH_CALL,
- superQualifierSymbol = expression.superQualifierSymbol
+ irSuperQualifier = expression.irSuperQualifier
)
}
}
@@ -313,8 +310,8 @@
if (this !is IrSimpleFunction) return this
- for (s in overriddenSymbols) {
- s.owner.findSuperMethodWithDefaultArguments()?.let { return it }
+ for (s in overridden) {
+ s.findSuperMethodWithDefaultArguments()?.let { return it }
}
return this
@@ -322,8 +319,8 @@
private fun parametersForCall(
expression: IrFunctionAccessExpression
- ): Pair<IrFunctionSymbol, List<Pair<IrValueParameter, IrExpression?>>> {
- val declaration = expression.symbol.owner
+ ): Pair<IrFunction, List<Pair<IrValueParameter, IrExpression?>>> {
+ val declaration = expression.target
val keyFunction = declaration.findSuperMethodWithDefaultArguments()!!
val realFunction =
@@ -358,7 +355,7 @@
value = maskValue
)
}
- if (expression.symbol is IrConstructorSymbol) {
+ if (expression.target is IrConstructor) {
params += markerParameterDeclaration(realFunction) to
IrConstImpl.constNull(startOffset, endOffset, context.irBuiltIns.nothingNType)
} else if (context.ir.shouldGenerateHandlerParameterForDefaultBodyFun()) {
@@ -368,7 +365,7 @@
params.forEach {
log { "descriptor::${realFunction.name.asString()}#${it.first.index}: ${it.first.name.asString()}" }
}
- return Pair(realFunction.symbol, params)
+ return Pair(realFunction, params)
}
private fun argumentCount(expression: IrMemberAccessExpression): Int {
@@ -416,7 +413,7 @@
if (this !is IrSimpleFunction) return false
fun IrSimpleFunction.inheritsDefaultValues(): Boolean =
- valueParameters.any { it.defaultValue != null } || overriddenSymbols.any { it.owner.inheritsDefaultValues() }
+ valueParameters.any { it.defaultValue != null } || overridden.any { it.inheritsDefaultValues() }
return inheritsDefaultValues()
}
@@ -437,7 +434,7 @@
syntheticParameters += newFunction.valueParameter(
syntheticParameters.last().index + 1,
kConstructorMarkerName,
- context.ir.symbols.defaultConstructorMarker.owner.defaultType
+ context.ir.symbols.defaultConstructorMarker.defaultType
)
} else if (context.ir.shouldGenerateHandlerParameterForDefaultBodyFun()) {
syntheticParameters += newFunction.valueParameter(
@@ -461,8 +458,7 @@
annotations.mapTo(newFunction.annotations) { it.deepCopyWithSymbols() }
if (origin == IrDeclarationOrigin.FAKE_OVERRIDE) {
- for (baseFunSymbol in (this as IrSimpleFunction).overriddenSymbols) {
- val baseFun = baseFunSymbol.owner
+ for (baseFun in (this as IrSimpleFunction).overridden) {
if (baseFun.needsDefaultArgumentsLowering(skipInlineMethods, skipExternalMethods)) {
val baseOrigin = if (baseFun.valueParameters.any { it.defaultValue != null }) {
IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER
@@ -470,7 +466,7 @@
IrDeclarationOrigin.FAKE_OVERRIDE
}
val defaultsBaseFun = baseFun.generateDefaultsFunction(context, baseOrigin, skipInlineMethods, skipExternalMethods)
- (newFunction as IrSimpleFunction).overriddenSymbols.add((defaultsBaseFun as IrSimpleFunction).symbol)
+ (newFunction as IrSimpleFunction).overridden.add(defaultsBaseFun as IrSimpleFunction)
}
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/Desymbolize.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/Desymbolize.kt
index 0fb38e9..44959aa 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/Desymbolize.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/Desymbolize.kt
@@ -5,5 +5,22 @@
package org.jetbrains.kotlin.backend.common.lower
-class Desymbolize {
+import org.jetbrains.kotlin.backend.common.CommonBackendContext
+import org.jetbrains.kotlin.backend.common.FileLoweringPass
+import org.jetbrains.kotlin.backend.common.phaser.makeIrModulePhase
+import org.jetbrains.kotlin.ir.declarations.*
+import org.jetbrains.kotlin.ir.util.desymbolize
+
+val desymbolizePhase = makeIrModulePhase(
+ ::Desymbolize,
+ name = "Desymbolize",
+ description = "Replace symbols by their owners in IR structures"
+)
+
+class Desymbolize() : FileLoweringPass {
+ constructor (context: CommonBackendContext) : this()
+
+ override fun lower(irFile: IrFile) {
+ irFile.desymbolize()
+ }
}
\ No newline at end of file
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt
index e623db4..ad4c622 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt
@@ -37,7 +37,7 @@
}
protected open fun mapRuntimeEnumEntry(builder: IrBuilderWithScope, subject: IrExpression): IrExpression =
- builder.irCall(subject.type.getClass()!!.symbol.getPropertyGetter("ordinal")!!).apply { dispatchReceiver = subject }
+ builder.irCall(subject.type.getClass()!!.getPropertyGetter("ordinal")!!).apply { dispatchReceiver = subject }
override fun lower(irFile: IrFile) {
visitFile(irFile)
@@ -59,7 +59,7 @@
// Will be initialized only when we found a branch that compares
// subject with compile-time known enum entry.
val subjectOrdinalProvider = lazy {
- context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, subject.startOffset, subject.endOffset).run {
+ context.createIrBuilder(currentScope!!.scope.irScopeOwner, subject.startOffset, subject.endOffset).run {
val integer = if (subject.type.isNullable())
irIfNull(context.irBuiltIns.intType, irGet(subject), irInt(-1), mapRuntimeEnumEntry(this, irGet(subject)))
else
@@ -81,7 +81,7 @@
override fun visitCall(expression: IrCall): IrExpression {
// We are looking for branch that is a comparison of the subject and another enum entry.
- if (expression.symbol != context.irBuiltIns.eqeqSymbol) {
+ if (expression.target != context.irBuiltIns.eqeqSymbol.owner) {
return super.visitCall(expression)
}
val lhs = expression.getValueArgument(0)!!
@@ -90,20 +90,20 @@
val (topmostSubject, topmostOrdinalProvider) = subjectWithOrdinalStack.peek()
?: return super.visitCall(expression)
val other = when {
- lhs is IrGetValue && lhs.symbol.owner == topmostSubject -> rhs
- rhs is IrGetValue && rhs.symbol.owner == topmostSubject -> lhs
+ lhs is IrGetValue && lhs.target == topmostSubject -> rhs
+ rhs is IrGetValue && rhs.target == topmostSubject -> lhs
else -> return super.visitCall(expression)
}
val entryOrdinal = when {
- other is IrGetEnumValue && topmostSubject.type.classifierOrNull?.owner == other.symbol.owner.parent ->
- mapConstEnumEntry(other.symbol.owner)
+ other is IrGetEnumValue && topmostSubject.type.classifierOrNull?.owner == other.target.parent ->
+ mapConstEnumEntry(other.target)
other.isNullConst() ->
-1
else -> return super.visitCall(expression)
}
val subjectOrdinal = topmostOrdinalProvider.value
- return IrCallImpl(expression.startOffset, expression.endOffset, expression.type, expression.symbol).apply {
- putValueArgument(0, IrGetValueImpl(lhs.startOffset, lhs.endOffset, subjectOrdinal.type, subjectOrdinal.symbol))
+ return IrCallImpl(expression.startOffset, expression.endOffset, expression.type, expression.target).apply {
+ putValueArgument(0, IrGetValueImpl(lhs.startOffset, lhs.endOffset, subjectOrdinal.type, subjectOrdinal))
putValueArgument(1, IrConstImpl.int(rhs.startOffset, rhs.endOffset, context.irBuiltIns.intType, entryOrdinal))
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FinallyBlocksLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FinallyBlocksLowering.kt
index e87789f..92b41e9 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FinallyBlocksLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FinallyBlocksLowering.kt
@@ -31,7 +31,7 @@
fun toIr(context: CommonBackendContext, startOffset: Int, endOffset: Int, value: IrExpression): IrExpression
}
- private data class Return(val target: IrReturnTargetSymbol): HighLevelJump {
+ private data class Return(val target: IrReturnTarget): HighLevelJump {
override fun toIr(context: CommonBackendContext, startOffset: Int, endOffset: Int, value: IrExpression)
=
IrReturnImpl(startOffset, endOffset, context.irBuiltIns.nothingType, target, value)
@@ -111,7 +111,7 @@
override fun visitBreak(jump: IrBreak): IrExpression {
val startOffset = jump.startOffset
val endOffset = jump.endOffset
- val irBuilder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, startOffset, endOffset)
+ val irBuilder = context.createIrBuilder(currentScope!!.scope.irScopeOwner, startOffset, endOffset)
return performHighLevelJump(
targetScopePredicate = { it is LoopScope && it.loop == jump.loop },
jump = Break(jump.loop),
@@ -124,7 +124,7 @@
override fun visitContinue(jump: IrContinue): IrExpression {
val startOffset = jump.startOffset
val endOffset = jump.endOffset
- val irBuilder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, startOffset, endOffset)
+ val irBuilder = context.createIrBuilder(currentScope!!.scope.irScopeOwner, startOffset, endOffset)
return performHighLevelJump(
targetScopePredicate = { it is LoopScope && it.loop == jump.loop },
jump = Continue(jump.loop),
@@ -138,8 +138,8 @@
expression.transformChildrenVoid(this)
return performHighLevelJump(
- targetScopePredicate = { it is ReturnableScope && it.symbol == expression.returnTargetSymbol },
- jump = Return(expression.returnTargetSymbol),
+ targetScopePredicate = { it is ReturnableScope && it.symbol == expression.irReturnTarget },
+ jump = Return(expression.irReturnTarget),
startOffset = expression.startOffset,
endOffset = expression.endOffset,
value = expression.value
@@ -173,7 +173,7 @@
val currentTryScope = tryScopes[index]
currentTryScope.jumps.getOrPut(jump) {
- val type = (jump as? Return)?.target?.owner?.returnType(context) ?: value.type
+ val type = (jump as? Return)?.target?.returnType(context) ?: value.type
jump.toString()
val symbol = IrReturnableBlockSymbolImpl(WrappedSimpleFunctionDescriptor())
with(currentTryScope) {
@@ -194,7 +194,7 @@
startOffset = startOffset,
endOffset = endOffset,
type = context.irBuiltIns.nothingType,
- returnTargetSymbol = it,
+ irReturnTarget = it,
value = value
)
}
@@ -206,7 +206,7 @@
val startOffset = aTry.startOffset
val endOffset = aTry.endOffset
- val irBuilder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, startOffset, endOffset)
+ val irBuilder = context.createIrBuilder(currentScope!!.scope.irScopeOwner, startOffset, endOffset)
val transformer = this
irBuilder.run {
val transformedFinallyExpression = finallyExpression.transform(transformer, null)
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FlattenStringConcatenationLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FlattenStringConcatenationLowering.kt
index b49bb15..4afa274 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FlattenStringConcatenationLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/FlattenStringConcatenationLowering.kt
@@ -16,7 +16,6 @@
import org.jetbrains.kotlin.ir.expressions.IrStringConcatenation
import org.jetbrains.kotlin.ir.expressions.impl.IrStringConcatenationImpl
import org.jetbrains.kotlin.ir.types.isStringClassType
-import org.jetbrains.kotlin.ir.util.fqNameSafe
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
@@ -83,7 +82,7 @@
return when (expression) {
is IrStringConcatenation -> true
is IrCall -> {
- val function = expression.symbol.owner
+ val function = expression.target
val receiver = expression.dispatchReceiver ?: expression.extensionReceiver
receiver != null &&
receiver.type.isStringClassType() &&
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt
index 87f3d60..299df50 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt
@@ -7,7 +7,6 @@
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
import org.jetbrains.kotlin.backend.common.CommonBackendContext
-import org.jetbrains.kotlin.backend.common.deepCopyWithWrappedDescriptors
import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor
import org.jetbrains.kotlin.backend.common.ir.SetDeclarationsParentVisitor
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
@@ -100,12 +99,12 @@
if (!declaration.isStatic) // TODO isStaticField
IrGetValueImpl(
irFieldInitializer.startOffset, irFieldInitializer.endOffset,
- irClass.thisReceiver!!.type, irClass.thisReceiver!!.symbol
+ irClass.thisReceiver!!.type, irClass.thisReceiver!!
)
else null
return IrSetFieldImpl(
irFieldInitializer.startOffset, irFieldInitializer.endOffset,
- declaration.symbol,
+ declaration,
receiver,
irFieldInitializer,
context.irBuiltIns.unitType,
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt
index abb4a4f..a5b1029 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt
@@ -13,8 +13,6 @@
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
@@ -24,7 +22,7 @@
// TODO: Support incremental compilation
class InlineClassLowering(val context: BackendContext) {
- private val transformedFunction = mutableMapOf<IrFunctionSymbol, IrSimpleFunctionSymbol>()
+ private val transformedFunction = mutableMapOf<IrFunction, IrSimpleFunction>()
val inlineClassDeclarationLowering = object : ClassLoweringPass {
override fun lower(irClass: IrClass) {
@@ -46,17 +44,17 @@
if (irConstructor.isPrimary) return irConstructor
// Secondary constructors are lowered into static function
- val result = transformedFunction.getOrPut(irConstructor.symbol) { createStaticBodilessMethod(irConstructor).symbol }.owner
+ val result = transformedFunction.getOrPut(irConstructor) { createStaticBodilessMethod(irConstructor) }
val irClass = irConstructor.parentAsClass
// Copied and adapted from Kotlin/Native InlineClassTransformer
- result.body = context.createIrBuilder(result.symbol).irBlockBody(result) {
+ result.body = context.createIrBuilder(result).irBlockBody(result) {
// Secondary ctors of inline class must delegate to some other constructors.
// Use these delegating call later to initialize this variable.
lateinit var thisVar: IrVariable
val parameterMapping = result.valueParameters.associateBy {
- irConstructor.valueParameters[it.index].symbol
+ irConstructor.valueParameters[it.index]
}
(irConstructor.body as IrBlockBody).statements.forEach { statement ->
@@ -74,11 +72,11 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
expression.transformChildrenVoid()
- if (expression.symbol == irClass.thisReceiver?.symbol) {
+ if (expression.target == irClass.thisReceiver) {
return irGet(thisVar)
}
- parameterMapping[expression.symbol]?.let { return irGet(it) }
+ parameterMapping[expression.target]?.let { return irGet(it) }
return expression
}
@@ -91,7 +89,7 @@
override fun visitReturn(expression: IrReturn): IrExpression {
expression.transformChildrenVoid()
- if (expression.returnTargetSymbol == irConstructor.symbol) {
+ if (expression.irReturnTarget == irConstructor) {
return irReturn(irBlock(expression.startOffset, expression.endOffset) {
+expression.value
+irGet(thisVar)
@@ -116,7 +114,7 @@
return listOf(function)
val staticMethod = createStaticBodilessMethod(function)
- transformedFunction[function.symbol] = staticMethod.symbol
+ transformedFunction[function] = staticMethod
// Move function body to static method, transforming value parameters and nested declarations
function.body!!.transformChildrenVoid(object : IrElementTransformerVoid() {
@@ -129,9 +127,9 @@
}
override fun visitGetValue(expression: IrGetValue): IrExpression {
- val valueDeclaration = expression.symbol.owner as? IrValueParameter ?: return super.visitGetValue(expression)
+ val valueDeclaration = expression.target as? IrValueParameter ?: return super.visitGetValue(expression)
- return context.createIrBuilder(staticMethod.symbol).irGet(
+ return context.createIrBuilder(staticMethod).irGet(
when (valueDeclaration) {
function.dispatchReceiverParameter, function.parentAsClass.thisReceiver ->
staticMethod.valueParameters[0]
@@ -152,11 +150,11 @@
staticMethod.body = function.body
- if (function.overriddenSymbols.isEmpty()) // Function is used only in unboxed context
+ if (function.overridden.isEmpty()) // Function is used only in unboxed context
return listOf(staticMethod)
// Delegate original function to static implementation
- function.body = context.createIrBuilder(function.symbol).irBlockBody {
+ function.body = context.createIrBuilder(function).irBlockBody {
+irReturn(
irCall(staticMethod).apply {
val parameters =
@@ -183,7 +181,7 @@
override fun visitConstructorCall(expression: IrConstructorCall): IrExpression {
expression.transformChildrenVoid(this)
- val function = expression.symbol.owner
+ val function = expression.target
if (!function.parentAsClass.isInline || function.isPrimary) {
return expression
}
@@ -193,7 +191,7 @@
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid(this)
- val function = expression.symbol.owner
+ val function = expression.target
if (function.parent !is IrClass ||
function.isStaticMethodOfClass ||
!function.parentAsClass.isInline ||
@@ -212,7 +210,7 @@
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
expression.transformChildrenVoid(this)
- val function = expression.symbol.owner
+ val function = expression.target
val klass = function.parentAsClass
return when {
!klass.isInline -> expression
@@ -221,11 +219,11 @@
}
}
- private fun getOrCreateStaticMethod(function: IrFunction): IrSimpleFunctionSymbol =
- transformedFunction.getOrPut(function.symbol) {
+ private fun getOrCreateStaticMethod(function: IrFunction): IrSimpleFunction =
+ transformedFunction.getOrPut(function) {
createStaticBodilessMethod(function).also {
function.parentAsClass.declarations.add(it)
- }.symbol
+ }
}
})
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt
index 807d6be..e9de632 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt
@@ -13,15 +13,9 @@
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.builders.irGet
import org.jetbrains.kotlin.ir.builders.irSetField
-import org.jetbrains.kotlin.ir.declarations.IrClass
-import org.jetbrains.kotlin.ir.declarations.IrConstructor
-import org.jetbrains.kotlin.ir.declarations.IrFunction
-import org.jetbrains.kotlin.ir.declarations.IrValueParameter
+import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.parentAsClass
@@ -31,14 +25,14 @@
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
- private val IrValueSymbol.classForImplicitThis: IrClass?
+ private val IrValueDeclaration.classForImplicitThis: IrClass?
// TODO: is this the correct way to get the class?
get() =
- if (this is IrValueParameterSymbol && owner.index == -1 &&
- (owner == (owner.parent as? IrFunction)?.dispatchReceiverParameter ||
- owner == (owner.parent as? IrClass)?.thisReceiver)
+ if (this is IrValueParameter && index == -1 &&
+ (this == (parent as? IrFunction)?.dispatchReceiverParameter ||
+ this == (parent as? IrClass)?.thisReceiver)
) {
- owner.type.classOrNull?.owner
+ type.classOrNull?.owner
} else
null
@@ -57,14 +51,14 @@
}
val blockBody = irConstructor.body as? IrBlockBody ?: throw AssertionError("Unexpected constructor body: ${irConstructor.body}")
- context.createIrBuilder(irConstructor.symbol, irConstructor.startOffset, irConstructor.endOffset).apply {
+ context.createIrBuilder(irConstructor, irConstructor.startOffset, irConstructor.endOffset).apply {
blockBody.statements.add(0, irSetField(irGet(irClass.thisReceiver!!), parentThisField, irGet(outerThisParameter)))
}
if (blockBody.statements.find { it is IrInstanceInitializerCall } == null) {
val delegatingConstructorCall =
blockBody.statements.find { it is IrDelegatingConstructorCall } as IrDelegatingConstructorCall?
?: throw AssertionError("Delegating constructor call expected: ${irConstructor.dump()}")
- delegatingConstructorCall.apply { dispatchReceiver = IrGetValueImpl(startOffset, endOffset, outerThisParameter.symbol) }
+ delegatingConstructorCall.apply { dispatchReceiver = IrGetValueImpl(startOffset, endOffset, outerThisParameter) }
}
blockBody.patchDeclarationParents(loweredConstructor)
loweredConstructor.body = blockBody
@@ -82,7 +76,7 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
expression.transformChildrenVoid(this)
- val implicitThisClass = expression.symbol.classForImplicitThis
+ val implicitThisClass = expression.target.classForImplicitThis
if (implicitThisClass == null || implicitThisClass == irClass) return expression
val startOffset = expression.startOffset
@@ -91,7 +85,7 @@
val function = currentFunction?.irElement as? IrFunction
val enclosingThisReceiver = function?.dispatchReceiverParameter ?: irClass.thisReceiver!!
- var irThis: IrExpression = IrGetValueImpl(startOffset, endOffset, enclosingThisReceiver.symbol, origin)
+ var irThis: IrExpression = IrGetValueImpl(startOffset, endOffset, enclosingThisReceiver, origin)
var innerClass = irClass
while (innerClass != implicitThisClass) {
if (!innerClass.isInner) {
@@ -103,10 +97,10 @@
irThis = if (function is IrConstructor && irClass == innerClass) {
// Might be before a super() call (e.g. an argument to one), in which case the JVM bytecode verifier will reject
// an attempt to access the field. Good thing we have a local variable as well.
- IrGetValueImpl(startOffset, endOffset, function.valueParameters[0].symbol, origin)
+ IrGetValueImpl(startOffset, endOffset, function.valueParameters[0], origin)
} else {
val outerThisField = context.declarationFactory.getOuterThisField(innerClass)
- IrGetFieldImpl(startOffset, endOffset, outerThisField.symbol, outerThisField.type, irThis, origin)
+ IrGetFieldImpl(startOffset, endOffset, outerThisField, outerThisField.type, irThis, origin)
}
innerClass = innerClass.parentAsClass
}
@@ -129,13 +123,13 @@
expression.transformChildrenVoid(this)
val dispatchReceiver = expression.dispatchReceiver ?: return expression
- val callee = expression.symbol
- val parent = callee.owner.parentAsClass
+ val callee = expression.target
+ val parent = callee.parentAsClass
if (!parent.isInner) return expression
- val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(callee.owner)
+ val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(callee)
val newCall = IrConstructorCallImpl.fromSymbolOwner(
- expression.startOffset, expression.endOffset, expression.type, newCallee.symbol, expression.origin
+ expression.startOffset, expression.endOffset, expression.type, newCallee, expression.origin
)
newCall.copyTypeArgumentsFrom(expression)
@@ -151,12 +145,12 @@
expression.transformChildrenVoid(this)
val dispatchReceiver = expression.dispatchReceiver ?: return expression
- val classConstructor = expression.symbol.owner
+ val classConstructor = expression.target
if (!classConstructor.parentAsClass.isInner) return expression
val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(classConstructor)
val newCall = IrDelegatingConstructorCallImpl(
- expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee.symbol, newCallee.descriptor,
+ expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee, newCallee.descriptor,
expression.typeArgumentsCount
).apply { copyTypeArgumentsFrom(expression) }
@@ -171,18 +165,18 @@
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
expression.transformChildrenVoid(this)
- val callee = expression.symbol as? IrConstructorSymbol ?: return expression
- val parent = callee.owner.parent as? IrClass ?: return expression
+ val callee = expression.target as? IrConstructor ?: return expression
+ val parent = callee.parent as? IrClass ?: return expression
if (!parent.isInner) return expression
- val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(callee.owner)
+ val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(callee)
val newReference = expression.run {
IrFunctionReferenceImpl(
startOffset,
endOffset,
type,
- newCallee.symbol,
+ newCallee,
newCallee.descriptor,
typeArgumentsCount,
origin
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/KCallableNamePropertyLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/KCallableNamePropertyLowering.kt
index 3a03b15..32a7363 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/KCallableNamePropertyLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/KCallableNamePropertyLowering.kt
@@ -51,7 +51,7 @@
val callableReference = expression.dispatchReceiver as? IrCallableReference ?: return expression
//TODO rewrite checking
- val directMember = expression.symbol.owner.let {
+ val directMember = expression.target.let {
(it as? IrSimpleFunction)?.correspondingPropertySymbol?.owner ?: it
}
val irClass = directMember.parent as? IrClass ?: return expression
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt
index 70cbe59..810c7b4 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt
@@ -96,7 +96,7 @@
assert(!type.isPrimitiveType()) { "'lateinit' modifier is not allowed on primitive types" }
val startOffset = getter.startOffset
val endOffset = getter.endOffset
- val irBuilder = context.createIrBuilder(getter.symbol, startOffset, endOffset)
+ val irBuilder = context.createIrBuilder(getter, startOffset, endOffset)
irBuilder.run {
val body = IrBlockBodyImpl(startOffset, endOffset)
val resultVar = scope.createTemporaryVariable(
@@ -119,10 +119,10 @@
// Transform usages
irFile.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetValue(expression: IrGetValue): IrExpression {
- val irVar = nullableVariables[expression.symbol.owner] ?: return expression
+ val irVar = nullableVariables[expression.target] ?: return expression
val parent = irVar.parent as IrSymbolOwner
- val irBuilder = context.createIrBuilder(parent.symbol, expression.startOffset, expression.endOffset)
+ val irBuilder = context.createIrBuilder(parent, expression.startOffset, expression.endOffset)
return irBuilder.run {
irIfThenElse(
@@ -135,38 +135,38 @@
override fun visitSetVariable(expression: IrSetVariable): IrExpression {
expression.transformChildrenVoid(this)
- val newVar = nullableVariables[expression.symbol.owner] ?: return expression
+ val newVar = nullableVariables[expression.target] ?: return expression
return with(expression) {
- IrSetVariableImpl(startOffset, endOffset, type, newVar.symbol, value, origin)
+ IrSetVariableImpl(startOffset, endOffset, type, newVar, value, origin)
}
}
override fun visitGetField(expression: IrGetField): IrExpression {
expression.transformChildrenVoid(this)
- val newField = nullableFields[expression.symbol.owner] ?: return expression
+ val newField = nullableFields[expression.target] ?: return expression
return with(expression) {
- IrGetFieldImpl(startOffset, endOffset, newField.symbol, newField.type, receiver, origin, superQualifierSymbol)
+ IrGetFieldImpl(startOffset, endOffset, newField, newField.type, receiver, origin, irSuperQualifier)
}
}
override fun visitSetField(expression: IrSetField): IrExpression {
expression.transformChildrenVoid(this)
- val newField = nullableFields[expression.symbol.owner] ?: return expression
+ val newField = nullableFields[expression.target] ?: return expression
return with(expression) {
- IrSetFieldImpl(startOffset, endOffset, newField.symbol, receiver, value, type, origin, superQualifierSymbol)
+ IrSetFieldImpl(startOffset, endOffset, newField, receiver, value, type, origin, irSuperQualifier)
}
}
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid(this)
- if (!Symbols.isLateinitIsInitializedPropertyGetter(expression.symbol)) return expression
+ if (!Symbols.isLateinitIsInitializedPropertyGetter(expression.target)) return expression
val receiver = expression.extensionReceiver as IrPropertyReference
- val property = receiver.getter?.owner?.resolveFakeOverride()?.correspondingProperty!!.also { assert(it.isLateinit) }
+ val property = receiver.getter?.resolveFakeOverride()?.correspondingProperty!!.also { assert(it.isLateinit) }
- return expression.run { context.createIrBuilder(symbol, startOffset, endOffset) }.run {
+ return expression.run { context.createIrBuilder(target, startOffset, endOffset) }.run {
irNotEquals(irGetField(receiver.dispatchReceiver, property.backingField!!), irNull())
}
}
@@ -186,5 +186,5 @@
)
}
- private val throwErrorFunction by lazy { context.ir.symbols.ThrowUninitializedPropertyAccessException.owner }
+ private val throwErrorFunction by lazy { context.ir.symbols.ThrowUninitializedPropertyAccessException }
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt
index ec2e30e..d2a57c4 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt
@@ -25,7 +25,6 @@
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
@@ -105,7 +104,7 @@
override fun irGet(startOffset: Int, endOffset: Int, valueDeclaration: IrValueDeclaration): IrExpression? {
val parameter = capturedValueToParameter[valueDeclaration] ?: return null
- return IrGetValueImpl(startOffset, endOffset, parameter.type, parameter.symbol)
+ return IrGetValueImpl(startOffset, endOffset, parameter.type, parameter)
}
}
@@ -137,8 +136,8 @@
val receiver = declaration.thisReceiver!!
return IrGetFieldImpl(
- startOffset, endOffset, field.symbol, field.type,
- receiver = IrGetValueImpl(startOffset, endOffset, receiver.type, receiver.symbol)
+ startOffset, endOffset, field, field.type,
+ receiver = IrGetValueImpl(startOffset, endOffset, receiver.type, receiver)
)
}
}
@@ -149,8 +148,8 @@
val receiver = member.dispatchReceiverParameter!!
return IrGetFieldImpl(
- startOffset, endOffset, field.symbol, field.type,
- receiver = IrGetValueImpl(startOffset, endOffset, receiver.type, receiver.symbol)
+ startOffset, endOffset, field, field.type,
+ receiver = IrGetValueImpl(startOffset, endOffset, receiver.type, receiver)
)
}
@@ -168,7 +167,7 @@
val newParameterToOld: MutableMap<IrValueParameter, IrValueParameter> = mutableMapOf()
val oldParameterToNew: MutableMap<IrValueParameter, IrValueParameter> = mutableMapOf()
- val newParameterToCaptured: MutableMap<IrValueParameter, IrValueSymbol> = mutableMapOf()
+ val newParameterToCaptured: MutableMap<IrValueParameter, IrValueDeclaration> = mutableMapOf()
fun lowerLocalDeclarations() {
collectLocalDeclarations()
@@ -242,14 +241,14 @@
}
override fun visitGetValue(expression: IrGetValue): IrExpression {
- val declaration = expression.symbol.owner
+ val declaration = expression.target
localContext?.irGet(expression.startOffset, expression.endOffset, declaration)?.let {
return it
}
oldParameterToNew[declaration]?.let {
- return IrGetValueImpl(expression.startOffset, expression.endOffset, it.type, it.symbol)
+ return IrGetValueImpl(expression.startOffset, expression.endOffset, it.type, it)
}
return expression
@@ -258,7 +257,7 @@
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid(this)
- val oldCallee = expression.symbol.owner
+ val oldCallee = expression.target
val newCallee = (oldCallee.transformed ?: return expression) as IrSimpleFunction
return createNewCall(expression, newCallee).fillArguments2(expression, newCallee)
@@ -267,7 +266,7 @@
override fun visitConstructorCall(expression: IrConstructorCall): IrExpression {
expression.transformChildrenVoid(this)
- val oldCallee = expression.symbol.owner
+ val oldCallee = expression.target
val newCallee = (oldCallee.transformed ?: return expression) as IrConstructor
return createNewCall(expression, newCallee).fillArguments2(expression, newCallee)
@@ -276,13 +275,13 @@
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
expression.transformChildrenVoid(this)
- val oldCallee = expression.symbol.owner
+ val oldCallee = expression.target
val newCallee = transformedDeclarations[oldCallee] as IrConstructor? ?: return expression
return IrDelegatingConstructorCallImpl(
expression.startOffset, expression.endOffset,
context.irBuiltIns.unitType,
- newCallee.symbol,
+ newCallee,
newCallee.descriptor,
expression.typeArgumentsCount
).also {
@@ -310,16 +309,14 @@
oldExpression.getValueArgument(oldParameter.index)
} else {
// The callee expects captured value as argument.
- val capturedValueSymbol =
+ val capturedValue =
newParameterToCaptured[newValueParameterDeclaration]
?: throw AssertionError("Non-mapped parameter $newValueParameterDeclaration")
- val capturedValue = capturedValueSymbol.owner
-
localContext?.irGet(oldExpression.startOffset, oldExpression.endOffset, capturedValue) ?: run {
// Captured value is directly available for the caller.
val value = oldParameterToNew[capturedValue] ?: capturedValue
- IrGetValueImpl(oldExpression.startOffset, oldExpression.endOffset, value.symbol)
+ IrGetValueImpl(oldExpression.startOffset, oldExpression.endOffset, value)
}
}
@@ -334,13 +331,13 @@
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
expression.transformChildrenVoid(this)
- val oldCallee = expression.symbol.owner
+ val oldCallee = expression.target
val newCallee = oldCallee.transformed ?: return expression
return IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset,
expression.type, // TODO functional type for transformed descriptor
- newCallee.symbol,
+ newCallee,
newCallee.descriptor,
expression.typeArgumentsCount,
expression.origin
@@ -354,18 +351,18 @@
override fun visitReturn(expression: IrReturn): IrExpression {
expression.transformChildrenVoid(this)
- val oldReturnTarget = expression.returnTargetSymbol.owner as? IrFunction ?: return expression
+ val oldReturnTarget = expression.irReturnTarget as? IrFunction ?: return expression
val newReturnTarget = oldReturnTarget.transformed ?: return expression
return IrReturnImpl(
expression.startOffset, expression.endOffset,
context.irBuiltIns.nothingType,
- newReturnTarget.symbol, expression.value
+ newReturnTarget, expression.value
)
}
override fun visitDeclarationReference(expression: IrDeclarationReference): IrExpression {
- if (expression.symbol.owner in transformedDeclarations) {
+ if (expression.target in transformedDeclarations) {
TODO()
}
return super.visitDeclarationReference(expression)
@@ -408,8 +405,8 @@
0,
localClassContext.capturedValueToField.map { (capturedValue, field) ->
IrSetFieldImpl(
- irClass.startOffset, irClass.endOffset, field.symbol,
- IrGetValueImpl(irClass.startOffset, irClass.endOffset, irClass.thisReceiver!!.symbol),
+ irClass.startOffset, irClass.endOffset, field,
+ IrGetValueImpl(irClass.startOffset, irClass.endOffset, irClass.thisReceiver!!),
constructorContext.irGet(irClass.startOffset, irClass.endOffset, capturedValue)!!,
context.irBuiltIns.unitType,
STATEMENT_ORIGIN_INITIALIZER_OF_FIELD_FOR_CAPTURED_VALUE
@@ -439,10 +436,10 @@
IrCallImpl(
oldCall.startOffset, oldCall.endOffset,
newCallee.returnType,
- newCallee.symbol,
+ newCallee,
newCallee.descriptor,
oldCall.typeArgumentsCount,
- oldCall.origin, oldCall.superQualifierSymbol
+ oldCall.origin, oldCall.irSuperQualifier
).also {
it.copyTypeArgumentsFrom(oldCall)
}
@@ -451,7 +448,7 @@
IrConstructorCallImpl.fromSymbolOwner(
oldCall.startOffset, oldCall.endOffset,
newCallee.returnType,
- newCallee.symbol,
+ newCallee,
oldCall.origin
).also {
it.copyTypeArgumentsFrom(oldCall)
@@ -545,13 +542,12 @@
}
private fun createTransformedValueParameters(
- capturedValues: List<IrValueSymbol>,
+ capturedValues: List<IrValueDeclaration>,
oldDeclaration: IrFunction,
newDeclaration: IrFunction
) = ArrayList<IrValueParameter>(capturedValues.size + oldDeclaration.valueParameters.size).apply {
- capturedValues.mapIndexedTo(this) { i, capturedValue ->
+ capturedValues.mapIndexedTo(this) { i, p ->
val parameterDescriptor = WrappedValueParameterDescriptor()
- val p = capturedValue.owner
IrValueParameterImpl(
p.startOffset,
p.endOffset,
@@ -567,7 +563,7 @@
).also {
parameterDescriptor.bind(it)
it.parent = newDeclaration
- newParameterToCaptured[it] = capturedValue
+ newParameterToCaptured[it] = p
}
}
@@ -583,7 +579,7 @@
valueParameters.forEach {
val capturedValue = newParameterToCaptured[it]
if (capturedValue != null) {
- localContext.capturedValueToParameter[capturedValue.owner] = it
+ localContext.capturedValueToParameter[capturedValue] = it
}
}
@@ -671,13 +667,13 @@
val irField = createFieldForCapturedValue(
classDeclaration.startOffset,
classDeclaration.endOffset,
- suggestNameForCapturedValue(capturedValue.owner),
+ suggestNameForCapturedValue(capturedValue),
Visibilities.PRIVATE,
classDeclaration,
- capturedValue.owner.type
+ capturedValue.type
)
- localClassContext.capturedValueToField[capturedValue.owner] = irField
+ localClassContext.capturedValueToField[capturedValue] = irField
}
}
@@ -723,7 +719,7 @@
}
override fun createScope(declaration: IrSymbolOwner): ScopeWithIr {
- return ScopeWithCounter(Scope(declaration.symbol), declaration)
+ return ScopeWithCounter(Scope(declaration), declaration)
}
override fun visitSimpleFunction(declaration: IrSimpleFunction) {
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt
index 49cbbdf..f5b4e40 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt
@@ -28,7 +28,6 @@
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classifierOrFail
@@ -43,11 +42,11 @@
class DeclarationIrBuilder(
backendContext: BackendContext,
- symbol: IrSymbol,
+ target: IrSymbolOwner,
startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET
) : IrBuilderWithScope(
IrLoweringContext(backendContext),
- Scope(symbol),
+ Scope(target),
startOffset,
endOffset
)
@@ -56,8 +55,8 @@
protected abstract fun remapVariable(value: IrValueDeclaration): IrValueDeclaration?
override fun visitGetValue(expression: IrGetValue): IrExpression =
- remapVariable(expression.symbol.owner)?.let {
- IrGetValueImpl(expression.startOffset, expression.endOffset, it.type, it.symbol, expression.origin)
+ remapVariable(expression.target)?.let {
+ IrGetValueImpl(expression.startOffset, expression.endOffset, it.type, it, expression.origin)
} ?: expression
}
@@ -72,11 +71,11 @@
}
fun BackendContext.createIrBuilder(
- symbol: IrSymbol,
+ target: IrSymbolOwner,
startOffset: Int = UNDEFINED_OFFSET,
endOffset: Int = UNDEFINED_OFFSET
) =
- DeclarationIrBuilder(this, symbol, startOffset, endOffset)
+ DeclarationIrBuilder(this, target, startOffset, endOffset)
fun <T : IrBuilder> T.at(element: IrElement) = this.at(element.startOffset, element.endOffset)
@@ -131,9 +130,9 @@
protected val builder: IrBuilderWithScope
get() = currentBuilder!!
- private inline fun <T> withBuilder(symbol: IrSymbol, block: () -> T): T {
+ private inline fun <T> withBuilder(owner: IrSymbolOwner, block: () -> T): T {
val oldBuilder = currentBuilder
- currentBuilder = context.createIrBuilder(symbol)
+ currentBuilder = context.createIrBuilder(owner)
return try {
block()
} finally {
@@ -142,20 +141,20 @@
}
override fun visitFunction(declaration: IrFunction): IrStatement {
- withBuilder(declaration.symbol) {
+ withBuilder(declaration) {
return super.visitFunction(declaration)
}
}
override fun visitField(declaration: IrField): IrStatement {
- withBuilder(declaration.symbol) {
+ withBuilder(declaration) {
// Transforms initializer:
return super.visitField(declaration)
}
}
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer): IrStatement {
- withBuilder(declaration.symbol) {
+ withBuilder(declaration) {
return super.visitAnonymousInitializer(declaration)
}
}
@@ -180,7 +179,7 @@
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall) {
assert(++numberOfCalls == 1) { "More than one delegating constructor call: ${symbol.owner}" }
- val delegatingClass = expression.symbol.owner.parent as IrClass
+ val delegatingClass = expression.target.parent as IrClass
// TODO: figure out why Lazy IR multiplies Declarations for descriptors and fix it
// It happens because of IrBuiltIns whose IrDeclarations are different for runtime and test
if (delegatingClass.descriptor == superClass.classifierOrFail.descriptor)
@@ -228,12 +227,12 @@
) : IrElementTransformer<Nothing?> {
override fun visitGetValue(expression: IrGetValue, data: Nothing?): IrExpression {
val irGetValue = expression
- if (irGetValue.symbol == oldThisReceiverParameter.symbol) {
+ if (irGetValue.target == oldThisReceiverParameter) {
val instanceField = context.declarationFactory.getFieldForObjectInstance(irClass)
return IrGetFieldImpl(
expression.startOffset,
expression.endOffset,
- instanceField.symbol,
+ instanceField,
irClass.defaultType
)
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt
index e7ab960..11f7026 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt
@@ -37,7 +37,7 @@
function,
IrFunctionReferenceImpl(
startOffset, endOffset, type,
- function.symbol, function.descriptor, 0,
+ function, function.descriptor, 0,
origin
)
)
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt
index 5bbdede..6de6ebe 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt
@@ -20,7 +20,6 @@
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrDoWhileLoopImpl
-import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
/**
* Replaces returnable blocks and `return`'s with loops and `break`'s correspondingly.
@@ -77,17 +76,17 @@
private class ReturnableBlockTransformer(val context: CommonBackendContext) : IrElementTransformerVoidWithContext() {
private var labelCnt = 0
- private val returnMap = mutableMapOf<IrReturnableBlockSymbol, (IrReturn) -> IrExpression>()
+ private val returnMap = mutableMapOf<IrReturnableBlock, (IrReturn) -> IrExpression>()
override fun visitReturn(expression: IrReturn): IrExpression {
expression.transformChildrenVoid()
- return returnMap[expression.returnTargetSymbol]?.invoke(expression) ?: expression
+ return returnMap[expression.irReturnTarget]?.invoke(expression) ?: expression
}
override fun visitContainerExpression(expression: IrContainerExpression): IrExpression {
if (expression !is IrReturnableBlock) return super.visitContainerExpression(expression)
- val builder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol)
+ val builder = context.createIrBuilder(currentScope!!.scope.irScopeOwner)
val variable by lazy {
builder.scope.createTemporaryVariableDeclaration(expression.type, "tmp\$ret\$${labelCnt++}", true)
}
@@ -106,26 +105,26 @@
var hasReturned = false
- returnMap[expression.symbol] = { returnExpression ->
+ returnMap[expression] = { returnExpression ->
hasReturned = true
builder.irComposite(returnExpression) {
- +irSetVar(variable.symbol, returnExpression.value)
+ +irSetVar(variable, returnExpression.value)
+irBreak(loop)
}
}
val newStatements = expression.statements.mapIndexed { i, s ->
- if (i == expression.statements.lastIndex && s is IrReturn && s.returnTargetSymbol == expression.symbol) {
+ if (i == expression.statements.lastIndex && s is IrReturn && s.irReturnTarget == expression) {
s.transformChildrenVoid()
if (!hasReturned) s.value else {
- builder.irSetVar(variable.symbol, s.value)
+ builder.irSetVar(variable, s.value)
}
} else {
s.transform(this, null)
}
}
- returnMap.remove(expression.symbol)
+ returnMap.remove(expression)
if (!hasReturned) {
return IrCompositeImpl(
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SharedVariablesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SharedVariablesLowering.kt
index 1f5d54c..105bf1d 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SharedVariablesLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SharedVariablesLowering.kt
@@ -23,8 +23,6 @@
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.visitors.*
import java.util.*
@@ -108,7 +106,7 @@
override fun visitValueAccess(expression: IrValueAccessExpression, data: IrDeclarationParent?) {
expression.acceptChildren(this, data)
- val value = expression.symbol.owner
+ val value = expression.target
if (value in relevantVars && (value as IrVariable).parent != data) {
sharedVariables.add(value)
}
@@ -117,7 +115,7 @@
}
private fun rewriteSharedVariables() {
- val transformedSymbols = HashMap<IrValueSymbol, IrVariableSymbol>()
+ val transformed = HashMap<IrValueDeclaration, IrVariable>()
irDeclaration.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitVariable(declaration: IrVariable): IrStatement {
@@ -127,7 +125,7 @@
val newDeclaration = context.sharedVariablesManager.declareSharedVariable(declaration)
newDeclaration.parent = declaration.parent
- transformedSymbols[declaration.symbol] = newDeclaration.symbol
+ transformed[declaration] = newDeclaration
return context.sharedVariablesManager.defineSharedValue(declaration, newDeclaration)
}
@@ -137,7 +135,7 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
expression.transformChildrenVoid(this)
- val newDeclaration = getTransformedSymbol(expression.symbol) ?: return expression
+ val newDeclaration = getTransformedSymbol(expression.target) ?: return expression
return context.sharedVariablesManager.getSharedValue(newDeclaration, expression)
}
@@ -145,15 +143,15 @@
override fun visitSetVariable(expression: IrSetVariable): IrExpression {
expression.transformChildrenVoid(this)
- val newDeclaration = getTransformedSymbol(expression.symbol) ?: return expression
+ val newDeclaration = getTransformedSymbol(expression.target) ?: return expression
return context.sharedVariablesManager.setSharedValue(newDeclaration, expression)
}
- private fun getTransformedSymbol(oldSymbol: IrValueSymbol): IrVariableSymbol? =
- transformedSymbols.getOrElse(oldSymbol) {
- assert(oldSymbol.owner !in sharedVariables) {
- "Shared variable is not transformed: ${oldSymbol.owner.dump()}"
+ private fun getTransformedSymbol(old: IrValueDeclaration): IrVariable? =
+ transformed.getOrElse(old) {
+ assert(old !in sharedVariables) {
+ "Shared variable is not transformed: ${old.dump()}"
}
null
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SpecialBridgeMethods.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SpecialBridgeMethods.kt
index 5cc6155..ef58810 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SpecialBridgeMethods.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SpecialBridgeMethods.kt
@@ -46,7 +46,7 @@
IrConstImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.intType, IrConstKind.Int, -1)
private fun getSecondArg(bridge: IrSimpleFunction) =
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, bridge.valueParameters[1].symbol)
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, bridge.valueParameters[1])
private val SPECIAL_METHODS_WITH_DEFAULTS_MAP = mapOf<SpecialMethodDescription, (IrSimpleFunction) -> IrExpression>(
makeDescription("kotlin.collections.Collection", "contains", 1) to ::constFalse,
@@ -80,7 +80,7 @@
return sequence {
yield(this@search)
visited.add(this@search)
- overriddenSymbols.forEach { yieldAll(it.owner.search()) }
+ overridden.forEach { yieldAll(it.search()) }
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/StringConcatenationLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/StringConcatenationLowering.kt
index 39959aa..fdaf67c 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/StringConcatenationLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/StringConcatenationLowering.kt
@@ -58,7 +58,7 @@
private val nameToString = Name.identifier("toString")
private val nameAppend = Name.identifier("append")
- private val stringBuilder = context.ir.symbols.stringBuilder.owner
+ private val stringBuilder = context.ir.symbols.stringBuilder
//TODO: calculate and pass string length to the constructor.
private val constructor = stringBuilder.constructors.single {
@@ -113,7 +113,7 @@
with(declaration) {
buildersStack.add(
- context.createIrBuilder(declaration.symbol, startOffset, endOffset)
+ context.createIrBuilder(declaration, startOffset, endOffset)
)
transformChildrenVoid(this@StringConcatenationTransformer)
buildersStack.removeAt(buildersStack.lastIndex)
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/TailrecLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/TailrecLowering.kt
index 5ed6571..a3d1f95 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/TailrecLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/TailrecLowering.kt
@@ -22,7 +22,6 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
-import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
import org.jetbrains.kotlin.ir.util.explicitParameters
import org.jetbrains.kotlin.ir.util.getArgumentsWithIr
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
@@ -53,14 +52,14 @@
}
val oldBody = irFunction.body as IrBlockBody
- val builder = context.createIrBuilder(irFunction.symbol).at(oldBody)
+ val builder = context.createIrBuilder(irFunction).at(oldBody)
val parameters = irFunction.explicitParameters
irFunction.body = builder.irBlockBody {
// Define variables containing current values of parameters:
val parameterToVariable = parameters.associate {
- it to createTmpVariable(irGet(it), nameHint = it.symbol.suggestVariableName(), isMutable = true)
+ it to createTmpVariable(irGet(it), nameHint = it.suggestVariableName(), isMutable = true)
}
// (these variables are to be updated on any tail call).
@@ -72,7 +71,7 @@
// Read variables containing current values of parameters:
val parameterToNew = parameters.associate {
val variable = parameterToVariable[it]!!
- it to createTmpVariable(irGet(variable), nameHint = it.symbol.suggestVariableName())
+ it to createTmpVariable(irGet(variable), nameHint = it.suggestVariableName())
}
val transformer = BodyTransformer(
@@ -103,7 +102,7 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
expression.transformChildrenVoid(this)
- val value = parameterToNew[expression.symbol.owner] ?: return expression
+ val value = parameterToNew[expression.target] ?: return expression
return builder.at(expression).irGet(value)
}
@@ -127,7 +126,7 @@
at(argument)
// Note that argument can use values of parameters, so it is important that
// references to parameters are mapped using `parameterToNew`, not `parameterToVariable`.
- +irSetVar(parameterToVariable[parameter]!!.symbol, argument)
+ +irSetVar(parameterToVariable[parameter]!!, argument)
}
val specifiedParameters = parameterToArgument.map { (parameter, _) -> parameter }.toSet()
@@ -145,15 +144,15 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
expression.transformChildrenVoid(this)
- val variable = parameterToVariable[expression.symbol.owner] ?: return expression
+ val variable = parameterToVariable[expression.target] ?: return expression
return IrGetValueImpl(
expression.startOffset, expression.endOffset, variable.type,
- variable.symbol, expression.origin
+ variable, expression.origin
)
}
}, data = null)
- +irSetVar(parameterToVariable[parameter]!!.symbol, defaultValue)
+ +irSetVar(parameterToVariable[parameter]!!, defaultValue)
}
// Jump to the entry:
@@ -161,10 +160,10 @@
}
}
-private fun IrValueParameterSymbol.suggestVariableName(): String =
- if (owner.name.isSpecial) {
- val oldNameStr = owner.name.asString()
+private fun IrValueParameter.suggestVariableName(): String =
+ if (name.isSpecial) {
+ val oldNameStr = name.asString()
"$" + oldNameStr.substring(1, oldNameStr.length - 1)
} else {
- owner.name.identifier
+ name.identifier
}
\ No newline at end of file
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt
index ade9927..4b01c5d 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt
@@ -20,9 +20,6 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrReturnableBlockSymbolImpl
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.isNullable
@@ -39,18 +36,18 @@
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
expression.transformChildrenVoid(this)
val callee = when (expression) {
- is IrCall -> expression.symbol.owner
- is IrConstructorCall -> expression.symbol.owner
+ is IrCall -> expression.target
+ is IrConstructorCall -> expression.target
else -> return expression
}
if (!callee.needsInlining)
return expression
- if (Symbols.isLateinitIsInitializedPropertyGetter(callee.symbol))
+ if (Symbols.isLateinitIsInitializedPropertyGetter(callee))
return expression
- if (Symbols.isTypeOfIntrinsic(callee.symbol))
+ if (Symbols.isTypeOfIntrinsic(callee))
return expression
- val actualCallee = getFunctionDeclaration(callee.symbol)
+ val actualCallee = getFunctionDeclaration(callee)
val parent = allScopes.map { it.irElement }.filterIsInstance<IrDeclarationParent>().lastOrNull()
@@ -58,8 +55,8 @@
return inliner.inline()
}
- private fun getFunctionDeclaration(symbol: IrFunctionSymbol): IrFunction {
- val descriptor = symbol.descriptor.original
+ private fun getFunctionDeclaration(function: IrFunction): IrFunction {
+ val descriptor = function.descriptor.original
val languageVersionSettings = context.configuration.languageVersionSettings
// TODO: Remove these hacks when coroutine intrinsics are fixed.
return when {
@@ -67,12 +64,12 @@
error("Continuation.intercepted is not available with release coroutines")
descriptor.isBuiltInSuspendCoroutineUninterceptedOrReturn(languageVersionSettings) ->
- context.ir.symbols.suspendCoroutineUninterceptedOrReturn.owner
+ context.ir.symbols.suspendCoroutineUninterceptedOrReturn
- symbol == context.ir.symbols.coroutineContextGetter ->
- context.ir.symbols.coroutineGetContext.owner
+ function == context.ir.symbols.coroutineContextGetter ->
+ context.ir.symbols.coroutineGetContext
- else -> (symbol.owner as? IrSimpleFunction)?.resolveFakeOverride() ?: symbol.owner
+ else -> (function as? IrSimpleFunction)?.resolveFakeOverride() ?: function
}
}
@@ -127,10 +124,6 @@
val irReturnableBlockSymbol = IrReturnableBlockSymbolImpl(copiedCallee.descriptor.original)
val endOffset = callee.endOffset
- /* creates irBuilder appending to the end of the given returnable block: thus why we initialize
- * irBuilder with (..., endOffset, endOffset).
- */
- val irBuilder = context.createIrBuilder(irReturnableBlockSymbol, endOffset, endOffset)
val transformer = ParameterSubstitutor()
statements.transform { it.transform(transformer, data = null) }
@@ -147,13 +140,17 @@
symbol = irReturnableBlockSymbol,
origin = if (isCoroutineIntrinsicCall) CoroutineIntrinsicLambdaOrigin else null,
statements = statements,
- inlineFunctionSymbol = callee.symbol
+ inlineFunction = callee
).apply {
+ /* creates irBuilder appending to the end of the given returnable block: thus why we initialize
+ * irBuilder with (..., endOffset, endOffset).
+ */
+ val irBuilder = context.createIrBuilder(this, endOffset, endOffset)
transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitReturn(expression: IrReturn): IrExpression {
expression.transformChildrenVoid(this)
- if (expression.returnTargetSymbol == copiedCallee.symbol)
+ if (expression.irReturnTarget == copiedCallee)
return irBuilder.irReturn(expression.value)
return expression
}
@@ -168,7 +165,7 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
val newExpression = super.visitGetValue(expression) as IrGetValue
- val argument = substituteMap[newExpression.symbol.owner] ?: return newExpression
+ val argument = substituteMap[newExpression.target] ?: return newExpression
argument.transformChildrenVoid(this) // Default argument can contain subjects for substitution.
@@ -184,14 +181,14 @@
return super.visitCall(expression)
val dispatchReceiver = expression.dispatchReceiver as IrGetValue
- val functionArgument = substituteMap[dispatchReceiver.symbol.owner] ?: return super.visitCall(expression)
- if ((dispatchReceiver.symbol.owner as? IrValueParameter)?.isNoinline == true)
+ val functionArgument = substituteMap[dispatchReceiver.target] ?: return super.visitCall(expression)
+ if ((dispatchReceiver.target as? IrValueParameter)?.isNoinline == true)
return super.visitCall(expression)
if (functionArgument is IrFunctionReference) {
functionArgument.transformChildrenVoid(this)
- val function = functionArgument.symbol.owner
+ val function = functionArgument.target
val functionParameters = function.explicitParameters
val boundFunctionParameters = functionArgument.getArgumentsWithIr()
val unboundFunctionParameters = functionParameters - boundFunctionParameters.map { it.first }
@@ -203,9 +200,9 @@
val immediateCall = with(expression) {
if (function is IrConstructor)
- IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, function.returnType, function.symbol)
+ IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, function.returnType, function)
else
- IrCallImpl(startOffset, endOffset, function.returnType, functionArgument.symbol)
+ IrCallImpl(startOffset, endOffset, function.returnType, functionArgument.target)
}.apply {
functionParameters.forEach {
val argument =
@@ -264,7 +261,7 @@
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.IMPLICIT_CAST, type, this)
private fun isLambdaCall(irCall: IrCall): Boolean {
- val callee = irCall.symbol.owner
+ val callee = irCall.target
val dispatchReceiver = callee.dispatchReceiverParameter ?: return false
assert(!dispatchReceiver.type.isKFunction())
@@ -290,11 +287,11 @@
val isImmutableVariableLoad: Boolean
get() = argumentExpression.let {
- it is IrGetValue && !it.symbol.owner.let { it is IrVariable && it.isVar }
+ it is IrGetValue && !it.target.let { it is IrVariable && it.isVar }
}
}
- // callee might be a copied version of callsite.symbol.owner
+ // callee might be a copied version of callsite
private fun buildParameterToArgument(callSite: IrFunctionAccessExpression, callee: IrFunction): List<ParameterToArgument> {
val parameterToArgument = mutableListOf<ParameterToArgument>()
@@ -306,7 +303,7 @@
)
val valueArguments =
- callSite.symbol.owner.valueParameters.map { callSite.getValueArgument(it.index) }.toMutableList()
+ callSite.target.valueParameters.map { callSite.getValueArgument(it.index) }.toMutableList()
if (callee.extensionReceiverParameter != null) {
parameterToArgument += ParameterToArgument(
@@ -374,7 +371,7 @@
val arguments = functionReference.getArgumentsWithIr().map { ParameterToArgument(it.first, it.second) }
val evaluationStatements = mutableListOf<IrStatement>()
val substitutor = ParameterSubstitutor()
- val referenced = functionReference.symbol.owner
+ val referenced = functionReference.target
arguments.forEach {
val newArgument = if (it.isImmutableVariableLoad) {
it.argumentExpression.transform( // Arguments may reference the previous ones - substitute them.
@@ -388,13 +385,13 @@
substitutor,
data = null
),
- nameHint = callee.symbol.owner.name.toString(),
+ nameHint = callee.name.toString(),
isMutable = false
)
evaluationStatements.add(newVariable)
- IrGetValueWithoutLocation(newVariable.symbol)
+ IrGetValueWithoutLocation(newVariable)
}
when (it.parameter) {
referenced.dispatchReceiverParameter -> functionReference.dispatchReceiver = newArgument
@@ -436,27 +433,27 @@
irExpression = IrBlockImpl (variableInitializer.startOffset,
variableInitializer.endOffset,
variableInitializer.type,
- InlinerExpressionLocationHint((currentScope.irElement as IrSymbolOwner).symbol)).apply {
+ InlinerExpressionLocationHint(currentScope.irElement as IrSymbolOwner)).apply {
statements.add(variableInitializer)
},
- nameHint = callee.symbol.owner.name.toString(),
+ nameHint = callee.name.toString(),
isMutable = false
)
evaluationStatements.add(newVariable)
- substituteMap[it.parameter] = IrGetValueWithoutLocation(newVariable.symbol)
+ substituteMap[it.parameter] = IrGetValueWithoutLocation(newVariable)
}
return evaluationStatements
}
}
private class IrGetValueWithoutLocation(
- symbol: IrValueSymbol,
+ target: IrValueDeclaration,
override val origin: IrStatementOrigin? = null
- ) : IrTerminalDeclarationReferenceBase<IrValueSymbol, ValueDescriptor>(
+ ) : IrTerminalDeclarationReferenceBase<IrValueDeclaration, ValueDescriptor>(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- symbol.owner.type,
- symbol, symbol.descriptor
+ target.type,
+ target, target.descriptor
), IrGetValue {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D) =
visitor.visitGetValue(this, data)
@@ -466,16 +463,16 @@
}
fun withLocation(startOffset: Int, endOffset: Int) =
- IrGetValueImpl(startOffset, endOffset, type, symbol, origin)
+ IrGetValueImpl(startOffset, endOffset, type, target, origin)
}
}
-class InlinerExpressionLocationHint(val inlineAtSymbol: IrSymbol) : IrStatementOrigin {
+class InlinerExpressionLocationHint(val inlineAt: IrSymbolOwner) : IrStatementOrigin {
override fun toString(): String = "(${this.javaClass.simpleName} : $functionNameOrDefaultToString @${functionFileOrNull?.fileEntry?.name})"
private val functionFileOrNull: IrFile?
- get() = (inlineAtSymbol as? IrFunction)?.file
+ get() = (inlineAt as? IrFunction)?.file
private val functionNameOrDefaultToString: String
- get() = (inlineAtSymbol as? IrFunction)?.name?.asString() ?: inlineAtSymbol.toString()
+ get() = (inlineAt as? IrFunction)?.name?.asString() ?: inlineAt.toString()
}
\ No newline at end of file
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ForLoopsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ForLoopsLowering.kt
index 67986de..b34ae52 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ForLoopsLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ForLoopsLowering.kt
@@ -15,7 +15,6 @@
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
@@ -117,11 +116,11 @@
) : IrElementTransformerVoidWithContext() {
private val symbols = context.ir.symbols
- private val iteratorToLoopHeader = mutableMapOf<IrVariableSymbol, ForLoopHeader>()
- private val headerInfoBuilder = HeaderInfoBuilder(context, this::getScopeOwnerSymbol)
- private val headerProcessor = HeaderProcessor(context, headerInfoBuilder, this::getScopeOwnerSymbol)
+ private val iteratorToLoopHeader = mutableMapOf<IrVariable, ForLoopHeader>()
+ private val headerInfoBuilder = HeaderInfoBuilder(context, this::getScopeOwner)
+ private val headerProcessor = HeaderProcessor(context, headerInfoBuilder, this::getScopeOwner)
- fun getScopeOwnerSymbol() = currentScope!!.scope.scopeOwnerSymbol
+ fun getScopeOwner() = currentScope!!.scope.irScopeOwner
override fun visitVariable(declaration: IrVariable): IrStatement {
val initializer = declaration.initializer
@@ -145,10 +144,10 @@
* Returns null if the for-loop cannot be lowered.
*/
private fun processHeader(variable: IrVariable): IrStatement? {
- assert(variable.symbol !in iteratorToLoopHeader)
+ assert(variable !in iteratorToLoopHeader)
val forLoopInfo = headerProcessor.processHeader(variable)
?: return null // If the for-loop cannot be lowered.
- iteratorToLoopHeader[variable.symbol] = forLoopInfo
+ iteratorToLoopHeader[variable] = forLoopInfo
// Lower into a composite with additional declarations (e.g., induction variable)
// used in the loop condition and body.
@@ -166,7 +165,7 @@
return super.visitWhileLoop(loop)
}
- with(context.createIrBuilder(getScopeOwnerSymbol(), loop.startOffset, loop.endOffset)) {
+ with(context.createIrBuilder(getScopeOwner(), loop.startOffset, loop.endOffset)) {
// Visit the loop body to process the "next" statement and lower nested loops.
// Processing the "next" statement is necessary for building loops that need to
// reference the loop variable in the loop condition.
@@ -199,7 +198,7 @@
val iterator = expression.dispatchReceiver as IrGetValue
// Return null if we didn't lower the corresponding header.
- return iteratorToLoopHeader[iterator.symbol]
+ return iteratorToLoopHeader[iterator.target]
}
/**
@@ -224,7 +223,7 @@
// val i = initializeLoopVariable() // `inductionVariable` for progressions
// // `array[inductionVariable]` for arrays
// inductionVariable = inductionVariable + step
- return with(context.createIrBuilder(getScopeOwnerSymbol(), initializer.startOffset, initializer.endOffset)) {
+ return with(context.createIrBuilder(getScopeOwner(), initializer.startOffset, initializer.endOffset)) {
variable.initializer = forLoopInfo.initializeLoopVariable(symbols, this)
val increment = forLoopInfo.incrementInductionVariable(this)
IrCompositeImpl(
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderInfo.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderInfo.kt
index 762664a..3a9dca0 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderInfo.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderInfo.kt
@@ -9,11 +9,11 @@
import org.jetbrains.kotlin.backend.common.ir.Symbols
import org.jetbrains.kotlin.backend.common.lower.matchers.IrCallMatcher
import org.jetbrains.kotlin.ir.IrElement
+import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.isSubtypeOfClass
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -175,9 +175,9 @@
fun match(expression: E): Boolean
/** Builds a [HeaderInfo] from the expression. */
- fun build(expression: E, data: D, scopeOwner: IrSymbol): HeaderInfo?
+ fun build(expression: E, data: D, scopeOwner: IrSymbolOwner): HeaderInfo?
- fun handle(expression: E, data: D, scopeOwner: IrSymbol) = if (match(expression)) {
+ fun handle(expression: E, data: D, scopeOwner: IrSymbolOwner) = if (match(expression)) {
build(expression, data, scopeOwner)
} else {
null
@@ -185,8 +185,8 @@
}
internal interface ExpressionHandler : HeaderInfoHandler<IrExpression, Nothing?> {
- fun build(expression: IrExpression, scopeOwner: IrSymbol): HeaderInfo?
- override fun build(expression: IrExpression, data: Nothing?, scopeOwner: IrSymbol) = build(expression, scopeOwner)
+ fun build(expression: IrExpression, scopeOwner: IrSymbolOwner): HeaderInfo?
+ override fun build(expression: IrExpression, data: Nothing?, scopeOwner: IrSymbolOwner) = build(expression, scopeOwner)
}
/** Matches a call to build an iterable and builds a [HeaderInfo] from the call's context. */
@@ -198,7 +198,7 @@
internal typealias ProgressionHandler = HeaderInfoFromCallHandler<ProgressionType>
-internal class HeaderInfoBuilder(context: CommonBackendContext, private val scopeOwnerSymbol: () -> IrSymbol) :
+internal class HeaderInfoBuilder(context: CommonBackendContext, private val scopeOwner: () -> IrSymbolOwner) :
IrElementVisitor<HeaderInfo?, Nothing?> {
private val symbols = context.ir.symbols
@@ -233,21 +233,21 @@
/** Builds a [HeaderInfo] for iterable expressions that are calls (e.g., `.reversed()`, `.indices`. */
override fun visitCall(expression: IrCall, data: Nothing?): HeaderInfo? {
// Return the HeaderInfo from the first successful match. First, try to match a `reversed()` call.
- val reversedHeaderInfo = reversedHandler.handle(expression, null, scopeOwnerSymbol())
+ val reversedHeaderInfo = reversedHandler.handle(expression, null, scopeOwner())
if (reversedHeaderInfo != null)
return reversedHeaderInfo
// Try to match a call to build a progression (e.g., `.indices`, `downTo`).
val progressionType = ProgressionType.fromIrType(expression.type, symbols)
val progressionHeaderInfo =
- progressionType?.run { progressionHandlers.firstNotNullResult { it.handle(expression, this, scopeOwnerSymbol()) } }
+ progressionType?.run { progressionHandlers.firstNotNullResult { it.handle(expression, this, scopeOwner()) } }
return progressionHeaderInfo ?: super.visitCall(expression, data)
}
/** Builds a [HeaderInfo] for iterable expressions not handled in [visitCall]. */
override fun visitExpression(expression: IrExpression, data: Nothing?): HeaderInfo? {
- return expressionHandlers.firstNotNullResult { it.handle(expression, null, scopeOwnerSymbol()) }
+ return expressionHandlers.firstNotNullResult { it.handle(expression, null, scopeOwner()) }
?: super.visitExpression(expression, data)
}
}
\ No newline at end of file
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderProcessor.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderProcessor.kt
index 70ba88a..3d0fbbf 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderProcessor.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/HeaderProcessor.kt
@@ -14,13 +14,13 @@
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
+import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrLoop
import org.jetbrains.kotlin.ir.expressions.impl.IrDoWhileLoopImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrWhileLoopImpl
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.functions
import org.jetbrains.kotlin.ir.util.getPackageFragment
@@ -66,8 +66,8 @@
it.valueParameters[0].type == step.type
}
irSetVar(
- inductionVariable.symbol, irCallOp(
- plusFun.symbol, plusFun.returnType,
+ inductionVariable, irCallOp(
+ plusFun, plusFun.returnType,
irGet(inductionVariable),
irGet(step)
)
@@ -245,7 +245,7 @@
internal class HeaderProcessor(
private val context: CommonBackendContext,
private val headerInfoBuilder: HeaderInfoBuilder,
- private val scopeOwnerSymbol: () -> IrSymbol
+ private val scopeOwner: () -> IrSymbolOwner
) {
private val symbols = context.ir.symbols
@@ -274,7 +274,7 @@
val iterable = (variable.initializer as? IrCall)?.let {
val extensionReceiver = it.extensionReceiver
if (extensionReceiver != null) {
- val function = it.symbol.owner
+ val function = it.target
if (it.valueArgumentsCount == 0
&& function.isTopLevel
&& function.getPackageFragment()?.fqName == FqName("kotlin.text")
@@ -292,7 +292,7 @@
val headerInfo = iterable?.accept(headerInfoBuilder, null)
?: return null // If the iterable is not supported.
- val builder = context.createIrBuilder(scopeOwnerSymbol(), variable.startOffset, variable.endOffset)
+ val builder = context.createIrBuilder(scopeOwner(), variable.startOffset, variable.endOffset)
with(builder) builder@{
with(headerInfo) {
// For this loop:
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ProgressionHandlers.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ProgressionHandlers.kt
index 836e9a2..9b5cdee 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ProgressionHandlers.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/ProgressionHandlers.kt
@@ -12,12 +12,11 @@
import org.jetbrains.kotlin.backend.common.lower.matchers.createIrCallMatcher
import org.jetbrains.kotlin.backend.common.lower.matchers.singleArgumentExtension
import org.jetbrains.kotlin.ir.builders.*
-import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
+import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -35,7 +34,7 @@
parameter(0) { it.type in progressionElementTypes }
}
- override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbol) =
+ override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbolOwner) =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
ProgressionHeaderInfo(
data,
@@ -57,7 +56,7 @@
parameter(0) { it.type in progressionElementTypes }
}
- override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbol): HeaderInfo? =
+ override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbolOwner): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
ProgressionHeaderInfo(
data,
@@ -79,7 +78,7 @@
parameter(0) { it.type in progressionElementTypes }
}
- override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbol): HeaderInfo? =
+ override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbolOwner): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
// `A until B` is essentially the same as `A .. (B-1)`. However, B could be MIN_VALUE and hence `(B-1)` could underflow.
// If B is MIN_VALUE, then `A until B` is an empty range. We handle this special case be adding an additional "not empty"
@@ -222,7 +221,7 @@
/** Builds a [HeaderInfo] for progressions built using the `indices` extension property. */
internal abstract class IndicesHandler(protected val context: CommonBackendContext) : ProgressionHandler {
- override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbol): HeaderInfo? =
+ override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbolOwner): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
// `last = array.size - 1` (last is inclusive) for the loop `for (i in array.indices)`.
val receiver = expression.extensionReceiver!!
@@ -268,7 +267,7 @@
override val IrType.sizePropertyGetter
get() = getClass()?.properties?.first { it.name.asString() == "length" }?.let {
it.getter!!
- } ?: context.ir.symbols.charSequence.getPropertyGetter("length")!!.owner
+ } ?: context.ir.symbols.charSequence.getPropertyGetter("length")!!
}
/** Builds a [HeaderInfo] for calls to reverse an iterable. */
@@ -290,7 +289,7 @@
}
// Reverse the HeaderInfo from the underlying progression or array (if any).
- override fun build(expression: IrCall, data: Nothing?, scopeOwner: IrSymbol) =
+ override fun build(expression: IrCall, data: Nothing?, scopeOwner: IrSymbolOwner) =
expression.extensionReceiver!!.accept(visitor, null)?.asReversed()
}
@@ -301,7 +300,7 @@
override fun match(expression: IrExpression) = ProgressionType.fromIrType(expression.type, symbols) != null
- override fun build(expression: IrExpression, scopeOwner: IrSymbol): HeaderInfo? =
+ override fun build(expression: IrExpression, scopeOwner: IrSymbolOwner): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
// Directly use the `first/last/step` properties of the progression.
val progression = scope.createTemporaryVariable(expression, nameHint = "progression")
@@ -331,7 +330,7 @@
}
internal abstract class IndexedGetIterationHandler(protected val context: CommonBackendContext) : ExpressionHandler {
- override fun build(expression: IrExpression, scopeOwner: IrSymbol): HeaderInfo? =
+ override fun build(expression: IrExpression, scopeOwner: IrSymbolOwner): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
// Consider the case like:
//
@@ -391,9 +390,9 @@
override val IrType.sizePropertyGetter
get() = getClass()?.properties?.first { it.name.asString() == "length" }?.let {
it.getter!!
- } ?: context.ir.symbols.charSequence.getPropertyGetter("length")!!.owner
+ } ?: context.ir.symbols.charSequence.getPropertyGetter("length")!!
override val IrType.getFunction
get() = getClass()?.functions?.first { it.name.asString() == "get" }
- ?: context.ir.symbols.charSequence.getSimpleFunction("get")!!.owner
+ ?: context.ir.symbols.charSequence.getSimpleFunction("get")!!
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt
index 108102e..c1be0d9 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt
@@ -22,7 +22,7 @@
this
} else {
val function = type.getClass()!!.functions.first { it.name == numberCastFunctionName }
- IrCallImpl(startOffset, endOffset, function.returnType, function.symbol)
+ IrCallImpl(startOffset, endOffset, function.returnType, function)
.apply { dispatchReceiver = this@castIfNecessary }
}
}
@@ -35,7 +35,7 @@
is Long -> IrConstImpl(startOffset, endOffset, type, IrConstKind.Long, -value)
else -> {
val unaryMinusFun = type.getClass()!!.functions.first { it.name == OperatorNameConventions.UNARY_MINUS }
- IrCallImpl(startOffset, endOffset, type, unaryMinusFun.symbol, unaryMinusFun.descriptor).apply {
+ IrCallImpl(startOffset, endOffset, type, unaryMinusFun, unaryMinusFun.descriptor).apply {
dispatchReceiver = this@negate
}
}
@@ -51,7 +51,7 @@
is Char -> IrConstImpl(startOffset, endOffset, type, IrConstKind.Char, thisValue - 1)
else -> {
val decFun = type.getClass()!!.functions.first { it.name == OperatorNameConventions.DEC }
- IrCallImpl(startOffset, endOffset, type, decFun.symbol, decFun.descriptor).apply {
+ IrCallImpl(startOffset, endOffset, type, decFun, decFun.descriptor).apply {
dispatchReceiver = this@decrement
}
}
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/matchers/IrCallMatcher.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/matchers/IrCallMatcher.kt
index d2fc995..aa097ca 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/matchers/IrCallMatcher.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/matchers/IrCallMatcher.kt
@@ -20,7 +20,7 @@
private val calleeRestriction: IrFunctionMatcher = createIrFunctionRestrictions(restrictions)
- override fun invoke(call: IrCall) = calleeRestriction(call.symbol.owner)
+ override fun invoke(call: IrCall) = calleeRestriction(call.target)
}
internal class IrCallExtensionReceiverMatcher(
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrBackendUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrBackendUtils.kt
index 33eb31a..5dc821c 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrBackendUtils.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrBackendUtils.kt
@@ -17,25 +17,24 @@
package org.jetbrains.kotlin.ir.util
import org.jetbrains.kotlin.backend.common.atMostOne
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrField
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.name.Name
-fun IrClassSymbol.getPropertyDeclaration(name: String) =
- this.owner.declarations.filterIsInstance<IrProperty>()
+fun IrClass.getPropertyDeclaration(name: String) =
+ this.declarations.filterIsInstance<IrProperty>()
.atMostOne { it.descriptor.name == Name.identifier(name) }
-fun IrClassSymbol.getSimpleFunction(name: String): IrSimpleFunctionSymbol? =
- owner.findDeclaration<IrSimpleFunction> { it.name.asString() == name }?.symbol
+fun IrClass.getSimpleFunction(name: String): IrSimpleFunction? =
+ findDeclaration<IrSimpleFunction> { it.name.asString() == name }
-fun IrClassSymbol.getPropertyGetter(name: String): IrSimpleFunctionSymbol? =
- this.getPropertyDeclaration(name)?.getter?.symbol ?: this.getSimpleFunction("<get-$name>")
+fun IrClass.getPropertyGetter(name: String): IrSimpleFunction? =
+ this.getPropertyDeclaration(name)?.getter ?: this.getSimpleFunction("<get-$name>")
-fun IrClassSymbol.getPropertySetter(name: String): IrSimpleFunctionSymbol? =
- this.getPropertyDeclaration(name)?.setter?.symbol ?: this.getSimpleFunction("<set-$name>")
+fun IrClass.getPropertySetter(name: String): IrSimpleFunction? =
+ this.getPropertyDeclaration(name)?.setter ?: this.getSimpleFunction("<set-$name>")
-fun IrClassSymbol.getPropertyField(name: String): IrFieldSymbol? =
- this.getPropertyDeclaration(name)?.backingField?.symbol
+fun IrClass.getPropertyField(name: String): IrField? =
+ this.getPropertyDeclaration(name)?.backingField
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt
index 4d343e6..91ec177 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt
@@ -82,12 +82,12 @@
}
fun IrType.substitute(params: List<IrTypeParameter>, arguments: List<IrType>): IrType =
- substitute(params.map { it.symbol }.zip(arguments).toMap())
+ substitute(params.zip(arguments).toMap())
-fun IrType.substitute(substitutionMap: Map<IrTypeParameterSymbol, IrType>): IrType {
+fun IrType.substitute(substitutionMap: Map<IrTypeParameter, IrType>): IrType {
if (this !is IrSimpleType) return this
- substitutionMap[classifier]?.let { return it }
+ substitutionMap[classifier.owner]?.let { return it }
val newArguments = arguments.map {
if (it is IrTypeProjection) {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt
index 7b2f791..f2fb422 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt
@@ -180,7 +180,7 @@
}!!
val charClassSymbol = getInternalClassWithoutPackage("kotlin.Char")
- val charConstructor = charClassSymbol.constructors.single().owner
+ val charConstructor = charClassSymbol.constructors.single()
val stringClassSymbol = getInternalClassWithoutPackage("kotlin.String")
val stringConstructorSymbol = stringClassSymbol.constructors.single()
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt
index b018332..910fa2d 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt
@@ -128,7 +128,7 @@
private val coroutinePackage = module.getPackage(COROUTINE_PACKAGE_FQNAME)
private val coroutineIntrinsicsPackage = module.getPackage(COROUTINE_INTRINSICS_PACKAGE_FQNAME)
- val enumEntryToGetInstanceFunction = mutableMapOf<IrEnumEntrySymbol, IrSimpleFunction>()
+ val enumEntryToGetInstanceFunction = mutableMapOf<IrEnumEntry, IrSimpleFunction>()
val objectToGetInstanceFunction = mutableMapOf<IrClassSymbol, IrSimpleFunction>()
val enumEntryExternalToInstanceField = mutableMapOf<IrEnumEntrySymbol, IrField>()
val callableReferencesCache = mutableMapOf<CallableReferenceKey, IrSimpleFunction>()
@@ -254,14 +254,14 @@
val suiteFun = getFunctions(FqName("kotlin.test.suite")).singleOrNull()?.let { symbolTable.referenceSimpleFunction(it) }
val testFun = getFunctions(FqName("kotlin.test.test")).singleOrNull()?.let { symbolTable.referenceSimpleFunction(it) }
- val coroutineImplLabelPropertyGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("state")!!.owner }
- val coroutineImplLabelPropertySetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("state")!!.owner }
- val coroutineImplResultSymbolGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("result")!!.owner }
- val coroutineImplResultSymbolSetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("result")!!.owner }
- val coroutineImplExceptionPropertyGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("exception")!!.owner }
- val coroutineImplExceptionPropertySetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("exception")!!.owner }
- val coroutineImplExceptionStatePropertyGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("exceptionState")!!.owner }
- val coroutineImplExceptionStatePropertySetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("exceptionState")!!.owner }
+ val coroutineImplLabelPropertyGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("state")!! }
+ val coroutineImplLabelPropertySetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("state")!! }
+ val coroutineImplResultSymbolGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("result")!! }
+ val coroutineImplResultSymbolSetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("result")!! }
+ val coroutineImplExceptionPropertyGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("exception")!! }
+ val coroutineImplExceptionPropertySetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("exception")!! }
+ val coroutineImplExceptionStatePropertyGetter by lazy { ir.symbols.coroutineImpl.getPropertyGetter("exceptionState")!! }
+ val coroutineImplExceptionStatePropertySetter by lazy { ir.symbols.coroutineImpl.getPropertySetter("exceptionState")!! }
val primitiveClassProperties by lazy {
primitiveClassesObject.owner.declarations.filterIsInstance<IrProperty>()
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt
index 3c7b228..3c2d8af 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt
@@ -390,7 +390,8 @@
val jsPhases = namedIrModulePhase(
name = "IrModuleLowering",
description = "IR module lowering",
- lower = validateIrBeforeLowering then
+ lower = desymbolizePhase then
+ validateIrBeforeLowering then
testGenerationPhase then
expectDeclarationsRemovingPhase then
stripTypeAliasDeclarationsPhase then
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt
index b13b06d6..b9bf082 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt
@@ -26,7 +26,6 @@
import org.jetbrains.kotlin.ir.expressions.IrGetValue
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
@@ -72,7 +71,7 @@
override fun defineSharedValue(originalDeclaration: IrVariable, sharedVariableDeclaration: IrVariable) = sharedVariableDeclaration
- override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue) = IrGetFieldImpl(
+ override fun getSharedValue(sharedVariable: IrVariable, originalGet: IrGetValue) = IrGetFieldImpl(
originalGet.startOffset, originalGet.endOffset,
closureBoxFieldDeclaration.symbol,
originalGet.type,
@@ -80,13 +79,13 @@
originalGet.startOffset,
originalGet.endOffset,
closureBoxType,
- sharedVariableSymbol,
+ sharedVariable,
originalGet.origin
),
originalGet.origin
)
- override fun setSharedValue(sharedVariableSymbol: IrVariableSymbol, originalSet: IrSetVariable): IrExpression =
+ override fun setSharedValue(sharedVariable: IrVariable, originalSet: IrSetVariable): IrExpression =
IrSetFieldImpl(
originalSet.startOffset,
originalSet.endOffset,
@@ -95,7 +94,7 @@
originalSet.startOffset,
originalSet.endOffset,
closureBoxType,
- sharedVariableSymbol,
+ sharedVariable,
originalSet.origin
),
originalSet.value,
@@ -181,10 +180,10 @@
declaration.valueParameters += parameterDeclaration
- val receiver = JsIrBuilder.buildGetValue(closureBoxClassDeclaration.thisReceiver!!.symbol)
- val value = JsIrBuilder.buildGetValue(parameterDeclaration.symbol)
+ val receiver = JsIrBuilder.buildGetValue(closureBoxClassDeclaration.thisReceiver!!)
+ val value = JsIrBuilder.buildGetValue(parameterDeclaration)
- val setField = JsIrBuilder.buildSetField(closureBoxFieldDeclaration.symbol, receiver, value, closureBoxFieldDeclaration.type)
+ val setField = JsIrBuilder.buildSetField(closureBoxFieldDeclaration, receiver, value, closureBoxFieldDeclaration.type)
declaration.body = IrBlockBodyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, listOf(setField))
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt
index 17f1b57..30a6bbc 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt
@@ -15,7 +15,6 @@
import org.jetbrains.kotlin.ir.declarations.impl.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.impl.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.name.Name
@@ -26,11 +25,11 @@
object SYNTHESIZED_STATEMENT : IrStatementOriginImpl("SYNTHESIZED_STATEMENT")
object SYNTHESIZED_DECLARATION : IrDeclarationOriginImpl("SYNTHESIZED_DECLARATION")
- fun buildCall(target: IrFunctionSymbol, type: IrType? = null, typeArguments: List<IrType>? = null): IrCall =
+ fun buildCall(target: IrFunction, type: IrType? = null, typeArguments: List<IrType>? = null): IrCall =
IrCallImpl(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
- type ?: target.owner.returnType,
+ type ?: target.returnType,
target,
target.descriptor,
target.descriptor.typeParametersCount,
@@ -42,8 +41,8 @@
}
}
- fun buildReturn(targetSymbol: IrFunctionSymbol, value: IrExpression, type: IrType) =
- IrReturnImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, targetSymbol, value)
+ fun buildReturn(target: IrFunction, value: IrExpression, type: IrType) =
+ IrReturnImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, target, value)
fun buildThrow(type: IrType, value: IrExpression) = IrThrowImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, value)
@@ -142,34 +141,34 @@
fun buildAnonymousInitializer() =
IrAnonymousInitializerImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, SYNTHESIZED_DECLARATION, IrAnonymousInitializerSymbolImpl(WrappedClassDescriptor()))
- fun buildGetObjectValue(type: IrType, classSymbol: IrClassSymbol) =
- IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, classSymbol)
+ fun buildGetObjectValue(type: IrType, irClass: IrClass) =
+ IrGetObjectValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, irClass)
- fun buildGetValue(symbol: IrValueSymbol) =
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, symbol.owner.type, symbol, SYNTHESIZED_STATEMENT)
+ fun buildGetValue(target: IrValueDeclaration) =
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.type, target, SYNTHESIZED_STATEMENT)
- fun buildSetVariable(symbol: IrVariableSymbol, value: IrExpression, type: IrType) =
- IrSetVariableImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, symbol, value, SYNTHESIZED_STATEMENT)
+ fun buildSetVariable(target: IrVariable, value: IrExpression, type: IrType) =
+ IrSetVariableImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, target, value, SYNTHESIZED_STATEMENT)
- fun buildGetField(symbol: IrFieldSymbol, receiver: IrExpression?, superQualifierSymbol: IrClassSymbol? = null, type: IrType? = null) =
+ fun buildGetField(target: IrField, receiver: IrExpression?, irSuperQualifier: IrClass? = null, type: IrType? = null) =
IrGetFieldImpl(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
- symbol,
- type ?: symbol.owner.type,
+ target,
+ type ?: target.type,
receiver,
SYNTHESIZED_STATEMENT,
- superQualifierSymbol
+ irSuperQualifier
)
fun buildSetField(
- symbol: IrFieldSymbol,
+ target: IrField,
receiver: IrExpression?,
value: IrExpression,
type: IrType,
- superQualifierSymbol: IrClassSymbol? = null
+ irSuperQualifier: IrClass? = null
) =
- IrSetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, symbol, receiver, value, type, SYNTHESIZED_STATEMENT, superQualifierSymbol)
+ IrSetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target, receiver, value, type, SYNTHESIZED_STATEMENT, irSuperQualifier)
fun buildBlockBody(statements: List<IrStatement>) = IrBlockBodyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, statements)
@@ -180,8 +179,8 @@
fun buildComposite(type: IrType, statements: List<IrStatement> = emptyList()) =
IrCompositeImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, SYNTHESIZED_STATEMENT, statements)
- fun buildFunctionReference(type: IrType, symbol: IrFunctionSymbol) =
- IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, symbol, symbol.descriptor, 0, null)
+ fun buildFunctionReference(type: IrType, target: IrFunction) =
+ IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, target, target.descriptor, 0, null)
fun buildVar(
type: IrType,
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt
index 4dd202d..9df6c35 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/AutoboxingTransformer.kt
@@ -35,7 +35,7 @@
}
is IrGetObjectValue ->
- this.symbol == irBuiltIns.unitClass
+ this.target == irBuiltIns.unitClass
else -> false
}
@@ -43,16 +43,16 @@
override fun IrExpression.useAs(type: IrType): IrExpression {
val actualType = when (this) {
- is IrConstructorCall -> symbol.owner.returnType
+ is IrConstructorCall -> target.returnType
is IrCall -> {
- val function = this.symbol.owner
+ val function = this.target
if (function.let { it is IrSimpleFunction && it.isSuspend }) {
irBuiltIns.anyNType
} else {
function.realOverrideTarget.returnType
}
}
- is IrGetField -> this.symbol.owner.type
+ is IrGetField -> this.target.type
is IrTypeOperatorCall -> when (this.operator) {
IrTypeOperator.IMPLICIT_INTEGER_COERCION ->
@@ -65,7 +65,7 @@
}
is IrGetValue -> {
- val value = this.symbol.owner
+ val value = this.target
if (value is IrValueParameter && value.isDispatchReceiver) {
irBuiltIns.anyNType
} else {
@@ -132,11 +132,11 @@
val nullCheck = buildIfElse(
type = resultType,
cond = buildCall(irBuiltIns.eqeqSymbol).apply {
- putValueArgument(0, buildGetValue(tmp.symbol))
+ putValueArgument(0, buildGetValue(tmp))
putValueArgument(1, buildNull(irBuiltIns.nothingNType))
},
thenBranch = buildNull(irBuiltIns.nothingNType),
- elseBranch = call(buildGetValue(tmp.symbol))
+ elseBranch = call(buildGetValue(tmp))
)
buildBlock(
type = resultType,
@@ -148,24 +148,21 @@
}
}
- private val IrFunctionAccessExpression.target: IrFunction
+ private val IrFunctionAccessExpression.callTarget: IrFunction
get() = when (this) {
- is IrConstructorCall -> this.symbol.owner
- is IrDelegatingConstructorCall -> this.symbol.owner
- is IrCall -> this.callTarget
+ is IrConstructorCall -> this.target
+ is IrDelegatingConstructorCall -> this.target
+ is IrCall -> this.target.realOverrideTarget
else -> TODO(this.render())
}
- private val IrCall.callTarget: IrFunction
- get() = symbol.owner.realOverrideTarget
-
override fun IrExpression.useAsDispatchReceiver(expression: IrFunctionAccessExpression): IrExpression {
- return this.useAsArgument(expression.target.dispatchReceiverParameter!!)
+ return this.useAsArgument(expression.callTarget.dispatchReceiverParameter!!)
}
override fun IrExpression.useAsExtensionReceiver(expression: IrFunctionAccessExpression): IrExpression {
- return this.useAsArgument(expression.target.extensionReceiverParameter!!)
+ return this.useAsArgument(expression.callTarget.extensionReceiverParameter!!)
}
override fun IrExpression.useAsValueArgument(
@@ -173,7 +170,7 @@
parameter: IrValueParameter
): IrExpression {
- return this.useAsArgument(expression.target.valueParameters[parameter.index])
+ return this.useAsArgument(expression.callTarget.valueParameters[parameter.index])
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt
index 9fa8c92..56f7646 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt
@@ -25,7 +25,7 @@
class JsBlockDecomposerLowering(val context: JsIrBackendContext) : AbstractBlockDecomposerLowering(context) {
override fun unreachableExpression(): IrExpression =
- JsIrBuilder.buildCall(context.intrinsics.unreachable.symbol, context.irBuiltIns.nothingType)
+ JsIrBuilder.buildCall(context.intrinsics.unreachable, context.irBuiltIns.nothingType)
}
abstract class AbstractBlockDecomposerLowering(context: CommonBackendContext) : DeclarationContainerLoweringPass {
@@ -58,7 +58,7 @@
private fun IrExpressionBody.toBlockBody(containingFunction: IrFunction): IrBlockBody {
expression.patchDeclarationParents(containingFunction)
- val returnStatement = JsIrBuilder.buildReturn(containingFunction.symbol, expression, nothingType)
+ val returnStatement = JsIrBuilder.buildReturn(containingFunction, expression, nothingType)
return IrBlockBodyImpl(expression.startOffset, expression.endOffset).apply {
statements += returnStatement
}
@@ -81,7 +81,7 @@
val lastStatement = newBody.statements.last()
if (newBody.statements.size > 1 || lastStatement !is IrReturn || lastStatement.value != expression) {
- expression = JsIrBuilder.buildCall(initFunction.symbol, expression.type)
+ expression = JsIrBuilder.buildCall(initFunction, expression.type)
return listOf(initFunction, irField)
}
}
@@ -166,7 +166,7 @@
val composite = expression.value as? IrComposite ?: return expression
return materializeLastExpression(composite) {
- IrReturnImpl(expression.startOffset, expression.endOffset, expression.type, expression.returnTargetSymbol, it)
+ IrReturnImpl(expression.startOffset, expression.endOffset, expression.type, expression.irReturnTarget, it)
}
}
@@ -209,12 +209,12 @@
IrSetFieldImpl(
startOffset,
endOffset,
- symbol,
- JsIrBuilder.buildGetValue(irVar.symbol),
+ target,
+ JsIrBuilder.buildGetValue(irVar),
setValue,
type,
origin,
- superQualifierSymbol
+ irSuperQualifier
)
}
return result
@@ -223,7 +223,7 @@
if (receiverResult != null) {
return materializeLastExpression(receiverResult) {
expression.run {
- IrSetFieldImpl(startOffset, endOffset, symbol, it, value, type, origin, superQualifierSymbol)
+ IrSetFieldImpl(startOffset, endOffset, target, it, value, type, origin, irSuperQualifier)
}
}
}
@@ -233,12 +233,12 @@
val receiver = expression.receiver?.let {
val irVar = makeTempVar(it.type, it)
valueResult!!.statements.add(0, irVar)
- JsIrBuilder.buildGetValue(irVar.symbol)
+ JsIrBuilder.buildGetValue(irVar)
}
return materializeLastExpression(valueResult!!) {
expression.run {
- IrSetFieldImpl(startOffset, endOffset, symbol, receiver, it, type, origin, superQualifierSymbol)
+ IrSetFieldImpl(startOffset, endOffset, target, receiver, it, type, origin, irSuperQualifier)
}
}
}
@@ -249,7 +249,7 @@
val composite = expression.value as? IrComposite ?: return expression
return materializeLastExpression(composite) {
- expression.run { IrSetVariableImpl(startOffset, endOffset, type, symbol, it, origin) }
+ expression.run { IrSetVariableImpl(startOffset, endOffset, type, target, it, origin) }
}
}
@@ -420,7 +420,7 @@
val composite = expression.receiver as? IrComposite ?: return expression
return materializeLastExpression(composite) {
- expression.run { IrGetFieldImpl(startOffset, endOffset, symbol, type, it, origin, superQualifierSymbol) }
+ expression.run { IrGetFieldImpl(startOffset, endOffset, target, type, it, origin, irSuperQualifier) }
}
}
@@ -489,7 +489,7 @@
// TODO: do not wrap if value is pure (const, variable, etc)
val irVar = makeTempVar(value.type, value)
newStatements += irVar
- JsIrBuilder.buildGetValue(irVar.symbol)
+ JsIrBuilder.buildGetValue(irVar)
}
}
@@ -632,7 +632,7 @@
expression as? IrBlock ?: expression.let { IrBlockImpl(it.startOffset, it.endOffset, it.type, null, listOf(it)) }
private fun wrap(expression: IrExpression, variable: IrVariable) =
- wrap(JsIrBuilder.buildSetVariable(variable.symbol, expression, unitType))
+ wrap(JsIrBuilder.buildSetVariable(variable, expression, unitType))
// try {
// try_block {}
@@ -663,7 +663,7 @@
val newTry = aTry.run { IrTryImpl(startOffset, endOffset, unitType, newTryResult, newCatches, finallyExpression) }
newTry.transformChildrenVoid(statementTransformer)
- val newStatements = listOf(irVar, newTry, JsIrBuilder.buildGetValue(irVar.symbol))
+ val newStatements = listOf(irVar, newTry, JsIrBuilder.buildGetValue(irVar))
return JsIrBuilder.buildComposite(aTry.type, newStatements)
}
@@ -714,7 +714,7 @@
expression.run { IrWhenImpl(startOffset, endOffset, unitType, origin, newBranches) }
.transform(statementTransformer, null) // deconstruct into `if-else` chain
- return JsIrBuilder.buildComposite(expression.type, listOf(irVar, newWhen, JsIrBuilder.buildGetValue(irVar.symbol)))
+ return JsIrBuilder.buildComposite(expression.type, listOf(irVar, newWhen, JsIrBuilder.buildGetValue(irVar)))
} else {
val newBranches = decomposedResults.map { (branch, condition, result) ->
when {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt
index dd0e9c3..5b18581 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BridgesConstruction.kt
@@ -18,7 +18,6 @@
import org.jetbrains.kotlin.backend.common.lower.irBlockBody
import org.jetbrains.kotlin.backend.common.lower.irNot
import org.jetbrains.kotlin.descriptors.Modality
-import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
import org.jetbrains.kotlin.ir.backend.js.utils.functionSignature
@@ -140,7 +139,7 @@
extensionReceiverParameter = bridge.extensionReceiverParameter?.copyTo(this)
valueParameters += bridge.valueParameters.map { p -> p.copyTo(this) }
annotations += bridge.annotations
- overriddenSymbols.addAll(delegateTo.overriddenSymbols)
+ overridden.addAll(delegateTo.overridden)
}
context.createIrBuilder(irFunction.symbol).irBlockBody(irFunction) {
@@ -190,7 +189,7 @@
!function.parentAsClass.isInterface
override fun getOverridden() =
- function.overriddenSymbols.map { IrBasedFunctionHandle(it.owner) }
+ function.overridden.map { IrBasedFunctionHandle(it) }
}
// Wrapper around function that compares and hashCodes it based on signature
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt
index 82b6db6..df7e404 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt
@@ -22,7 +22,6 @@
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.types.IrSimpleType
@@ -64,7 +63,7 @@
inner class CallableReferenceLowerTransformer : IrElementTransformerVoid() {
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
expression.transformChildrenVoid(this)
- val declaration = expression.symbol.owner
+ val declaration = expression.target
if (declaration.origin == JsIrBackendContext.callableClosureOrigin) return expression
val key = makeCallableKey(declaration, expression)
val factory = callableToFactoryFunction.getOrPut(key) { lowerKFunctionReference(declaration, expression) }
@@ -73,7 +72,7 @@
override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
expression.transformChildrenVoid(this)
- val declaration = expression.getter!!.owner
+ val declaration = expression.getter!!
val key = makeCallableKey(declaration, expression)
val factory = callableToFactoryFunction.getOrPut(key) { lowerKPropertyReference(declaration, expression) }
return redirectToFunction(expression, factory)
@@ -81,7 +80,7 @@
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression {
expression.transformChildrenVoid(this)
- val key = makeCallableKey(expression.getter.owner, expression)
+ val key = makeCallableKey(expression.getter, expression)
val factory = callableToFactoryFunction.getOrPut(key) { lowerLocalKPropertyReference(expression) }
return redirectToFunction(expression, factory)
}
@@ -159,7 +158,7 @@
val closureFunction = buildClosureFunction(declaration, factoryFunction, functionReference, functionReference.type.arity)
val additionalDeclarations = generateFactoryBodyWithGuard(factoryFunction) {
- val irClosureReference = JsIrBuilder.buildFunctionReference(functionReference.type, closureFunction.symbol)
+ val irClosureReference = JsIrBuilder.buildFunctionReference(functionReference.type, closureFunction)
val irVar = JsIrBuilder.buildVar(irClosureReference.type, factoryFunction, initializer = irClosureReference)
@@ -168,7 +167,7 @@
JsIrBuilder.buildString(context.irBuiltIns.stringType, getReferenceName(declaration))
}
- Pair(listOf(closureFunction, irVar, irSetName), irVar.symbol)
+ Pair(listOf(closureFunction, irVar, irSetName), irVar)
}
newDeclarations += additionalDeclarations + factoryFunction
@@ -198,31 +197,31 @@
val arity = propertyReference.type.arity
val factoryName = createPropertyFactoryName(getterDeclaration.correspondingPropertySymbol!!.owner)
- val factoryFunction = buildFactoryFunction(propertyReference.getter!!.owner, propertyReference, factoryName)
+ val factoryFunction = buildFactoryFunction(propertyReference.getter!!, propertyReference, factoryName)
- val getterFunction = propertyReference.getter?.let { buildClosureFunction(it.owner, factoryFunction, propertyReference, arity) }!!
- val setterFunction = propertyReference.setter?.let { buildClosureFunction(it.owner, factoryFunction, propertyReference, arity + 1) }
+ val getterFunction = propertyReference.getter?.let { buildClosureFunction(it, factoryFunction, propertyReference, arity) }!!
+ val setterFunction = propertyReference.setter?.let { buildClosureFunction(it, factoryFunction, propertyReference, arity + 1) }
val additionalDeclarations = generateFactoryBodyWithGuard(factoryFunction) {
val statements = mutableListOf<IrStatement>(getterFunction)
- val getterFunctionTypeSymbol = context.ir.symbols.functionN(getterFunction.valueParameters.size + 1)
+ val getterFunctionClass = context.ir.symbols.functionN(getterFunction.valueParameters.size + 1)
- val getterFunctionIrType = IrSimpleTypeImpl(getterFunctionTypeSymbol, false, emptyList(), emptyList())
- val irGetReference = JsIrBuilder.buildFunctionReference(getterFunctionIrType, getterFunction.symbol)
+ val getterFunctionIrType = IrSimpleTypeImpl(getterFunctionClass.symbol, false, emptyList(), emptyList())
+ val irGetReference = JsIrBuilder.buildFunctionReference(getterFunctionIrType, getterFunction)
val irVar = JsIrBuilder.buildVar(getterFunctionIrType, factoryFunction, initializer = irGetReference)
statements += irVar
statements += setDynamicProperty(irVar.symbol, Namer.KPROPERTY_GET) {
- JsIrBuilder.buildGetValue(irVar.symbol)
+ JsIrBuilder.buildGetValue(irVar)
}
if (setterFunction != null) {
statements += setterFunction
- val setterFunctionTypeSymbol = context.ir.symbols.functionN(setterFunction.valueParameters.size + 1)
- val setterFunctionIrType = IrSimpleTypeImpl(setterFunctionTypeSymbol, false, emptyList(), emptyList())
- val irSetReference = JsIrBuilder.buildFunctionReference(setterFunctionIrType, setterFunction.symbol)
+ val setterFunctionClass = context.ir.symbols.functionN(setterFunction.valueParameters.size + 1)
+ val setterFunctionIrType = IrSimpleTypeImpl(setterFunctionClass.symbol, false, emptyList(), emptyList())
+ val irSetReference = JsIrBuilder.buildFunctionReference(setterFunctionIrType, setterFunction)
statements += setDynamicProperty(irVar.symbol, Namer.KPROPERTY_SET) { irSetReference }
}
@@ -234,7 +233,7 @@
)
}
- Pair(statements, irVar.symbol)
+ Pair(statements, irVar)
}
newDeclarations += additionalDeclarations + factoryFunction
@@ -258,31 +257,30 @@
// }
val arity = propertyReference.type.arity
- val declaration = propertyReference.delegate.owner
+ val declaration = propertyReference.delegate
val factoryName = createPropertyFactoryName(declaration)
- val factoryFunction = buildFactoryFunction(propertyReference.getter.owner, propertyReference, factoryName)
+ val factoryFunction = buildFactoryFunction(propertyReference.getter, propertyReference, factoryName)
val closureFunction = buildClosureFunction(context.irBuiltIns.throwIseSymbol.owner, factoryFunction, propertyReference, arity)
val additionalDeclarations = generateFactoryBodyWithGuard(factoryFunction) {
val statements = mutableListOf<IrStatement>(closureFunction)
- val getterFunctionTypeSymbol = context.ir.symbols.functionN(closureFunction.valueParameters.size + 1)
- val getterFunctionIrType = IrSimpleTypeImpl(getterFunctionTypeSymbol, false, emptyList(), emptyList())
- val irGetReference = JsIrBuilder.buildFunctionReference(getterFunctionIrType, closureFunction.symbol)
+ val getterFunctionClass = context.ir.symbols.functionN(closureFunction.valueParameters.size + 1)
+ val getterFunctionIrType = IrSimpleTypeImpl(getterFunctionClass.symbol, false, emptyList(), emptyList())
+ val irGetReference = JsIrBuilder.buildFunctionReference(getterFunctionIrType, closureFunction)
val irVar = JsIrBuilder.buildVar(getterFunctionIrType, factoryFunction, initializer = irGetReference)
- val irVarSymbol = irVar.symbol
statements += irVar
- statements += setDynamicProperty(irVarSymbol, Namer.KPROPERTY_GET) {
- JsIrBuilder.buildGetValue(irVarSymbol)
+ statements += setDynamicProperty(irVar, Namer.KPROPERTY_GET) {
+ JsIrBuilder.buildGetValue(irVar)
}
- statements += setDynamicProperty(irVarSymbol, Namer.KCALLABLE_NAME) {
+ statements += setDynamicProperty(irVar, Namer.KCALLABLE_NAME) {
JsIrBuilder.buildString(context.irBuiltIns.stringType, getReferenceName(declaration))
}
- Pair(statements, irVarSymbol)
+ Pair(statements, irVar)
}
newDeclarations += additionalDeclarations + factoryFunction
@@ -292,10 +290,10 @@
private fun generateFactoryBodyWithGuard(
factoryFunction: IrSimpleFunction,
- builder: () -> Pair<List<IrStatement>, IrValueSymbol>
+ builder: () -> Pair<List<IrStatement>, IrValueDeclaration>
): List<IrDeclaration> {
- val (bodyStatements, varSymbol) = builder()
+ val (bodyStatements, variable) = builder()
val statements = mutableListOf<IrStatement>()
val returnValue: IrExpression
val returnStatements: List<IrDeclaration>
@@ -310,13 +308,13 @@
val irNull = { JsIrBuilder.buildNull(context.irBuiltIns.nothingNType) }
val cacheVar = JsIrBuilder.buildVar(type, factoryFunction.parent, cacheName, true, initializer = irNull())
- val irCacheValue = { JsIrBuilder.buildGetValue(cacheVar.symbol) }
+ val irCacheValue = { JsIrBuilder.buildGetValue(cacheVar) }
val irIfCondition = JsIrBuilder.buildCall(context.irBuiltIns.eqeqSymbol).apply {
putValueArgument(0, irCacheValue())
putValueArgument(1, irNull())
}
val irSetCache =
- JsIrBuilder.buildSetVariable(cacheVar.symbol, JsIrBuilder.buildGetValue(varSymbol), context.irBuiltIns.unitType)
+ JsIrBuilder.buildSetVariable(cacheVar, JsIrBuilder.buildGetValue(variable), context.irBuiltIns.unitType)
val thenStatements = mutableListOf<IrStatement>().apply {
addAll(bodyStatements)
add(irSetCache)
@@ -328,11 +326,11 @@
returnStatements = listOf(cacheVar)
} else {
statements += bodyStatements
- returnValue = JsIrBuilder.buildGetValue(varSymbol)
+ returnValue = JsIrBuilder.buildGetValue(variable)
returnStatements = emptyList()
}
- statements += JsIrBuilder.buildReturn(factoryFunction.symbol, returnValue, context.irBuiltIns.nothingType)
+ statements += JsIrBuilder.buildReturn(factoryFunction, returnValue, context.irBuiltIns.nothingType)
factoryFunction.body = JsIrBuilder.buildBlockBody(statements)
return returnStatements
@@ -491,9 +489,8 @@
)
// the params which are passed to closure
- val boundParamSymbols = factoryFunction.valueParameters.map { it.symbol }
+ val boundParamDeclarations = factoryFunction.valueParameters
val unboundParamDeclarations = generateSignatureForClosure(declaration, factoryFunction, closureFunction, reference, arity)
- val unboundParamSymbols = unboundParamDeclarations.map { it.symbol }
closureFunction.valueParameters += unboundParamDeclarations
@@ -503,7 +500,7 @@
val irCall =
if (target is IrConstructorSymbol) IrConstructorCallImpl.fromSymbolOwner(returnType, target) else JsIrBuilder.buildCall(
- callTarget.symbol,
+ callTarget,
type = returnType
)
@@ -512,31 +509,31 @@
if (callTarget.dispatchReceiverParameter != null) {
val dispatchReceiverDeclaration =
- if (reference.dispatchReceiver != null) boundParamSymbols[gp++] else unboundParamSymbols[cp++]
+ if (reference.dispatchReceiver != null) boundParamDeclarations[gp++] else unboundParamDeclarations[cp++]
irCall.dispatchReceiver = JsIrBuilder.buildGetValue(dispatchReceiverDeclaration)
}
if (callTarget.extensionReceiverParameter != null) {
val extensionReceiverDeclaration =
- if (reference.extensionReceiver != null) boundParamSymbols[gp++] else unboundParamSymbols[cp++]
+ if (reference.extensionReceiver != null) boundParamDeclarations[gp++] else unboundParamDeclarations[cp++]
irCall.extensionReceiver = JsIrBuilder.buildGetValue(extensionReceiverDeclaration)
}
var j = 0
- for (i in gp until boundParamSymbols.size) {
- irCall.putValueArgument(j++, JsIrBuilder.buildGetValue(boundParamSymbols[i]))
+ for (i in gp until boundParamDeclarations.size) {
+ irCall.putValueArgument(j++, JsIrBuilder.buildGetValue(boundParamDeclarations[i]))
}
- for (i in cp until unboundParamSymbols.size) {
- val closureParam = unboundParamSymbols[i].owner
- val value = JsIrBuilder.buildGetValue(unboundParamSymbols[i])
+ for (i in cp until unboundParamDeclarations.size) {
+ val closureParam = unboundParamDeclarations[i]
+ val value = JsIrBuilder.buildGetValue(unboundParamDeclarations[i])
val parameter = callTarget.valueParameters[j]
val argument =
if (parameter.varargElementType == closureParam.type) {
// fun foo(x: X, vararg y: Y): Z
// val r: (X, Y) -> Z = ::foo
- val tailValues = unboundParamSymbols.drop(i)
+ val tailValues = unboundParamDeclarations.drop(i)
IrVarargImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, parameter.type, parameter.varargElementType!!, tailValues.map {
JsIrBuilder.buildGetValue(it)
})
@@ -545,14 +542,14 @@
if (j == callTarget.valueParameters.size) break
}
- val irClosureReturn = JsIrBuilder.buildReturn(closureFunction.symbol, irCall, context.irBuiltIns.nothingType)
+ val irClosureReturn = JsIrBuilder.buildReturn(closureFunction, irCall, context.irBuiltIns.nothingType)
closureFunction.body = JsIrBuilder.buildBlockBody(listOf(irClosureReturn))
return closureFunction
}
- private inline fun setDynamicProperty(r: IrValueSymbol, property: String, value: () -> IrExpression): IrStatement {
+ private inline fun setDynamicProperty(r: IrValueDeclaration, property: String, value: () -> IrExpression): IrStatement {
return IrDynamicOperatorExpressionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, IrDynamicOperator.EQ).apply {
receiver = IrDynamicMemberExpressionImpl(startOffset, endOffset, context.dynamicType, property, JsIrBuilder.buildGetValue(r))
arguments += value()
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ClassReferenceLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ClassReferenceLowering.kt
index 8a75b14..f937d41 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ClassReferenceLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ClassReferenceLowering.kt
@@ -78,7 +78,7 @@
}
private fun getPrimitiveClass(target: IrSimpleFunction, returnType: IrType) =
- JsIrBuilder.buildCall(target.symbol, returnType).apply {
+ JsIrBuilder.buildCall(target, returnType).apply {
dispatchReceiver = JsIrBuilder.buildGetObjectValue(primitiveClassesObject.owner.defaultType, primitiveClassesObject)
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ConstLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ConstLowering.kt
index b3408b7..a39daf6 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ConstLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ConstLowering.kt
@@ -32,7 +32,7 @@
vararg args: C
): IrExpression {
val constructor = irClass.constructors.single()
- val argType = constructor.owner.valueParameters.first().type
+ val argType = constructor.valueParameters.first().type
return IrConstructorCallImpl.fromSymbolOwner(irClass.owner.defaultType, constructor).apply {
for (i in args.indices) {
putValueArgument(i, carrierFactory(UNDEFINED_OFFSET, UNDEFINED_OFFSET, argType, args[i]))
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt
index c2ded07..8536d19 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt
@@ -45,7 +45,7 @@
override fun lower(irFile: IrFile) {
irFile.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetEnumValue(expression: IrGetEnumValue): IrExpression {
- val enumEntry = expression.symbol.owner
+ val enumEntry = expression.target
val klass = enumEntry.parent as IrClass
return if (klass.isExternal) lowerExternalEnumEntry(enumEntry, klass) else lowerEnumEntry(enumEntry, klass)
}
@@ -54,7 +54,7 @@
private fun lowerExternalEnumEntry(enumEntry: IrEnumEntry, klass: IrClass) =
context.enumEntryExternalToInstanceField.getOrPut(enumEntry.symbol) { createFieldForEntry(enumEntry, klass) }.let {
- JsIrBuilder.buildGetField(it.symbol, classAsReceiver(klass), null, klass.defaultType)
+ JsIrBuilder.buildGetField(it, classAsReceiver(klass), null, klass.defaultType)
}
private fun classAsReceiver(irClass: IrClass): IrExpression {
@@ -75,13 +75,13 @@
}
private fun lowerEnumEntry(enumEntry: IrEnumEntry, klass: IrClass) =
- context.enumEntryToGetInstanceFunction.getOrPut(enumEntry.symbol) {
+ context.enumEntryToGetInstanceFunction.getOrPut(enumEntry) {
JsIrBuilder.buildFunction(
createEntryAccessorName(klass.name.identifier, enumEntry),
returnType = enumEntry.getType(klass),
parent = klass
)
- }.run { JsIrBuilder.buildCall(symbol) }
+ }.run { JsIrBuilder.buildCall(this) }
}
class EnumClassLowering(val context: JsIrBackendContext) : DeclarationContainerLoweringPass {
@@ -222,14 +222,14 @@
}
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall) =
- builder.irDelegatingConstructorCall(expression.symbol.owner).apply {
+ builder.irDelegatingConstructorCall(expression.target).apply {
for (i in 0..1) {
putValueArgument(i, builder.irGet(constructor.valueParameters[i]))
}
}
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
- var delegatingConstructor = expression.symbol.owner
+ var delegatingConstructor = expression.target
val constructorWasTransformed = delegatingConstructor.symbol in loweredEnumConstructors
if (constructorWasTransformed)
@@ -261,7 +261,7 @@
irClass.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetValue(expression: IrGetValue): IrExpression {
- fromOldToNewParameter[expression.symbol]?.let {
+ fromOldToNewParameter[expression.target]?.let {
return builder.irGet(it)
}
@@ -289,7 +289,7 @@
builder.irCall(constructor)
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrExpression {
- var constructor = expression.symbol.owner
+ var constructor = expression.target
val constructorWasTransformed = constructor.symbol in loweredEnumConstructors
// Enum entry class constructors are not transformed
@@ -457,7 +457,7 @@
initEntryInstancesFun: IrSimpleFunction,
entryInstances: List<IrField>
) = enumEntries.mapIndexed { index, enumEntry ->
- context.enumEntryToGetInstanceFunction.getOrPut(enumEntry.symbol) {
+ context.enumEntryToGetInstanceFunction.getOrPut(enumEntry) {
buildFunction(createEntryAccessorName(enumName, enumEntry), enumEntry.getType(irClass))
}.apply {
body = context.createIrBuilder(symbol).irBlockBody(this) {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt
index c998974..7d1ee24 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt
@@ -24,7 +24,6 @@
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
-import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
class JsDefaultArgumentStubGenerator(override val context: JsIrBackendContext) : DefaultArgumentStubGenerator(context, true, true) {
@@ -50,7 +49,7 @@
private fun resolveInvoke(paramCount: Int): IrSimpleFunction {
assert(paramCount > 0)
- val functionKlass = context.ir.symbols.functionN(paramCount).owner
+ val functionKlass = context.ir.symbols.functionN(paramCount)
return functionKlass.declarations.filterIsInstance<IrSimpleFunction>().first { it.name == Name.identifier("invoke") }
}
}
@@ -62,7 +61,7 @@
irBody.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitCall(expression: IrCall): IrExpression {
super.visitCall(expression)
- if (expression.origin != DEFAULT_DISPATCH_CALL || expression.superQualifierSymbol == null) return expression
+ if (expression.origin != DEFAULT_DISPATCH_CALL || expression.irSuperQualifier == null) return expression
val binding = buildBoundSuperCall(expression)
@@ -75,7 +74,7 @@
private fun buildBoundSuperCall(irCall: IrCall): IrExpression {
- val originalFunction = context.ir.defaultParameterDeclarationsCache.entries.first { it.value == irCall.symbol.owner }.key
+ val originalFunction = context.ir.defaultParameterDeclarationsCache.entries.first { it.value == irCall.target }.key
val reference = irCall.run {
IrFunctionReferenceImpl(
@@ -97,7 +96,7 @@
context.intrinsics.jsBind.symbol,
context.intrinsics.jsBind.descriptor,
BIND_CALL,
- superQualifierSymbol
+ irSuperQualifier
)
}.apply {
putValueArgument(0, irCall.dispatchReceiver?.deepCopyWithSymbols())
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt
index 3287984..a926606 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/MultipleCatchesLowering.kt
@@ -63,7 +63,7 @@
if (aTry.catches.isEmpty()) return aTry.also { assert(it.finallyExpression != null) }
val pendingExceptionDeclaration = JsIrBuilder.buildVar(context.dynamicType, data, "\$p")
- val pendingException = { JsIrBuilder.buildGetValue(pendingExceptionDeclaration.symbol) }
+ val pendingException = { JsIrBuilder.buildGetValue(pendingExceptionDeclaration) }
val branches = mutableListOf<IrBranch>()
var isCaughtDynamic = false
@@ -81,7 +81,7 @@
val catchBody = catch.result.transform(object : IrElementTransformer<IrValueSymbol> {
override fun visitGetValue(expression: IrGetValue, data: IrValueSymbol) =
- if (expression.symbol == data)
+ if (expression.target == data)
castedPendingException()
else
expression
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ObjectLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ObjectLowering.kt
index 3c6b1f2..c7551c7 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ObjectLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ObjectLowering.kt
@@ -13,7 +13,6 @@
import org.jetbrains.kotlin.backend.common.lower.irIfThen
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
-import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.builders.declarations.buildField
@@ -83,9 +82,9 @@
override fun lower(irFile: IrFile) {
irFile.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetObjectValue(expression: IrGetObjectValue): IrExpression {
- val obj: IrClass = expression.symbol.owner
+ val obj: IrClass = expression.target
if (obj.isEffectivelyExternal()) return expression
- return JsIrBuilder.buildCall(getOrCreateGetInstanceFunction(objectToGetInstanceFunction, obj).symbol)
+ return JsIrBuilder.buildCall(getOrCreateGetInstanceFunction(objectToGetInstanceFunction, obj))
}
})
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimitiveCompanionLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimitiveCompanionLowering.kt
index 6072e60..a1d6de8 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimitiveCompanionLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimitiveCompanionLowering.kt
@@ -53,7 +53,7 @@
override fun lower(irFile: IrFile) {
irFile.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetObjectValue(expression: IrGetObjectValue): IrExpression {
- val irClass = expression.symbol.owner
+ val irClass = expression.target
val actualCompanion = getActualPrimitiveCompanion(irClass) ?: return expression
return IrGetObjectValueImpl(
expression.startOffset,
@@ -66,7 +66,7 @@
override fun visitCall(expression: IrCall): IrExpression {
val newCall = super.visitCall(expression) as IrCall
- val function = expression.symbol.owner as IrSimpleFunction
+ val function = expression.target as IrSimpleFunction
val actualFunction = getActualPrimitiveCompanionPropertyAccessor(function)
?: return newCall
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt
index 99bcc83..d2860ccc 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt
@@ -69,7 +69,7 @@
override fun visitCall(expression: IrCall): IrExpression {
super.visitCall(expression)
- return memberMap[expression.symbol]?.let {
+ return memberMap[expression.target]?.let {
transformPrivateToStaticCall(expression, it)
} ?: expression
}
@@ -77,7 +77,7 @@
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
super.visitFunctionReference(expression)
- return memberMap[expression.symbol]?.let {
+ return memberMap[expression.target]?.let {
transformPrivateToStaticReference(expression) {
IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset,
@@ -98,7 +98,7 @@
IrPropertyReferenceImpl(
expression.startOffset, expression.endOffset,
expression.type,
- expression.symbol, // TODO remap property symbol based on remapped getter/setter?
+ expression.target, // TODO remap property symbol based on remapped getter/setter?
expression.typeArgumentsCount,
expression.field,
memberMap[expression.getter]?.symbol ?: expression.getter,
@@ -116,7 +116,7 @@
staticTarget.symbol, staticTarget.descriptor,
expression.typeArgumentsCount,
expression.origin,
- expression.superQualifierSymbol
+ expression.irSuperQualifier
)
newExpression.extensionReceiver = expression.extensionReceiver
@@ -213,7 +213,7 @@
staticFunction.body = function.body?.deepCopyWithSymbols(staticFunction)
staticFunction.transform(object : IrElementTransformerVoid() {
- override fun visitGetValue(expression: IrGetValue) = parameterMapping[expression.symbol.owner]?.let {
+ override fun visitGetValue(expression: IrGetValue) = parameterMapping[expression.target]?.let {
expression.run { IrGetValueImpl(startOffset, endOffset, type, it.symbol, origin) }
} ?: expression
}, null)
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt
index 81f5660..0147562 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt
@@ -83,19 +83,19 @@
private fun generateFactoryBody(constructor: IrConstructor, irClass: IrClass, stub: IrSimpleFunction, delegate: IrSimpleFunction) {
val type = irClass.defaultType
val createFunctionIntrinsic = context.intrinsics.jsObjectCreate
- val irCreateCall = JsIrBuilder.buildCall(createFunctionIntrinsic.symbol, type, listOf(type))
- val irDelegateCall = JsIrBuilder.buildCall(delegate.symbol, type).also { call ->
+ val irCreateCall = JsIrBuilder.buildCall(createFunctionIntrinsic, type, listOf(type))
+ val irDelegateCall = JsIrBuilder.buildCall(delegate, type).also { call ->
for (i in 0 until stub.typeParameters.size) {
call.putTypeArgument(i, stub.typeParameters[i].toIrType())
}
for (i in 0 until stub.valueParameters.size) {
- call.putValueArgument(i, JsIrBuilder.buildGetValue(stub.valueParameters[i].symbol))
+ call.putValueArgument(i, JsIrBuilder.buildGetValue(stub.valueParameters[i]))
}
call.putValueArgument(constructor.valueParameters.size, irCreateCall)
}
- val irReturn = JsIrBuilder.buildReturn(stub.symbol, irDelegateCall, context.irBuiltIns.nothingType)
+ val irReturn = JsIrBuilder.buildReturn(stub, irDelegateCall, context.irBuiltIns.nothingType)
stub.body = JsIrBuilder.buildBlockBody(listOf(irReturn))
@@ -104,7 +104,7 @@
private fun generateInitBody(constructor: IrConstructor, irClass: IrClass, delegate: IrSimpleFunction) {
val thisParam = delegate.valueParameters.last()
val oldThisReceiver = irClass.thisReceiver!!
- val retStmt = JsIrBuilder.buildReturn(delegate.symbol, JsIrBuilder.buildGetValue(thisParam.symbol), context.irBuiltIns.nothingType)
+ val retStmt = JsIrBuilder.buildReturn(delegate, JsIrBuilder.buildGetValue(thisParam), context.irBuiltIns.nothingType)
val statements = (constructor.body!!.deepCopyWithSymbols(delegate) as IrStatementContainer).statements
val oldValueParameters = constructor.valueParameters + oldThisReceiver
@@ -131,7 +131,7 @@
IrGetValueImpl(expression.startOffset, expression.endOffset, newThisSymbol.owner.type, newThisSymbol)
)
- override fun visitGetValue(expression: IrGetValue) = symbolMapping[expression.symbol.owner]?.let {
+ override fun visitGetValue(expression: IrGetValue) = symbolMapping[expression.target]?.let {
expression.run { IrGetValueImpl(startOffset, endOffset, type, it.symbol, origin) }
} ?: expression
}
@@ -202,7 +202,7 @@
override fun visitConstructorCall(expression: IrConstructorCall, data: IrFunction?): IrElement {
super.visitConstructorCall(expression, data)
- val target = expression.symbol.owner
+ val target = expression.target
return if (target.isSecondaryConstructorCall) {
val ctor = oldCtorToNewMap.getOrPut(target) {
buildConstructorStubDeclarations(target, target.parentAsClass)
@@ -214,7 +214,7 @@
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: IrFunction?): IrElement {
super.visitDelegatingConstructorCall(expression, data)
- val target = expression.symbol.owner
+ val target = expression.target
return if (target.isSecondaryConstructorCall) {
val klass = target.parentAsClass
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TestGenerator.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TestGenerator.kt
index 83eac2e..1016318 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TestGenerator.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TestGenerator.kt
@@ -15,7 +15,6 @@
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
@@ -42,7 +41,7 @@
private data class FunctionWithBody(val function: IrSimpleFunction, val body: IrBlockBody)
- private fun IrSimpleFunctionSymbol.createInvocation(
+ private fun IrSimpleFunction.createInvocation(
name: String,
parentBody: IrBlockBody,
ignored: Boolean = false
@@ -62,8 +61,8 @@
putValueArgument(0, JsIrBuilder.buildString(context.irBuiltIns.stringType, name))
putValueArgument(1, JsIrBuilder.buildBoolean(context.irBuiltIns.booleanType, ignored))
- val refType = IrSimpleTypeImpl(context.ir.symbols.functionN(0), false, emptyList(), emptyList())
- putValueArgument(2, JsIrBuilder.buildFunctionReference(refType, function.symbol))
+ val refType = IrSimpleTypeImpl(context.ir.symbols.functionN(0).symbol, false, emptyList(), emptyList())
+ putValueArgument(2, JsIrBuilder.buildFunctionReference(refType, function))
}
return FunctionWithBody(function, body)
@@ -102,15 +101,15 @@
body.statements += classVal
body.statements += beforeFuns.map {
- JsIrBuilder.buildCall(it.symbol).apply {
- dispatchReceiver = JsIrBuilder.buildGetValue(classVal.symbol)
+ JsIrBuilder.buildCall(it).apply {
+ dispatchReceiver = JsIrBuilder.buildGetValue(classVal)
}
}
val returnStatement = JsIrBuilder.buildReturn(
- fn.symbol,
- JsIrBuilder.buildCall(testFun.symbol).apply {
- dispatchReceiver = JsIrBuilder.buildGetValue(classVal.symbol)
+ fn,
+ JsIrBuilder.buildCall(testFun).apply {
+ dispatchReceiver = JsIrBuilder.buildGetValue(classVal)
},
context.irBuiltIns.unitType
)
@@ -122,8 +121,8 @@
tryResult = returnStatement
finallyExpression = JsIrBuilder.buildComposite(context.irBuiltIns.unitType).apply {
statements += afterFuns.map {
- JsIrBuilder.buildCall(it.symbol).apply {
- dispatchReceiver = JsIrBuilder.buildGetValue(classVal.symbol)
+ JsIrBuilder.buildCall(it).apply {
+ dispatchReceiver = JsIrBuilder.buildGetValue(classVal)
}
}
}
@@ -133,10 +132,10 @@
private fun IrClass.instance(): IrExpression {
return if (kind == ClassKind.OBJECT) {
- JsIrBuilder.buildGetObjectValue(defaultType, symbol)
+ JsIrBuilder.buildGetObjectValue(defaultType, this)
} else {
declarations.asSequence().filterIsInstance<IrConstructor>().single { it.isPrimary }.let { constructor ->
- IrConstructorCallImpl.fromSymbolOwner(defaultType, constructor.symbol).also {
+ IrConstructorCallImpl.fromSymbolOwner(defaultType, constructor).also {
if (isInner) {
it.dispatchReceiver = (parent as IrClass).instance()
}
@@ -158,5 +157,5 @@
get() = hasAnnotation("kotlin.test.AfterTest")
private fun IrAnnotationContainer.hasAnnotation(fqName: String) =
- annotations.any { it.symbol.owner.fqNameWhenAvailable?.parent()?.asString() == fqName }
+ annotations.any { it.target.fqNameWhenAvailable?.parent()?.asString() == fqName }
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt
index 1b3ac75..4672c58 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt
@@ -6,23 +6,16 @@
package org.jetbrains.kotlin.ir.backend.js.lower
import org.jetbrains.kotlin.backend.common.FileLoweringPass
-import org.jetbrains.kotlin.backend.common.lower.callsSuper
-import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
-import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
import org.jetbrains.kotlin.ir.declarations.IrClass
-import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.types.isNullableString
-import org.jetbrains.kotlin.ir.types.isString
import org.jetbrains.kotlin.ir.types.makeNotNull
-import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.isThrowable
-import org.jetbrains.kotlin.ir.util.isThrowableTypeOrSubtype
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
@@ -53,7 +46,7 @@
)
else -> {
val arg = getValueArgument(0)!!
- val parameter = symbol.owner.valueParameters[0]
+ val parameter = target.valueParameters[0]
when {
parameter.type.isNullableString() -> ThrowableArguments(message = arg, cause = nullValue())
else -> {
@@ -69,7 +62,7 @@
override fun visitConstructorCall(expression: IrConstructorCall, data: IrDeclarationParent): IrExpression {
expression.transformChildren(this, data)
- if (expression.symbol !in throwableConstructors) return expression
+ if (expression.target !in throwableConstructors) return expression
val (messageArg, causeArg) = expression.extractThrowableArguments()
@@ -83,7 +76,7 @@
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: IrDeclarationParent): IrExpression {
expression.transformChildren(this, data)
- if (expression.symbol !in throwableConstructors) return expression
+ if (expression.target !in throwableConstructors) return expression
val (messageArg, causeArg) = expression.extractThrowableArguments()
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt
index 2532087..88a9e1d 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/TypeOperatorLowering.kt
@@ -27,7 +27,7 @@
class TypeOperatorLowering(val context: JsIrBackendContext) : FileLoweringPass {
private val unit = context.irBuiltIns.unitType
- private val unitValue get() = JsIrBuilder.buildGetObjectValue(unit, unit.classifierOrFail as IrClassSymbol)
+ private val unitValue get() = JsIrBuilder.buildGetObjectValue(unit, unit.classifierOrFail as IrClass)
private val lit24 get() = JsIrBuilder.buildInt(context.irBuiltIns.intType, 24)
private val lit16 get() = JsIrBuilder.buildInt(context.irBuiltIns.intType, 16)
@@ -184,7 +184,7 @@
): () -> IrExpressionWithCopy {
val varDeclaration = JsIrBuilder.buildVar(value.type, declaration, initializer = value)
newStatements += varDeclaration
- return { JsIrBuilder.buildGetValue(varDeclaration.symbol) }
+ return { JsIrBuilder.buildGetValue(varDeclaration) }
}
private fun generateTypeCheck(argument: () -> IrExpressionWithCopy, toType: IrType): IrExpression {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/VarargLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/VarargLowering.kt
index 36cda0b..339ba4d 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/VarargLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/VarargLowering.kt
@@ -9,7 +9,6 @@
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.declarations.IrFile
-import org.jetbrains.kotlin.ir.declarations.name
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
@@ -189,7 +188,7 @@
for (i in 0 until size) {
val argument = expression.getValueArgument(i)
- val parameter = expression.symbol.owner.valueParameters[i]
+ val parameter = expression.target.valueParameters[i]
val varargElementType = parameter.varargElementType
if (argument == null && varargElementType != null) {
val arrayInfo = InlineClassArrayInfo(varargElementType, parameter.type)
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/BuiltInConstructorCalls.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/BuiltInConstructorCalls.kt
index 1d6da11..35ef1db 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/BuiltInConstructorCalls.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/BuiltInConstructorCalls.kt
@@ -19,7 +19,7 @@
override fun transformFunctionAccess(call: IrFunctionAccessExpression): IrExpression =
if (call is IrConstructorCall) {
// Do not transform Delegation calls
- when (call.symbol) {
+ when (call.target) {
intrinsics.stringConstructorSymbol -> JsIrBuilder.buildString(context.irBuiltIns.stringType, "")
intrinsics.anyConstructorSymbol -> irConstructorCall(call, intrinsics.jsObjectConstructorSymbol)
else -> call
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLoweringUtils.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLoweringUtils.kt
index 9391699..c7fb4e9 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLoweringUtils.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLoweringUtils.kt
@@ -8,31 +8,30 @@
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.irCall
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.SimpleType
-typealias SymbolToTransformer = MutableMap<IrFunctionSymbol, (IrFunctionAccessExpression) -> IrExpression>
+typealias FunctionToTransformer = MutableMap<IrFunction, (IrFunctionAccessExpression) -> IrExpression>
-internal fun SymbolToTransformer.add(from: Map<SimpleType, IrFunctionSymbol>, to: IrFunctionSymbol) {
+internal fun FunctionToTransformer.add(from: Map<SimpleType, IrFunction>, to: IrFunction) {
from.forEach { _, func ->
add(func, to)
}
}
-internal fun SymbolToTransformer.add(from: Map<SimpleType, IrFunctionSymbol>, to: (IrFunctionAccessExpression) -> IrExpression) {
+internal fun FunctionToTransformer.add(from: Map<SimpleType, IrFunction>, to: (IrFunctionAccessExpression) -> IrExpression) {
from.forEach { _, func ->
add(func, to)
}
}
-internal fun SymbolToTransformer.add(from: IrFunctionSymbol, to: (IrFunctionAccessExpression) -> IrExpression) {
+internal fun FunctionToTransformer.add(from: IrFunction, to: (IrFunctionAccessExpression) -> IrExpression) {
put(from, to)
}
-internal fun SymbolToTransformer.add(from: IrFunctionSymbol, to: IrFunctionSymbol, dispatchReceiverAsFirstArgument: Boolean = false) {
+internal fun FunctionToTransformer.add(from: IrFunction, to: IrFunction, dispatchReceiverAsFirstArgument: Boolean = false) {
put(from) { call -> irCall(call, to, dispatchReceiverAsFirstArgument) }
}
@@ -46,12 +45,8 @@
internal typealias MemberToTransformer = HashMap<SimpleMemberKey, (IrFunctionAccessExpression) -> IrExpression>
-internal fun MemberToTransformer.add(type: IrType, name: Name, v: IrFunctionSymbol) {
- add(type, name) { irCall(it, v, receiversAsArguments = true) }
-}
-
internal fun MemberToTransformer.add(type: IrType, name: Name, v: IrFunction) {
- add(type, name, v.symbol)
+ add(type, name) { irCall(it, v, receiversAsArguments = true) }
}
internal fun MemberToTransformer.add(type: IrType, name: Name, v: (IrFunctionAccessExpression) -> IrExpression) {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EnumIntrinsicsTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EnumIntrinsicsTransformer.kt
index daba1d1..970bb25 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EnumIntrinsicsTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EnumIntrinsicsTransformer.kt
@@ -27,7 +27,7 @@
if (!enum.isEnumClass) return call
val staticMethod = enum.findDeclaration(staticMethodPredicate)
if (staticMethod == null || !staticMethod.isStaticMethodOfClass)
- throw IllegalStateException("Enum class should have static method for ${call.symbol.owner.name}")
+ throw IllegalStateException("Enum class should have static method for ${call.target.name}")
return irCall(call, staticMethod.symbol)
}
@@ -42,7 +42,7 @@
it.name == Name.identifier("values") && it.valueParameters.count() == 0
}
- override fun transformFunctionAccess(call: IrFunctionAccessExpression) = when (call.symbol) {
+ override fun transformFunctionAccess(call: IrFunctionAccessExpression) = when (call.target) {
context.intrinsics.enumValueOfIntrinsic -> transformEnumValueOfIntrinsic(call)
context.intrinsics.enumValuesIntrinsic -> transformEnumValuesIntrinsic(call)
else -> call
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EqualityAndComparisonCallsTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EqualityAndComparisonCallsTransformer.kt
index 4f5fcba..6330d77 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EqualityAndComparisonCallsTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EqualityAndComparisonCallsTransformer.kt
@@ -23,10 +23,10 @@
private val intrinsics = context.intrinsics
private val irBuiltIns = context.irBuiltIns
- private val symbolToTransformer: SymbolToTransformer = mutableMapOf()
+ private val functionToTransformer: FunctionToTransformer = mutableMapOf()
init {
- symbolToTransformer.run {
+ functionToTransformer.run {
add(irBuiltIns.eqeqeqSymbol, intrinsics.jsEqeqeq)
add(irBuiltIns.eqeqSymbol, ::transformEqeqOperator)
// ieee754equals can only be applied in between statically known Floats, Doubles, null or undefined
@@ -59,12 +59,12 @@
}
override fun transformFunctionAccess(call: IrFunctionAccessExpression): IrExpression {
- val symbol = call.symbol
- symbolToTransformer[symbol]?.let {
+ val target = call.target
+ functionToTransformer[target]?.let {
return it(call)
}
- return when (symbol.owner.name) {
+ return when (target.name) {
Name.identifier("compareTo") -> transformCompareToMethodCall(call)
Name.identifier("equals") -> transformEqualsMethodCall(call as IrCall)
else -> call
@@ -113,14 +113,14 @@
(0 until valueArgumentsCount).all { getValueArgument(it)!!.type.isNullable() }
private fun transformCompareToMethodCall(call: IrFunctionAccessExpression): IrExpression {
- val function = call.symbol.owner as IrSimpleFunction
+ val function = call.target as IrSimpleFunction
if (function.parent !is IrClass) return call
fun IrSimpleFunction.isFakeOverriddenFromComparable(): Boolean = when {
origin != IrDeclarationOrigin.FAKE_OVERRIDE ->
!isStaticMethodOfClass && parentAsClass.thisReceiver!!.type.isComparable()
- else -> overriddenSymbols.all { it.owner.isFakeOverriddenFromComparable() }
+ else -> overridden.all { it.isFakeOverriddenFromComparable() }
}
return when {
@@ -137,7 +137,7 @@
private fun transformEqualsMethodCall(call: IrCall): IrExpression {
- val function = call.symbol.owner
+ val function = call.target
return when {
// Nothing special
!function.isEqualsInheritedFromAny() -> call
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ExceptionHelperCallsTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ExceptionHelperCallsTransformer.kt
index 4c5a7a9..0a8b9c9 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ExceptionHelperCallsTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ExceptionHelperCallsTransformer.kt
@@ -27,5 +27,5 @@
)
override fun transformFunctionAccess(call: IrFunctionAccessExpression) =
- helperMapping[call.symbol]?.let { irCall(call, it) } ?: call
+ helperMapping[call.target]?.let { irCall(call, it) } ?: call
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/JsonIntrinsics.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/JsonIntrinsics.kt
index 240a84b..c059925 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/JsonIntrinsics.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/JsonIntrinsics.kt
@@ -32,7 +32,7 @@
}
}
- when (call.symbol.owner.fqNameWhenAvailable) {
+ when (call.target.fqNameWhenAvailable) {
FqName("kotlin.js.Json.get") ->
return generateMemberAccess()
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/MethodsOfAnyCallsTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/MethodsOfAnyCallsTransformer.kt
index 2f5a62a..35504bb 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/MethodsOfAnyCallsTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/MethodsOfAnyCallsTransformer.kt
@@ -39,7 +39,7 @@
}
put(Name.identifier("hashCode")) { call ->
- if (call.symbol.owner.isFakeOverriddenFromAny()) {
+ if (call.target.isFakeOverriddenFromAny()) {
if ((call as IrCall).isSuperToAny()) {
irCall(call, intrinsics.jsGetObjectHashCode, receiversAsArguments = true)
} else {
@@ -54,8 +54,8 @@
override fun transformFunctionAccess(call: IrFunctionAccessExpression): IrExpression {
- val symbol = call.symbol
- nameToTransformer[symbol.owner.name]?.let {
+ val target = call.target
+ nameToTransformer[target.name]?.let {
return it(call)
}
@@ -63,7 +63,7 @@
}
private fun shouldReplaceToStringWithRuntimeCall(call: IrFunctionAccessExpression): Boolean {
- val function = call.symbol.owner
+ val function = call.target
if (function.valueParameters.size != 0 && function.name.asString() != "toString" )
return false
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberConversionCallsTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberConversionCallsTransformer.kt
index a286e73..91927168 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberConversionCallsTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberConversionCallsTransformer.kt
@@ -8,7 +8,6 @@
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
import org.jetbrains.kotlin.ir.backend.js.utils.ConversionNames
-import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
@@ -76,7 +75,7 @@
}
override fun transformFunctionAccess(call: IrFunctionAccessExpression): IrExpression {
- val function = call.symbol.owner
+ val function = call.target
function.dispatchReceiverParameter?.also {
val key = SimpleMemberKey(it.type, function.name)
memberToTransformer[key]?.also {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberOperatorCallsTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberOperatorCallsTransformer.kt
index 2690a9c..9068319 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberOperatorCallsTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/NumberOperatorCallsTransformer.kt
@@ -8,6 +8,7 @@
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
import org.jetbrains.kotlin.ir.backend.js.utils.OperatorNames
+import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
@@ -73,7 +74,7 @@
}
override fun transformFunctionAccess(call: IrFunctionAccessExpression): IrExpression {
- val function = call.symbol.owner
+ val function = call.target
function.dispatchReceiverParameter?.also {
val key = SimpleMemberKey(it.type, function.name)
memberToTransformer[key]?.also {
@@ -85,7 +86,7 @@
private fun transformRangeTo(call: IrFunctionAccessExpression): IrExpression {
if (call.valueArgumentsCount != 1) return call
- return with(call.symbol.owner.valueParameters[0].type) {
+ return with(call.target.valueParameters[0].type) {
when {
isByte() || isShort() || isInt() ->
irCall(call, intrinsics.jsNumberRangeToNumber, receiversAsArguments = true)
@@ -108,7 +109,7 @@
}
class BinaryOp(call: IrFunctionAccessExpression) {
- val function = call.symbol.owner
+ val function = call.target
val name = function.name
val lhs = function.dispatchReceiverParameter!!.type
val rhs = function.valueParameters[0].type
@@ -224,8 +225,8 @@
}
}
- fun IrFunctionSymbol.call(vararg arguments: IrExpression) =
- JsIrBuilder.buildCall(this, owner.returnType).apply {
+ fun IrFunction.call(vararg arguments: IrExpression) =
+ JsIrBuilder.buildCall(this, returnType).apply {
for ((idx, arg) in arguments.withIndex()) {
putValueArgument(idx, arg)
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/PrimitiveContainerMemberCallTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/PrimitiveContainerMemberCallTransformer.kt
index 35b9fd1..6564b09 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/PrimitiveContainerMemberCallTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/PrimitiveContainerMemberCallTransformer.kt
@@ -7,23 +7,20 @@
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.declarations.IrConstructor
-import org.jetbrains.kotlin.ir.expressions.IrCall
-import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.util.getSimpleFunction
import org.jetbrains.kotlin.ir.util.getPropertyGetter
class PrimitiveContainerMemberCallTransformer(private val context: JsIrBackendContext) : CallsTransformer {
private val intrinsics = context.intrinsics
- private val symbolToTransformer: SymbolToTransformer = mutableMapOf()
+ private val functionToTransformer: FunctionToTransformer = mutableMapOf()
init {
- symbolToTransformer.run {
+ functionToTransformer.run {
// Arrays
add(context.intrinsics.array.sizeProperty, context.intrinsics.jsArrayLength, true)
add(context.intrinsics.array.getFunction, context.intrinsics.jsArrayGet, true)
@@ -60,8 +57,8 @@
}
override fun transformFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
- val symbol = expression.symbol
- symbolToTransformer[symbol]?.let {
+ val symbol = expression.target
+ functionToTransformer[symbol]?.let {
return it(expression)
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ReflectionCallsTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ReflectionCallsTransformer.kt
index e85bf48..cc8673d 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ReflectionCallsTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ReflectionCallsTransformer.kt
@@ -34,7 +34,7 @@
addWithPredicate(
Name.special(Namer.KCALLABLE_GET_NAME),
{ call ->
- call.symbol.owner.dispatchReceiverParameter?.run { type.isSubtypeOfClass(context.irBuiltIns.kCallableClass) } ?: false
+ call.target.dispatchReceiverParameter?.run { type.isSubtypeOfClass(context.irBuiltIns.kCallableClass) } ?: false
},
{ call ->
IrDynamicMemberExpressionImpl(
@@ -49,7 +49,7 @@
addWithPredicate(
Name.identifier(Namer.KPROPERTY_GET),
{ call ->
- call.symbol.owner.dispatchReceiverParameter?.run { type.isSubtypeOfClass(context.irBuiltIns.kPropertyClass) } ?: false
+ call.target.dispatchReceiverParameter?.run { type.isSubtypeOfClass(context.irBuiltIns.kPropertyClass) } ?: false
},
{ call -> buildDynamicCall(Namer.KPROPERTY_GET, call) }
)
@@ -57,7 +57,7 @@
addWithPredicate(
Name.identifier(Namer.KPROPERTY_SET),
{ call ->
- call.symbol.owner.dispatchReceiverParameter?.run { type.isSubtypeOfClass(context.irBuiltIns.kPropertyClass) } ?: false
+ call.target.dispatchReceiverParameter?.run { type.isSubtypeOfClass(context.irBuiltIns.kPropertyClass) } ?: false
},
{ call -> buildDynamicCall(Namer.KPROPERTY_SET, call) }
)
@@ -65,8 +65,8 @@
}
override fun transformFunctionAccess(call: IrFunctionAccessExpression): IrExpression {
- val symbol = call.symbol
- nameToTransformer[symbol.owner.name]?.let {
+ val symbol = call.target
+ nameToTransformer[symbol.name]?.let {
return it(call)
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/JsSuspendFunctionsLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/JsSuspendFunctionsLowering.kt
index 69a210d..9d43965 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/JsSuspendFunctionsLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/JsSuspendFunctionsLowering.kt
@@ -15,9 +15,7 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.util.explicitParameters
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
import org.jetbrains.kotlin.ir.visitors.*
@@ -65,8 +63,8 @@
stateMachineFunction,
"suspendResult",
true,
- initializer = JsIrBuilder.buildCall(coroutineImplResultSymbolGetter.symbol).apply {
- dispatchReceiver = JsIrBuilder.buildGetValue(stateMachineFunction.dispatchReceiverParameter!!.symbol)
+ initializer = JsIrBuilder.buildCall(coroutineImplResultSymbolGetter).apply {
+ dispatchReceiver = JsIrBuilder.buildGetValue(stateMachineFunction.dispatchReceiverParameter!!)
}
)
@@ -88,7 +86,7 @@
}
val suspendableNodes = collectSuspendableNodes(body)
- val thisReceiver = (stateMachineFunction.dispatchReceiverParameter as IrValueParameter).symbol
+ val thisReceiver = stateMachineFunction.dispatchReceiverParameter as IrValueParameter
val stateMachineBuilder = StateMachineBuilder(
suspendableNodes,
@@ -126,36 +124,35 @@
override fun visitReturn(expression: IrReturn): IrExpression {
expression.transformChildrenVoid(this)
- return if (expression.returnTargetSymbol != simplifiedFunction.symbol)
+ return if (expression.irReturnTarget != simplifiedFunction.symbol)
expression
else
- JsIrBuilder.buildReturn(stateMachineFunction.symbol, expression.value, expression.type)
+ JsIrBuilder.buildReturn(stateMachineFunction, expression.value, expression.type)
}
})
val liveLocals = computeLivenessAtSuspensionPoints(functionBody).values.flatten().toSet()
- val localToPropertyMap = mutableMapOf<IrValueSymbol, IrFieldSymbol>()
+ val localToPropertyMap = mutableMapOf<IrValueDeclaration, IrField>()
var localCounter = 0
// TODO: optimize by using the same property for different locals.
liveLocals.forEach {
if (it != suspendState && it != suspendResult) {
- localToPropertyMap.getOrPut(it.symbol) {
+ localToPropertyMap.getOrPut(it) {
coroutineClass.addField(Name.identifier("${it.name}${localCounter++}"), it.type, (it as? IrVariable)?.isVar ?: false)
- .symbol
}
}
}
simplifiedFunction.explicitParameters.forEach {
- localToPropertyMap.getOrPut(it.symbol) {
- argumentToPropertiesMap.getValue(it).symbol
+ localToPropertyMap.getOrPut(it) {
+ argumentToPropertiesMap.getValue(it)
}
}
stateMachineFunction.transform(LiveLocalsTransformer(localToPropertyMap, { JsIrBuilder.buildGetValue(thisReceiver) }, unit), null)
}
- private fun assignStateIds(entryState: SuspendState, thisReceiver: IrValueParameterSymbol, switch: IrWhen, rootLoop: IrLoop) {
+ private fun assignStateIds(entryState: SuspendState, thisReceiver: IrValueParameter, switch: IrWhen, rootLoop: IrLoop) {
val visited = mutableSetOf<SuspendState>()
val sortedStates = DFS.topologicalOrder(listOf(entryState), { it.successors }, { visited.add(it) })
@@ -165,7 +162,7 @@
for (state in sortedStates) {
val condition = JsIrBuilder.buildCall(eqeqeqInt).apply {
- putValueArgument(0, JsIrBuilder.buildCall(coroutineImplLabelPropertyGetter.symbol).also {
+ putValueArgument(0, JsIrBuilder.buildCall(coroutineImplLabelPropertyGetter).also {
it.dispatchReceiver = JsIrBuilder.buildGetValue(thisReceiver)
})
putValueArgument(1, JsIrBuilder.buildInt(context.irBuiltIns.intType, state.id))
@@ -204,10 +201,10 @@
override fun initializeStateMachine(coroutineConstructors: List<IrConstructor>, coroutineClassThis: IrValueDeclaration) {
for (it in coroutineConstructors) {
(it.body as? IrBlockBody)?.run {
- val receiver = JsIrBuilder.buildGetValue(coroutineClassThis.symbol)
+ val receiver = JsIrBuilder.buildGetValue(coroutineClassThis)
assert(exceptionTrapId >= 0)
val id = JsIrBuilder.buildInt(context.irBuiltIns.intType, exceptionTrapId)
- statements += JsIrBuilder.buildCall(coroutineImplExceptionStatePropertySetter.symbol).also { call ->
+ statements += JsIrBuilder.buildCall(coroutineImplExceptionStatePropertySetter).also { call ->
call.dispatchReceiver = receiver
call.putValueArgument(0, id)
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt
index a0b5366..bac4e2a 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt
@@ -16,13 +16,12 @@
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
+import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
import org.jetbrains.kotlin.ir.visitors.*
@@ -63,8 +62,8 @@
private val exStateSymbolGetter: IrSimpleFunction,
private val exStateSymbolSetter: IrSimpleFunction,
private val stateSymbolSetter: IrSimpleFunction,
- private val thisSymbol: IrValueParameterSymbol,
- private val suspendResult: IrVariableSymbol
+ private val thisValueParameter: IrValueParameter,
+ private val suspendResult: IrVariable
) : IrElementVisitorVoid {
private val loopMap = mutableMapOf<IrLoop, LoopBounds>()
@@ -73,7 +72,7 @@
private val booleanNotSymbol = context.irBuiltIns.booleanNotSymbol
private val eqeqeqSymbol = context.irBuiltIns.eqeqeqSymbol
- private val thisReceiver get() = JsIrBuilder.buildGetValue(thisSymbol)
+ private val thisReceiver get() = JsIrBuilder.buildGetValue(thisValueParameter)
private var hasExceptions = false
@@ -93,7 +92,6 @@
private fun buildGlobalCatch(): IrCatch {
val catchVariable = globalExceptionVar
- val globalExceptionSymbol = globalExceptionVar.symbol
val block = JsIrBuilder.buildBlock(unit)
if (hasExceptions) {
val thenBlock = JsIrBuilder.buildBlock(unit)
@@ -105,22 +103,22 @@
block.statements += JsIrBuilder.buildIfElse(unit, check, thenBlock, elseBlock)
thenBlock.statements += JsIrBuilder.buildThrow(
nothing,
- JsIrBuilder.buildGetValue(globalExceptionSymbol)
+ JsIrBuilder.buildGetValue(catchVariable)
)
// TODO: exception table
- elseBlock.statements += JsIrBuilder.buildCall(stateSymbolSetter.symbol, unit).apply {
+ elseBlock.statements += JsIrBuilder.buildCall(stateSymbolSetter, unit).apply {
dispatchReceiver = thisReceiver
putValueArgument(0, exceptionState())
}
- elseBlock.statements += JsIrBuilder.buildCall(exceptionSymbolSetter.symbol, unit).apply {
+ elseBlock.statements += JsIrBuilder.buildCall(exceptionSymbolSetter, unit).apply {
dispatchReceiver = thisReceiver
- putValueArgument(0, JsIrBuilder.buildGetValue(globalExceptionSymbol))
+ putValueArgument(0, JsIrBuilder.buildGetValue(catchVariable))
}
} else {
block.statements += JsIrBuilder.buildThrow(
nothing,
- JsIrBuilder.buildGetValue(globalExceptionSymbol)
+ JsIrBuilder.buildGetValue(catchVariable)
)
}
@@ -130,7 +128,7 @@
private var currentState = entryState
private var currentBlock = entryState.entryBlock
- private val returnableBlockMap = mutableMapOf<IrReturnableBlockSymbol, Pair<SuspendState, IrVariableSymbol?>>()
+ private val returnableBlockMap = mutableMapOf<IrReturnableBlockSymbol, Pair<SuspendState, IrVariable?>>()
private val catchBlockStack = mutableListOf(rootExceptionTrap)
@@ -175,7 +173,7 @@
private fun doDispatchImpl(target: SuspendState, block: IrContainerExpression, andContinue: Boolean) {
val irDispatch = IrDispatchPoint(target)
currentState.successors.add(target)
- block.addStatement(JsIrBuilder.buildCall(stateSymbolSetter.symbol, unit).apply {
+ block.addStatement(JsIrBuilder.buildCall(stateSymbolSetter, unit).apply {
dispatchReceiver = thisReceiver
putValueArgument(0, irDispatch)
})
@@ -255,9 +253,7 @@
val exitState = SuspendState(unit)
val resultVariable = if (hasResultingValue(expression)) {
- val irVar = tempVar(expression.type, "RETURNABLE_BLOCK")
- addStatement(irVar)
- irVar.symbol
+ tempVar(expression.type, "RETURNABLE_BLOCK").also { addStatement(it) }
} else null
returnableBlockMap[expression.symbol] = Pair(exitState, resultVariable)
@@ -292,7 +288,7 @@
currentState.successors += continueState
transformLastExpression {
- JsIrBuilder.buildCall(stateSymbolSetter.symbol, unit).apply {
+ JsIrBuilder.buildCall(stateSymbolSetter, unit).apply {
dispatchReceiver = thisReceiver
putValueArgument(0, dispatch)
}
@@ -325,7 +321,7 @@
doDispatch(headState)
}
- private fun wrap(expression: IrExpression, variable: IrVariableSymbol) =
+ private fun wrap(expression: IrExpression, variable: IrVariable) =
JsIrBuilder.buildSetVariable(variable, expression, unit)
override fun visitWhen(expression: IrWhen) {
@@ -334,16 +330,16 @@
val exitState = SuspendState(expression.type)
- val varSymbol: IrVariableSymbol?
+ val variable: IrVariable?
val branches: List<IrBranch>
if (hasResultingValue(expression)) {
val irVar = tempVar(expression.type, "WHEN_RESULT")
- varSymbol = irVar.symbol
+ variable = irVar
addStatement(irVar)
branches = expression.branches.map {
- val wrapped = wrap(it.result, varSymbol)
+ val wrapped = wrap(it.result, variable)
if (it.result in suspendableNodes) {
suspendableNodes += wrapped
}
@@ -353,7 +349,7 @@
}
}
} else {
- varSymbol = null
+ variable = null
branches = expression.branches
}
@@ -390,8 +386,8 @@
maybeDoDispatch(exitState)
updateState(exitState)
- if (varSymbol != null) {
- addStatement(JsIrBuilder.buildGetValue(varSymbol))
+ if (variable != null) {
+ addStatement(JsIrBuilder.buildGetValue(variable))
}
}
@@ -439,7 +435,7 @@
transformLastExpression {
irVar.apply { initializer = it }
}
- JsIrBuilder.buildGetValue(irVar.symbol)
+ JsIrBuilder.buildGetValue(irVar)
} else {
arg?.deepCopyWithSymbols(function.owner)
}
@@ -487,12 +483,12 @@
IrSetFieldImpl(
startOffset,
endOffset,
- symbol,
+ target,
receiver,
value,
unit,
origin,
- superQualifierSymbol
+ irSuperQualifier
)
})
}
@@ -520,10 +516,10 @@
override fun visitReturn(expression: IrReturn) {
expression.acceptChildrenVoid(this)
- if (expression.returnTargetSymbol is IrReturnableBlockSymbol) {
- val (exitState, varSymbol) = returnableBlockMap[expression.returnTargetSymbol]!!
- if (varSymbol != null) {
- transformLastExpression { JsIrBuilder.buildSetVariable(varSymbol, it, it.type) }
+ if (expression.irReturnTarget is IrReturnableBlockSymbol) {
+ val (exitState, irVar) = returnableBlockMap[expression.irReturnTarget]!!
+ if (irVar != null) {
+ transformLastExpression { JsIrBuilder.buildSetVariable(irVar, it, it.type) }
}
maybeDoDispatch(exitState)
} else {
@@ -555,17 +551,17 @@
val exitState = SuspendState(unit)
- val varSymbol = if (hasResultingValue(aTry)) tempVar(aTry.type, "TRY_RESULT") else null
+ val variable = if (hasResultingValue(aTry)) tempVar(aTry.type, "TRY_RESULT") else null
- if (varSymbol != null) {
- addStatement(varSymbol)
+ if (variable != null) {
+ addStatement(variable)
}
// TODO: refact it with exception table, see coroutinesInternal.kt
setupExceptionState(tryState.catchState)
- val tryResult = if (varSymbol != null) {
- JsIrBuilder.buildSetVariable(varSymbol.symbol, aTry.tryResult, unit).also {
+ val tryResult = if (variable != null) {
+ JsIrBuilder.buildSetVariable(variable, aTry.tryResult, unit).also {
if (it.value in suspendableNodes) suspendableNodes += it
}
} else aTry.tryResult
@@ -591,8 +587,8 @@
val irVar = catch.catchParameter.also {
it.initializer = initializer
}
- val catchResult = if (varSymbol != null) {
- JsIrBuilder.buildSetVariable(varSymbol.symbol, catch.result, unit).also {
+ val catchResult = if (variable != null) {
+ JsIrBuilder.buildSetVariable(variable, catch.result, unit).also {
if (it.value in suspendableNodes) suspendableNodes += it
}
} else catch.result
@@ -633,22 +629,22 @@
updateState(exitState)
- if (varSymbol != null) {
- addStatement(JsIrBuilder.buildGetValue(varSymbol.symbol))
+ if (variable != null) {
+ addStatement(JsIrBuilder.buildGetValue(variable))
}
}
private fun setupExceptionState(target: SuspendState) {
addStatement(
- JsIrBuilder.buildCall(exStateSymbolSetter.symbol, unit).apply {
+ JsIrBuilder.buildCall(exStateSymbolSetter, unit).apply {
dispatchReceiver = thisReceiver
putValueArgument(0, IrDispatchPoint(target))
}
)
}
- private fun exceptionState() = JsIrBuilder.buildCall(exStateSymbolGetter.symbol).also { it.dispatchReceiver = thisReceiver }
- private fun pendingException() = JsIrBuilder.buildCall(exceptionSymbolGetter.symbol).also { it.dispatchReceiver = thisReceiver }
+ private fun exceptionState() = JsIrBuilder.buildCall(exStateSymbolGetter).also { it.dispatchReceiver = thisReceiver }
+ private fun pendingException() = JsIrBuilder.buildCall(exceptionSymbolGetter).also { it.dispatchReceiver = thisReceiver }
private fun buildTryState() = TryState(currentState, SuspendState(unit))
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendLoweringUtils.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendLoweringUtils.kt
index c4e46dd..c5dd810 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendLoweringUtils.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendLoweringUtils.kt
@@ -6,18 +6,15 @@
package org.jetbrains.kotlin.ir.backend.js.lower.coroutines
import org.jetbrains.kotlin.backend.common.ir.isSuspend
-import org.jetbrains.kotlin.backend.common.pop
-import org.jetbrains.kotlin.backend.common.push
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
+import org.jetbrains.kotlin.ir.declarations.IrField
+import org.jetbrains.kotlin.ir.declarations.IrValueDeclaration
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
-import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.*
@@ -64,7 +61,7 @@
override fun visitReturn(expression: IrReturn) {
super.visitReturn(expression)
- if (expression.returnTargetSymbol is IrReturnableBlockSymbol && isSuspendableNode(expression.returnTargetSymbol.owner)) {
+ if (expression.irReturnTarget is IrReturnableBlock && isSuspendableNode(expression.irReturnTarget)) {
markNode(expression)
}
}
@@ -82,19 +79,19 @@
}
class LiveLocalsTransformer(
- private val localMap: Map<IrValueSymbol, IrFieldSymbol>,
+ private val localMap: Map<IrValueDeclaration, IrField>,
private val receiver: () -> IrExpression,
private val unitType: IrType
) :
IrElementTransformerVoid() {
override fun visitGetValue(expression: IrGetValue): IrExpression {
- val field = localMap[expression.symbol] ?: return expression
+ val field = localMap[expression.target] ?: return expression
return expression.run { IrGetFieldImpl(startOffset, endOffset, field, type, receiver(), origin) }
}
override fun visitSetVariable(expression: IrSetVariable): IrExpression {
expression.transformChildrenVoid(this)
- val field = localMap[expression.symbol] ?: return expression
+ val field = localMap[expression.target] ?: return expression
return expression.run { IrSetFieldImpl(startOffset, endOffset, field, receiver(), value, unitType, origin) }
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsExpressionTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsExpressionTransformer.kt
index 44cee71..97f09cb 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsExpressionTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsExpressionTransformer.kt
@@ -10,12 +10,10 @@
import org.jetbrains.kotlin.ir.backend.js.utils.*
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrConstructor
-import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.types.isUnit
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.js.backend.ast.*
-import org.jetbrains.kotlin.util.OperatorNameConventions
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
class IrElementToJsExpressionTransformer : BaseIrElementToJsNodeTransformer<JsExpression, JsGenerationContext> {
@@ -29,7 +27,7 @@
body.expression.accept(this, context)
override fun visitFunctionReference(expression: IrFunctionReference, context: JsGenerationContext): JsExpression {
- val irFunction = expression.symbol.owner
+ val irFunction = expression.target
return irFunction.accept(IrFunctionToJsTransformer(), context).apply { name = null }
}
@@ -63,9 +61,7 @@
}
override fun visitGetField(expression: IrGetField, context: JsGenerationContext): JsExpression {
- val symbol = expression.symbol
- val field = symbol.owner
-
+ val field = expression.target
val fieldParent = field.parent
if (fieldParent is IrClass && field.isEffectivelyExternal()) {
@@ -85,37 +81,37 @@
}
override fun visitGetValue(expression: IrGetValue, context: JsGenerationContext): JsExpression =
- context.getNameForValueDeclaration(expression.symbol.owner).makeRef()
+ context.getNameForValueDeclaration(expression.target).makeRef()
override fun visitGetObjectValue(expression: IrGetObjectValue, context: JsGenerationContext): JsExpression {
- val obj = expression.symbol.owner
+ val obj = expression.target
assert(obj.kind == ClassKind.OBJECT)
assert(obj.isEffectivelyExternal()) { "Non external IrGetObjectValue must be lowered" }
return context.getRefForExternalClass(obj)
}
override fun visitSetField(expression: IrSetField, context: JsGenerationContext): JsExpression {
- val fieldName = context.getNameForField(expression.symbol.owner)
+ val fieldName = context.getNameForField(expression.target)
val dest = JsNameRef(fieldName, expression.receiver?.accept(this, context))
val source = expression.value.accept(this, context)
return jsAssignment(dest, source)
}
override fun visitSetVariable(expression: IrSetVariable, context: JsGenerationContext): JsExpression {
- val ref = JsNameRef(context.getNameForValueDeclaration(expression.symbol.owner))
+ val ref = JsNameRef(context.getNameForValueDeclaration(expression.target))
val value = expression.value.accept(this, context)
return JsBinaryOperation(JsBinaryOperator.ASG, ref, value)
}
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, context: JsGenerationContext): JsExpression {
- val classNameRef = context.getNameForConstructor(expression.symbol.owner).makeRef()
+ val classNameRef = context.getNameForConstructor(expression.target).makeRef()
val callFuncRef = JsNameRef(Namer.CALL_FUNCTION, classNameRef)
val fromPrimary = context.currentFunction is IrConstructor
val thisRef =
if (fromPrimary) JsThisRef() else context.getNameForValueDeclaration(context.currentFunction!!.valueParameters.last()).makeRef()
val arguments = translateCallArguments(expression, context, this)
- val constructor = expression.symbol.owner
+ val constructor = expression.target
if (constructor.parentAsClass.isInline) {
assert(constructor.isPrimary) {
"Delegation to secondary inline constructors must be lowered into simple function calls"
@@ -127,7 +123,7 @@
}
override fun visitConstructorCall(expression: IrConstructorCall, context: JsGenerationContext): JsExpression {
- val function = expression.symbol.owner
+ val function = expression.target
val arguments = translateCallArguments(expression, context, this)
val klass = function.parentAsClass
return if (klass.isInline) {
@@ -149,7 +145,7 @@
}
override fun visitCall(expression: IrCall, context: JsGenerationContext): JsExpression {
- if (context.checkIfJsCode(expression.symbol)) {
+ if (context.checkIfJsCode(expression.target)) {
val statements = translateJsCodeIntoStatementList(expression.getValueArgument(0) ?: error("JsCode is expected"))
if (statements.isEmpty()) return JsPrefixOperation(JsUnaryOperator.VOID, JsIntLiteral(3)) // TODO: report warning or even error
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsStatementTransformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsStatementTransformer.kt
index a12b55b..242f787 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsStatementTransformer.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/IrElementToJsStatementTransformer.kt
@@ -65,14 +65,14 @@
}
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, context: JsGenerationContext): JsStatement {
- if (expression.symbol.owner.constructedClassType.isAny()) {
+ if (expression.target.constructedClassType.isAny()) {
return JsEmpty
}
return expression.accept(IrElementToJsExpressionTransformer(), context).makeStmt()
}
override fun visitCall(expression: IrCall, data: JsGenerationContext): JsStatement {
- if (data.checkIfJsCode(expression.symbol)) {
+ if (data.checkIfJsCode(expression.target)) {
val statements = translateJsCodeIntoStatementList(expression.getValueArgument(0) ?: error("JsCode is expected"))
return when (statements.size) {
0 -> JsEmpty
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/JsIntrinsicTransformers.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/JsIntrinsicTransformers.kt
index 4377e4a9..fe853d7 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/JsIntrinsicTransformers.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/JsIntrinsicTransformers.kt
@@ -174,11 +174,11 @@
add(intrinsics.jsBind) { call, context: JsGenerationContext ->
val receiver = call.getValueArgument(0)!!
val reference = call.getValueArgument(1) as IrFunctionReference
- val superClass = call.superQualifierSymbol!!
+ val superClass = call.irSuperQualifier!!
val jsReceiver = receiver.accept(IrElementToJsExpressionTransformer(), context)
- val functionName = context.getNameForMemberFunction(reference.symbol.owner as IrSimpleFunction)
- val superName = context.getNameForClass(superClass.owner).makeRef()
+ val functionName = context.getNameForMemberFunction(reference.target as IrSimpleFunction)
+ val superName = context.getNameForClass(superClass).makeRef()
val qPrototype = JsNameRef(functionName, prototypeOf(superName))
val bindRef = JsNameRef(Namer.BIND_FUNCTION, qPrototype)
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt
index 9dcf225..b124a82 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/transformers/irToJs/jsAstUtils.kt
@@ -62,7 +62,7 @@
}
private fun isNativeInvoke(call: IrCall): Boolean {
- val simpleFunction = call.symbol.owner as? IrSimpleFunction ?: return false
+ val simpleFunction = call.target as? IrSimpleFunction ?: return false
val receiverType = simpleFunction.dispatchReceiverParameter?.type ?: return false
if (simpleFunction.isSuspend) return false
@@ -75,7 +75,7 @@
context: JsGenerationContext,
transformer: IrElementToJsExpressionTransformer
): JsExpression {
- val function = expression.symbol.owner.realOverrideTarget
+ val function = expression.target.realOverrideTarget
require(function is IrSimpleFunction) { "Only IrSimpleFunction could be called via IrCall" } // TODO: fix it in IrCall
val symbol = function.symbol
@@ -106,12 +106,12 @@
return JsInvocation(jsDispatchReceiver!!, arguments)
}
- expression.superQualifierSymbol?.let { superQualifier ->
- val (target, klass) = if (superQualifier.owner.isInterface) {
+ expression.irSuperQualifier?.let { superQualifier ->
+ val (target, klass) = if (superQualifier.isInterface) {
val impl = function.resolveFakeOverride()!!
Pair(impl, impl.parentAsClass)
} else {
- Pair(function, superQualifier.owner)
+ Pair(function, superQualifier)
}
val qualifierName = context.getNameForClass(klass).makeRef()
@@ -206,7 +206,7 @@
val argument = expression.getValueArgument(index)
val result = argument?.accept(transformer, context)
if (result == null) {
- assert(expression is IrFunctionAccessExpression && expression.symbol.owner.isExternalOrInheritedFromExternal())
+ assert(expression is IrFunctionAccessExpression && expression.target.isExternalOrInheritedFromExternal())
JsPrefixOperation(JsUnaryOperator.VOID, JsIntLiteral(1))
} else
result
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt
index 0ad389f..df355ab 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt
@@ -7,7 +7,6 @@
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.js.backend.ast.JsName
import org.jetbrains.kotlin.js.backend.ast.JsNameRef
import org.jetbrains.kotlin.js.backend.ast.JsScope
@@ -43,9 +42,9 @@
}
private fun isCoroutineDoResume(): Boolean {
- val overriddenSymbols = (currentFunction as? IrSimpleFunction)?.overriddenSymbols ?: return false
- return staticContext.doResumeFunctionSymbol in overriddenSymbols
+ val overriddenSymbols = (currentFunction as? IrSimpleFunction)?.overridden ?: return false
+ return staticContext.doResumeFunction in overriddenSymbols
}
- fun checkIfJsCode(symbol: IrFunctionSymbol): Boolean = symbol == staticContext.backendContext.intrinsics.jsCode
+ fun checkIfJsCode(target: IrFunction): Boolean = target == staticContext.backendContext.intrinsics.jsCode
}
\ No newline at end of file
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsStaticContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsStaticContext.kt
index cf4dd75..be2014b 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsStaticContext.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsStaticContext.kt
@@ -20,9 +20,9 @@
val intrinsics = JsIntrinsicTransformers(backendContext)
val classModels = mutableMapOf<IrClassSymbol, JsIrClassModel>()
- val coroutineImplDeclaration = backendContext.ir.symbols.coroutineImpl.owner
- val doResumeFunctionSymbol = coroutineImplDeclaration.declarations
- .filterIsInstance<IrSimpleFunction>().single { it.name.asString() == "doResume" }.symbol
+ val coroutineImplDeclaration = backendContext.ir.symbols.coroutineImpl
+ val doResumeFunction = coroutineImplDeclaration.declarations
+ .filterIsInstance<IrSimpleFunction>().single { it.name.asString() == "doResume" }
val initializerBlock = JsGlobalBlock()
}
\ No newline at end of file
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt
index 495076f..f41ead4 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt
@@ -26,10 +26,6 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.expressions.IrExpression
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
-import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable
import org.jetbrains.kotlin.ir.util.SymbolTable
@@ -70,11 +66,11 @@
localClassInfo[container.attributeOwnerId] = value
}
- internal val localDelegatedProperties = mutableMapOf<IrClass, List<IrLocalDelegatedPropertySymbol>>()
+ internal val localDelegatedProperties = mutableMapOf<IrClass, List<IrLocalDelegatedProperty>>()
internal val multifileFacadesToAdd = mutableMapOf<JvmClassName, MutableList<IrClass>>()
internal val multifileFacadeForPart = mutableMapOf<IrClass, JvmClassName>()
- internal val multifileFacadeMemberToPartMember = mutableMapOf<IrFunctionSymbol, IrFunctionSymbol>()
+ internal val multifileFacadeMemberToPartMember = mutableMapOf<IrFunction, IrFunction>()
override var inVerbosePhase: Boolean = false
@@ -88,26 +84,26 @@
val suspendFunctionViews = mutableMapOf<IrFunction, IrFunction>()
val fakeContinuation: IrExpression = createFakeContinuation(this)
- val staticDefaultStubs = mutableMapOf<IrFunctionSymbol, IrFunction>()
+ val staticDefaultStubs = mutableMapOf<IrFunction, IrFunction>()
- internal fun getTopLevelClass(fqName: FqName): IrClassSymbol {
+ internal fun getTopLevelClass(fqName: FqName): IrClass {
val descriptor = state.module.getPackage(fqName.parent()).memberScope.getContributedClassifier(
fqName.shortName(), NoLookupLocation.FROM_BACKEND
) as ClassDescriptor? ?: error("Class is not found: $fqName")
return referenceClass(descriptor)
}
- internal fun referenceClass(descriptor: ClassDescriptor): IrClassSymbol =
- symbolTable.referenceClass(descriptor)
+ internal fun referenceClass(descriptor: ClassDescriptor): IrClass =
+ symbolTable.referenceClass(descriptor).owner
- internal fun referenceTypeParameter(descriptor: TypeParameterDescriptor): IrTypeParameterSymbol =
- symbolTable.referenceTypeParameter(descriptor)
+ internal fun referenceTypeParameter(descriptor: TypeParameterDescriptor): IrTypeParameter =
+ symbolTable.referenceTypeParameter(descriptor).owner
- internal fun referenceFunction(descriptor: FunctionDescriptor): IrFunctionSymbol =
+ internal fun referenceFunction(descriptor: FunctionDescriptor): IrFunction =
if (descriptor is ClassConstructorDescriptor)
- symbolTable.referenceConstructor(descriptor)
+ symbolTable.referenceConstructor(descriptor).owner
else
- symbolTable.referenceSimpleFunction(descriptor)
+ symbolTable.referenceSimpleFunction(descriptor).owner
override fun log(message: () -> String) {
/*TODO*/
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendFacade.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendFacade.kt
index 0100f50..3fd2f3f 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendFacade.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendFacade.kt
@@ -67,10 +67,10 @@
state, sourceManager, irModuleFragment.irBuiltins, irModuleFragment, symbolTable, phaseConfig, firMode
)
state.irBasedMapAsmMethod = { descriptor ->
- context.methodSignatureMapper.mapAsmMethod(context.referenceFunction(descriptor).owner)
+ context.methodSignatureMapper.mapAsmMethod(context.referenceFunction(descriptor))
}
state.mapInlineClass = { descriptor ->
- context.typeMapper.mapType(context.referenceClass(descriptor).owner.defaultType)
+ context.typeMapper.mapType(context.referenceClass(descriptor).defaultType)
}
//TODO
ExternalDependenciesGenerator(
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt
index 75b24db..e36f8c0 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt
@@ -230,7 +230,8 @@
val jvmPhases = namedIrModulePhase(
name = "IrLowering",
description = "IR lowering",
- lower = expectDeclarationsRemovingPhase then
+ lower = desymbolizePhase then
+ expectDeclarationsRemovingPhase then
fileClassPhase then
performByIrFile(lower = jvmFilePhases) then
generateMultifileFacadesPhase
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt
index e419c0c..0811c3d 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt
@@ -14,11 +14,8 @@
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor
import org.jetbrains.kotlin.ir.builders.declarations.*
-import org.jetbrains.kotlin.ir.declarations.IrClass
-import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
-import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
+import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
-import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable
@@ -47,33 +44,33 @@
private val irBuiltIns = context.irBuiltIns
- private val nullPointerExceptionClass: IrClassSymbol =
+ private val nullPointerExceptionClass: IrClass =
createClass(FqName("java.lang.NullPointerException")) { klass ->
klass.addConstructor().apply {
addValueParameter("message", irBuiltIns.stringType)
}
}
- override val ThrowNullPointerException: IrFunctionSymbol =
+ override val ThrowNullPointerException: IrFunction =
nullPointerExceptionClass.constructors.single()
- override val ThrowNoWhenBranchMatchedException: IrSimpleFunctionSymbol
+ override val ThrowNoWhenBranchMatchedException: IrFunction
get() = error("Unused in JVM IR")
- private val typeCastExceptionClass: IrClassSymbol =
+ private val typeCastExceptionClass: IrClass =
createClass(FqName("kotlin.TypeCastException")) { klass ->
klass.addConstructor().apply {
addValueParameter("message", irBuiltIns.stringType)
}
}
- override val ThrowTypeCastException: IrFunctionSymbol =
+ override val ThrowTypeCastException: IrFunction =
typeCastExceptionClass.constructors.single()
private fun createPackage(fqName: FqName): IrPackageFragment =
IrExternalPackageFragmentImpl(IrExternalPackageFragmentSymbolImpl(EmptyPackageFragmentDescriptor(context.state.module, fqName)))
- private fun createClass(fqName: FqName, classKind: ClassKind = ClassKind.CLASS, block: (IrClass) -> Unit = {}): IrClassSymbol =
+ private fun createClass(fqName: FqName, classKind: ClassKind = ClassKind.CLASS, block: (IrClass) -> Unit = {}): IrClass =
buildClass {
name = fqName.shortName()
kind = classKind
@@ -88,9 +85,9 @@
}
createImplicitParameterDeclarationWithWrappedDescriptor()
block(this)
- }.symbol
+ }
- private val intrinsicsClass: IrClassSymbol = createClass(
+ private val intrinsicsClass: IrClass = createClass(
JvmClassName.byInternalName(IrIntrinsicMethods.INTRINSICS_CLASS_NAME).fqNameForTopLevelClassMaybeWithDollars
) { klass ->
klass.addFunction("throwUninitializedPropertyAccessException", irBuiltIns.unitType, isStatic = true).apply {
@@ -106,63 +103,63 @@
}
}
- val checkExpressionValueIsNotNull: IrSimpleFunctionSymbol =
- intrinsicsClass.functions.single { it.owner.name.asString() == "checkExpressionValueIsNotNull" }
+ val checkExpressionValueIsNotNull: IrSimpleFunction =
+ intrinsicsClass.functions.single { it.name.asString() == "checkExpressionValueIsNotNull" }
- val checkNotNullExpressionValue: IrSimpleFunctionSymbol =
- intrinsicsClass.functions.single { it.owner.name.asString() == "checkNotNullExpressionValue" }
+ val checkNotNullExpressionValue: IrSimpleFunction =
+ intrinsicsClass.functions.single { it.name.asString() == "checkNotNullExpressionValue" }
- override val ThrowUninitializedPropertyAccessException: IrSimpleFunctionSymbol =
- intrinsicsClass.functions.single { it.owner.name.asString() == "throwUninitializedPropertyAccessException" }
+ override val ThrowUninitializedPropertyAccessException: IrSimpleFunction =
+ intrinsicsClass.functions.single { it.name.asString() == "throwUninitializedPropertyAccessException" }
- override val stringBuilder: IrClassSymbol
+ override val stringBuilder: IrClass
get() = context.getTopLevelClass(FqName("java.lang.StringBuilder"))
- override val defaultConstructorMarker: IrClassSymbol =
+ override val defaultConstructorMarker: IrClass =
createClass(FqName("kotlin.jvm.internal.DefaultConstructorMarker"))
- override val copyRangeTo: Map<ClassDescriptor, IrSimpleFunctionSymbol>
+ override val copyRangeTo: Map<ClassDescriptor, IrSimpleFunction>
get() = error("Unused in JVM IR")
- override val coroutineImpl: IrClassSymbol
+ override val coroutineImpl: IrClass
get() = TODO("not implemented")
- override val coroutineSuspendedGetter: IrSimpleFunctionSymbol
+ override val coroutineSuspendedGetter: IrSimpleFunction
get() = TODO("not implemented")
- override val getContinuation: IrSimpleFunctionSymbol
+ override val getContinuation: IrSimpleFunction
get() = TODO("not implemented")
- override val coroutineContextGetter: IrSimpleFunctionSymbol
+ override val coroutineContextGetter: IrSimpleFunction
get() = TODO("not implemented")
- override val suspendCoroutineUninterceptedOrReturn: IrSimpleFunctionSymbol
+ override val suspendCoroutineUninterceptedOrReturn: IrSimpleFunction
get() = TODO("not implemented")
- override val coroutineGetContext: IrSimpleFunctionSymbol
+ override val coroutineGetContext: IrSimpleFunction
get() = TODO("not implemented")
- override val returnIfSuspended: IrSimpleFunctionSymbol
+ override val returnIfSuspended: IrSimpleFunction
get() = TODO("not implemented")
- val javaLangClass: IrClassSymbol =
+ val javaLangClass: IrClass =
if (firMode) createClass(FqName("java.lang.Class")) else context.getTopLevelClass(FqName("java.lang.Class"))
- private val javaLangAssertionError: IrClassSymbol =
+ private val javaLangAssertionError: IrClass =
if (firMode) createClass(FqName("java.lang.AssertionError")) else context.getTopLevelClass(FqName("java.lang.AssertionError"))
- val assertionErrorConstructor by lazy<IrConstructorSymbol> {
+ val assertionErrorConstructor by lazy<IrConstructor> {
javaLangAssertionError.constructors.single {
- it.owner.valueParameters.size == 1 && it.owner.valueParameters[0].type.isNullableAny()
+ it.valueParameters.size == 1 && it.valueParameters[0].type.isNullableAny()
}
}
- val continuationClass: IrClassSymbol =
+ val continuationClass: IrClass =
createClass(DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE, ClassKind.INTERFACE) { klass ->
klass.addTypeParameter("T", irBuiltIns.anyNType, Variance.IN_VARIANCE)
}
- val lambdaClass: IrClassSymbol = createClass(FqName("kotlin.jvm.internal.Lambda")) { klass ->
+ val lambdaClass: IrClass = createClass(FqName("kotlin.jvm.internal.Lambda")) { klass ->
klass.addConstructor().apply {
addValueParameter("arity", irBuiltIns.intType)
}
@@ -174,7 +171,7 @@
klass.addFunction("getOwner", irBuiltIns.kDeclarationContainerClass.typeWith(), Modality.OPEN)
}
- val functionReference: IrClassSymbol = createClass(FqName("kotlin.jvm.internal.FunctionReference")) { klass ->
+ val functionReference: IrClass = createClass(FqName("kotlin.jvm.internal.FunctionReference")) { klass ->
klass.addConstructor().apply {
addValueParameter("arity", irBuiltIns.intType)
}
@@ -189,12 +186,12 @@
generateCallableReferenceMethods(klass)
}
- val functionReferenceReceiverField: IrFieldSymbol = functionReference.fieldByName("receiver")
- val functionReferenceGetSignature: IrSimpleFunctionSymbol = functionReference.functionByName("getSignature")
- val functionReferenceGetName: IrSimpleFunctionSymbol = functionReference.functionByName("getName")
- val functionReferenceGetOwner: IrSimpleFunctionSymbol = functionReference.functionByName("getOwner")
+ val functionReferenceReceiverField: IrField = functionReference.fieldByName("receiver")
+ val functionReferenceGetSignature: IrSimpleFunction = functionReference.functionByName("getSignature")
+ val functionReferenceGetName: IrSimpleFunction = functionReference.functionByName("getName")
+ val functionReferenceGetOwner: IrSimpleFunction = functionReference.functionByName("getOwner")
- fun getFunction(parameterCount: Int): IrClassSymbol =
+ fun getFunction(parameterCount: Int): IrClass =
symbolTable.referenceClass(builtIns.getFunction(parameterCount))
private val jvmFunctionClasses = storageManager.createMemoizedFunction { n: Int ->
@@ -212,10 +209,10 @@
}
}
- fun getJvmFunctionClass(parameterCount: Int): IrClassSymbol =
+ fun getJvmFunctionClass(parameterCount: Int): IrClass =
jvmFunctionClasses(parameterCount)
- val functionN: IrClassSymbol = createClass(FqName("kotlin.jvm.functions.FunctionN"), ClassKind.INTERFACE) { klass ->
+ val functionN: IrClass = createClass(FqName("kotlin.jvm.functions.FunctionN"), ClassKind.INTERFACE) { klass ->
val returnType = klass.addTypeParameter("R", irBuiltIns.anyNType, Variance.OUT_VARIANCE)
klass.addFunction("invoke", returnType.defaultType, Modality.ABSTRACT).apply {
@@ -291,10 +288,10 @@
}
}
- fun getPropertyReferenceClass(mutable: Boolean, parameterCount: Int, impl: Boolean): IrClassSymbol =
+ fun getPropertyReferenceClass(mutable: Boolean, parameterCount: Int, impl: Boolean): IrClass =
propertyReferenceClasses(PropertyReferenceKey(mutable, parameterCount, impl))
- val reflection: IrClassSymbol = createClass(FqName("kotlin.jvm.internal.Reflection")) { klass ->
+ val reflection: IrClass = createClass(FqName("kotlin.jvm.internal.Reflection")) { klass ->
// We use raw types for java.lang.Class and kotlin.reflect.KClass here for simplicity and because this is what's used
// at declaration site at kotlin.jvm.internal.Reflection.
val rawJavaLangClass = javaLangClass.typeWith()
@@ -323,14 +320,14 @@
}
}
- val getOrCreateKotlinPackage: IrSimpleFunctionSymbol =
+ val getOrCreateKotlinPackage: IrSimpleFunction =
reflection.functionByName("getOrCreateKotlinPackage")
- val desiredAssertionStatus: IrSimpleFunctionSymbol by lazy {
+ val desiredAssertionStatus: IrSimpleFunction by lazy {
javaLangClass.functionByName("desiredAssertionStatus")
}
- val unsafeCoerceIntrinsic: IrSimpleFunctionSymbol =
+ val unsafeCoerceIntrinsic: IrSimpleFunction =
buildFun {
name = Name.special("<unsafe-coerce>")
origin = IrDeclarationOrigin.IR_BUILTINS_STUB
@@ -340,9 +337,9 @@
val dst = addTypeParameter("R", irBuiltIns.anyNType)
addValueParameter("v", src.defaultType)
returnType = dst.defaultType
- }.symbol
+ }
- private val collectionToArrayClass: IrClassSymbol = createClass(FqName("kotlin.jvm.internal.CollectionToArray")) { klass ->
+ private val collectionToArrayClass: IrClass = createClass(FqName("kotlin.jvm.internal.CollectionToArray")) { klass ->
klass.origin = JvmLoweredDeclarationOrigin.TO_ARRAY
val arrayType = irBuiltIns.arrayClass.typeWith(irBuiltIns.anyNType)
@@ -357,13 +354,13 @@
}
}
- val nonGenericToArray: IrSimpleFunctionSymbol =
- collectionToArrayClass.functions.single { it.owner.name.asString() == "toArray" && it.owner.valueParameters.size == 1 }
+ val nonGenericToArray: IrSimpleFunction =
+ collectionToArrayClass.functions.single { it.name.asString() == "toArray" && it.valueParameters.size == 1 }
- val genericToArray: IrSimpleFunctionSymbol =
- collectionToArrayClass.functions.single { it.owner.name.asString() == "toArray" && it.owner.valueParameters.size == 2 }
+ val genericToArray: IrSimpleFunction =
+ collectionToArrayClass.functions.single { it.name.asString() == "toArray" && it.valueParameters.size == 2 }
- val kClassJava: IrPropertySymbol =
+ val kClassJava: IrProperty =
buildProperty {
name = Name.identifier("java")
}.apply {
@@ -372,9 +369,9 @@
addExtensionReceiver(irBuiltIns.kClassClass.typeWith())
returnType = javaLangClass.typeWith()
}
- }.symbol
+ }
- val spreadBuilder: IrClassSymbol = createClass(FqName("kotlin.jvm.internal.SpreadBuilder")) { klass ->
+ val spreadBuilder: IrClass = createClass(FqName("kotlin.jvm.internal.SpreadBuilder")) { klass ->
klass.addConstructor().apply {
addValueParameter("size", irBuiltIns.intType)
}
@@ -394,7 +391,7 @@
}
}
- val primitiveSpreadBuilders: Map<IrType, IrClassSymbol> = irBuiltIns.primitiveIrTypes.associateWith { irType ->
+ val primitiveSpreadBuilders: Map<IrType, IrClass> = irBuiltIns.primitiveIrTypes.associateWith { irType ->
val name = irType.classOrNull!!.owner.name
createClass(FqName("kotlin.jvm.internal.${name}SpreadBuilder")) { klass ->
klass.addConstructor().apply {
@@ -416,7 +413,7 @@
}
}
- private val systemClass: IrClassSymbol = createClass(FqName("java.lang.System")) { klass ->
+ private val systemClass: IrClass = createClass(FqName("java.lang.System")) { klass ->
klass.addFunction("arraycopy", irBuiltIns.unitType, isStatic = true).apply {
addValueParameter("src", irBuiltIns.anyNType)
addValueParameter("srcPos", irBuiltIns.intType)
@@ -426,10 +423,10 @@
}
}
- val systemArraycopy: IrSimpleFunctionSymbol = systemClass.functionByName("arraycopy")
+ val systemArraycopy: IrSimpleFunction = systemClass.functionByName("arraycopy")
}
-private fun IrClassSymbol.functionByName(name: String): IrSimpleFunctionSymbol =
- functions.single { it.owner.name.asString() == name }
-private fun IrClassSymbol.fieldByName(name: String): IrFieldSymbol =
- fields.single { it.owner.name.asString() == name }
+private fun IrClass.functionByName(name: String): IrSimpleFunction =
+ functions.single { it.name.asString() == name }
+private fun IrClass.fieldByName(name: String): IrField =
+ fields.single { it.name.asString() == name }
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt
index ad21874..4d5f6ec 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt
@@ -172,7 +172,7 @@
private fun genAnnotationArguments(annotation: IrConstructorCall, annotationVisitor: AnnotationVisitor) {
val annotationClass = annotation.annotationClass
- for (param in annotation.symbol.owner.valueParameters) {
+ for (param in annotation.target.valueParameters) {
val value = annotation.getValueArgument(param.index)
if (value == null) {
if (param.defaultValue != null) continue // Default value will be supplied by JVM at runtime.
@@ -200,7 +200,7 @@
when (value) {
is IrConst<*> -> annotationVisitor.visit(name, value.value)
is IrConstructorCall -> {
- val callee = value.symbol.owner
+ val callee = value.target
when {
callee.parentAsClass.isAnnotationClass -> {
val internalAnnName = typeMapper.mapType(callee.returnType).descriptor
@@ -212,8 +212,8 @@
}
}
is IrGetEnumValue -> {
- val enumClassInternalName = typeMapper.mapClass(value.symbol.owner.parentAsClass).descriptor
- val enumEntryName = value.symbol.owner.name
+ val enumClassInternalName = typeMapper.mapClass(value.target.parentAsClass).descriptor
+ val enumEntryName = value.target.name
annotationVisitor.visitEnum(name, enumClassInternalName, enumEntryName.asString())
}
is IrVararg -> { // array constructor
@@ -270,7 +270,7 @@
fun IrConstructorCall.applicableTargetSet() =
annotationClass.applicableTargetSet() ?: KotlinTarget.DEFAULT_TARGET_SET
- val IrConstructorCall.annotationClass get() = symbol.owner.parentAsClass
+ val IrConstructorCall.annotationClass get() = target.parentAsClass
}
}
@@ -288,13 +288,13 @@
val retentionArgument =
getAnnotation(KotlinBuiltIns.FQ_NAMES.retention)?.getValueArgument(RETENTION_PARAMETER_NAME)
as? IrGetEnumValue?: return null
- val retentionArgumentValue = retentionArgument.symbol.owner
+ val retentionArgumentValue = retentionArgument.target
return KotlinRetention.valueOf(retentionArgumentValue.name.asString())
}
// To be generalized to IrMemberAccessExpression as soon as properties get symbols.
private fun IrConstructorCall.getValueArgument(name: Name): IrExpression? {
- val index = symbol.owner.valueParameters.find { it.name == name }?.index ?: return null
+ val index = target.valueParameters.find { it.name == name }?.index ?: return null
return getValueArgument(index)
}
@@ -311,6 +311,6 @@
val valueArgument = targetEntry.getValueArgument(TARGET_ALLOWED_TARGETS)
as? IrVararg ?: return null
return valueArgument.elements.filterIsInstance<IrGetEnumValue>().mapNotNull {
- KotlinTarget.valueOrNull(it.symbol.owner.name.asString())
+ KotlinTarget.valueOrNull(it.target.name.asString())
}.toSet()
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt
index 6f4895b..9468663 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt
@@ -338,7 +338,7 @@
// TODO: Since the class could have been reparented in lowerings, this could
// be a class instead of the actual function that the class is nested inside
// in the source.
- val containingDeclaration = irClass.symbol.owner.parent
+ val containingDeclaration = irClass.parent
if (containingDeclaration is IrFunction) {
val method = methodSignatureMapper.mapAsmMethod(containingDeclaration)
visitor.visitOuterClass(outerClassName, method.name, method.descriptor)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt
index 39a94bd..33e1eb6 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt
@@ -146,8 +146,8 @@
it.body = body?.deepCopyWithSymbols(this)
it.body?.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetValue(expression: IrGetValue): IrGetValue =
- valueParametersMapping[expression.symbol.owner]?.let { newParam ->
- expression.run { IrGetValueImpl(startOffset, endOffset, type, newParam.symbol, origin) }
+ valueParametersMapping[expression.target]?.let { newParam ->
+ expression.run { IrGetValueImpl(startOffset, endOffset, type, newParam, origin) }
} ?: expression
override fun visitCall(expression: IrCall): IrExpression {
@@ -164,9 +164,9 @@
callerIsInlineLambda: Boolean
): IrCall {
if (!isSuspend) return this
- val view = (symbol.owner as IrSimpleFunction).getOrCreateSuspendFunctionViewIfNeeded(context)
- if (view == symbol.owner) return this
- return IrCallImpl(startOffset, endOffset, view.returnType, view.symbol).also {
+ val view = (target as IrSimpleFunction).getOrCreateSuspendFunctionViewIfNeeded(context)
+ if (view == target) return this
+ return IrCallImpl(startOffset, endOffset, view.returnType, view).also {
it.copyTypeArgumentsFrom(this)
it.dispatchReceiver = dispatchReceiver
it.extensionReceiver = extensionReceiver
@@ -176,9 +176,9 @@
val continuationParameter =
when {
caller.isInvokeSuspendOfLambda(context) || caller.isInvokeSuspendOfContinuation(context) ->
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, caller.dispatchReceiverParameter!!.symbol)
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, caller.dispatchReceiverParameter!!)
callerIsInlineLambda -> context.fakeContinuation
- else -> IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, caller.valueParameters.last().symbol)
+ else -> IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, caller.valueParameters.last())
}
it.putValueArgument(valueArgumentsCount, continuationParameter)
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt
index acddc15..0484052 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt
@@ -34,7 +34,6 @@
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
@@ -213,7 +212,7 @@
private fun generateNonNullAssertion(param: IrValueParameter) {
val asmType = param.type.asmType
if (!param.type.unboxInlineClass().isNullable() && !isPrimitive(asmType)) {
- mv.load(findLocalIndex(param.symbol), asmType)
+ mv.load(findLocalIndex(param), asmType)
mv.aconst(param.name.asString())
val methodName =
if (state.languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4) "checkNotNullParameter"
@@ -255,7 +254,7 @@
val type = typeMapper.mapType(param)
// NOTE: we expect all value parameters to be present in the frame.
mv.visitLocalVariable(
- name, type.descriptor, null, startLabel, endLabel, findLocalIndex(param.symbol)
+ name, type.descriptor, null, startLabel, endLabel, findLocalIndex(param)
)
}
@@ -286,7 +285,7 @@
}
info.variables.reversed().forEach {
- frameMap.leave(it.declaration.symbol)
+ frameMap.leave(it.declaration)
}
}
@@ -307,17 +306,17 @@
}
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: BlockInfo): PromisedValue {
- classCodegen.context.irIntrinsics.getIntrinsic(expression.symbol)
+ classCodegen.context.irIntrinsics.getIntrinsic(expression.target)
?.invoke(expression, this, data)?.let { return it.coerce(expression.type) }
val callable = methodSignatureMapper.mapToCallableMethod(expression)
- val callee = expression.symbol.owner
+ val callee = expression.target
val callGenerator = getOrCreateCallGenerator(expression, data, callable.signature)
val asmType = if (expression is IrConstructorCall) typeMapper.mapTypeAsDeclaration(expression.type) else expression.asmType
when {
expression is IrConstructorCall -> {
- closureReifiedMarkers[expression.symbol.owner.parentAsClass]?.let {
+ closureReifiedMarkers[expression.target.parentAsClass]?.let {
if (it.wereUsedReifiedParameters()) {
putNeedClassReificationMarker(v)
propagateChildReifiedTypeParametersUsages(it)
@@ -335,7 +334,7 @@
for (argumentIndex in 0 until expression.typeArgumentsCount) {
val classifier = expression.getTypeArgument(argumentIndex)?.classifierOrNull
- if (classifier is IrTypeParameterSymbol && classifier.owner.isReified) {
+ if (classifier is IrTypeParameter && classifier.isReified) {
consumeReifiedOperationMarker(classifier)
}
}
@@ -358,7 +357,7 @@
}
callGenerator.beforeValueParametersStart()
- expression.symbol.owner.valueParameters.forEachIndexed { i, irParameter ->
+ expression.target.valueParameters.forEachIndexed { i, irParameter ->
val arg = expression.getValueArgument(i)
val parameterType = callable.valueParameterTypes[i]
require(arg != null) { "Null argument in ExpressionCodegen for parameter ${irParameter.render()}" }
@@ -400,7 +399,7 @@
override fun visitVariable(declaration: IrVariable, data: BlockInfo): PromisedValue {
val varType = typeMapper.mapType(declaration)
- val index = frameMap.enter(declaration.symbol, varType)
+ val index = frameMap.enter(declaration, varType)
declaration.markLineNumber(startOffset = true)
@@ -417,15 +416,15 @@
override fun visitGetValue(expression: IrGetValue, data: BlockInfo): PromisedValue {
// Do not generate line number information for loads from compiler-generated
// temporary variables. They do not correspond to variable loads in user code.
- if (expression.symbol.owner.origin != IrDeclarationOrigin.IR_TEMPORARY_VARIABLE)
+ if (expression.target.origin != IrDeclarationOrigin.IR_TEMPORARY_VARIABLE)
expression.markLineNumber(startOffset = true)
- val type = frameMap.typeOf(expression.symbol)
- mv.load(findLocalIndex(expression.symbol), type)
+ val type = frameMap.typeOf(expression.target)
+ mv.load(findLocalIndex(expression.target), type)
return MaterialValue(this, type, expression.type)
}
override fun visitFieldAccess(expression: IrFieldAccessExpression, data: BlockInfo): PromisedValue {
- val callee = expression.symbol.owner
+ val callee = expression.target
callee.constantValue()?.let {
// Handling const reads before codegen is important for constant folding.
assert(expression is IrSetField) { "read of const val ${callee.name} not inlined by ConstLowering" }
@@ -466,7 +465,7 @@
// i.e., not in an initializer block or constructor body.
val isFieldInitializer = expression.origin == null
val skip = (inPrimaryConstructor || inClassInit) && isFieldInitializer && expressionValue is IrConst<*> &&
- isDefaultValueForType(expression.symbol.owner.type.asmType, expressionValue.value)
+ isDefaultValueForType(expression.target.type.asmType, expressionValue.value)
return if (skip) defaultValue(expression.type) else super.visitSetField(expression, data)
}
@@ -485,19 +484,19 @@
else -> !isPrimitive(type) && value == null
}
- private fun findLocalIndex(irSymbol: IrSymbol): Int {
- val index = frameMap.getIndex(irSymbol)
+ private fun findLocalIndex(declaration: IrSymbolOwner): Int {
+ val index = frameMap.getIndex(declaration)
if (index >= 0)
return index
- val dump = if (irSymbol.isBound) irSymbol.owner.dump() else irSymbol.descriptor.toString()
+ val dump = if (declaration.symbol.isBound) declaration.dump() else declaration.symbol.descriptor.toString()
throw AssertionError("Non-mapped local declaration: $dump\n in ${irFunction.dump()}")
}
override fun visitSetVariable(expression: IrSetVariable, data: BlockInfo): PromisedValue {
expression.markLineNumber(startOffset = true)
expression.value.markLineNumber(startOffset = true)
- expression.value.accept(this, data).coerce(expression.symbol.owner.type).materialize()
- mv.store(findLocalIndex(expression.symbol), expression.symbol.owner.asmType)
+ expression.value.accept(this, data).coerce(expression.target.type).materialize()
+ mv.store(findLocalIndex(expression.target), expression.target.asmType)
return defaultValue(expression.type)
}
@@ -536,10 +535,10 @@
}
override fun visitReturn(expression: IrReturn, data: BlockInfo): PromisedValue {
- val returnTarget = expression.returnTargetSymbol.owner
+ val returnTarget = expression.irReturnTarget
val owner =
(returnTarget as? IrFunction
- ?: (returnTarget as? IrReturnableBlock)?.inlineFunctionSymbol?.owner
+ ?: (returnTarget as? IrReturnableBlock)?.inlineFunction
?: error("Unsupported IrReturnTarget: $returnTarget")).getOrCreateSuspendFunctionViewIfNeeded(context)
//TODO: should be owner != irFunction
val isNonLocalReturn =
@@ -946,13 +945,13 @@
private fun getOrCreateCallGenerator(
element: IrFunctionAccessExpression, data: BlockInfo, signature: JvmMethodSignature
): IrCallGenerator {
- if (!element.symbol.owner.isInlineFunctionCall(context) ||
+ if (!element.target.isInlineFunctionCall(context) ||
classCodegen.irClass.fileParent.fileEntry is MultifileFacadeFileEntry
) {
return IrCallGenerator.DefaultCallGenerator
}
- val callee = element.symbol.owner
+ val callee = element.target
val typeArgumentContainer = if (callee is IrConstructor) callee.parentAsClass else callee
val typeArguments =
if (element.typeArgumentsCount == 0) {
@@ -998,9 +997,9 @@
}
override fun consumeReifiedOperationMarker(typeParameter: TypeParameterMarker) {
- require(typeParameter is IrTypeParameterSymbol)
- if (typeParameter.owner.parent != irFunction) {
- classCodegen.reifiedTypeParametersUsages.addUsedReifiedParameter(typeParameter.owner.name.asString())
+ require(typeParameter is IrTypeParameter)
+ if (typeParameter.parent != irFunction) {
+ classCodegen.reifiedTypeParametersUsages.addUsedReifiedParameter(typeParameter.name.asString())
}
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt
index d3a47c5..122db46 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt
@@ -78,8 +78,8 @@
} else {
val frameMap = createFrameMapWithReceivers(signature)
val irClass = context.suspendFunctionContinuations[irFunction]
- val element = (irFunction.symbol.descriptor.psiElement
- ?: context.suspendLambdaToOriginalFunctionMap[irFunction.parent]?.symbol?.descriptor?.psiElement) as? KtElement
+ val element = (irFunction.descriptor.psiElement
+ ?: context.suspendLambdaToOriginalFunctionMap[irFunction.parent]?.descriptor?.psiElement) as? KtElement
val continuationClassBuilder = context.continuationClassBuilders[irClass]
methodVisitor = when {
irFunction.isSuspend &&
@@ -179,7 +179,7 @@
?.backingField
?.initializer.safeAs<IrExpressionBody>()
?.expression?.safeAs<IrGetValue>()
- ?.symbol?.owner?.safeAs<IrValueParameter>()
+ ?.target?.safeAs<IrValueParameter>()
?.defaultValue?.safeAs<IrExpressionBody>()
?.expression
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt
index e07aa6e..5d3e9bf3 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt
@@ -112,7 +112,7 @@
// TODO port inlining cycle detection to IrFunctionAccessExpression & pass it
state.globalInlineContext.enterIntoInlining(null)
try {
- performInline(expression.symbol.owner.typeParameters.map { it.symbol }, false, codegen.typeMapper.typeSystem, codegen)
+ performInline(expression.target.typeParameters, false, codegen.typeMapper.typeSystem, codegen)
} finally {
state.globalInlineContext.exitFromInliningOf(null)
}
@@ -124,7 +124,7 @@
parameter: IrValueParameter,
boundReceiver: IrVariable?
): LambdaInfo {
- val referencedFunction = irReference.symbol.owner
+ val referencedFunction = irReference.target
return IrExpressionLambdaImpl(
irReference, referencedFunction, codegen.typeMapper, codegen.methodSignatureMapper, codegen.context, parameter.isCrossinline,
boundReceiver != null, parameter.type.isExtensionFunctionType
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt
index 0312b3c..ddd85f2 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt
@@ -102,7 +102,7 @@
}
private fun getFunctionToInline(call: IrCall, jvmSignature: JvmMethodSignature, callDefault: Boolean): IrFunction {
- val callee = call.symbol.owner
+ val callee = call.target
val parent = callee.parentAsClass
if (callDefault) {
/*TODO: get rid of hack*/
@@ -115,8 +115,8 @@
}
if (parent.fileParent.fileEntry is MultifileFacadeFileEntry) {
- return (codegen.context.multifileFacadeMemberToPartMember[callee.symbol]
- ?: error("Function from a multi-file facade without the link to the function in the part: ${callee.render()}")).owner
+ return (codegen.context.multifileFacadeMemberToPartMember[callee]
+ ?: error("Function from a multi-file facade without the link to the function in the part: ${callee.render()}"))
}
return callee
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt
index bdc69c3..666bbf5 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt
@@ -19,7 +19,6 @@
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
-import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.originalKotlinType
import org.jetbrains.kotlin.ir.util.defaultType
@@ -39,9 +38,9 @@
override fun mapClass(classifier: ClassifierDescriptor): Type =
when (classifier) {
is ClassDescriptor ->
- mapClass(context.referenceClass(classifier).owner)
+ mapClass(context.referenceClass(classifier))
is TypeParameterDescriptor ->
- mapType(context.referenceTypeParameter(classifier).owner.defaultType)
+ mapType(context.referenceTypeParameter(classifier).defaultType)
else ->
error("Unknown descriptor: $classifier")
}
@@ -54,7 +53,7 @@
if (sw.skipGenericSignature()) return
with(KotlinTypeMapper) {
for (typeParameter in irParameters) {
- typeSystem.writeFormalTypeParameter(typeParameter.symbol, sw) { type, mode ->
+ typeSystem.writeFormalTypeParameter(typeParameter, sw) { type, mode ->
mapType(type as IrType, mode, sw)
}
}
@@ -243,7 +242,7 @@
private fun writeGenericArguments(
sw: JvmSignatureWriter,
arguments: List<IrTypeArgument>,
- parameters: List<IrTypeParameterSymbol>,
+ parameters: List<IrTypeParameter>,
mode: TypeMappingMode
) = with(KotlinTypeMapper) {
typeSystem.writeGenericArguments(sw, arguments, parameters, mode) { type, sw, mode ->
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt
index 6dcb259..39d38d5 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt
@@ -292,7 +292,7 @@
}
fun mapToCallableMethod(expression: IrFunctionAccessExpression): IrCallableMethod {
- val callee = expression.symbol.owner.getOrCreateSuspendFunctionViewIfNeeded(context)
+ val callee = expression.target.getOrCreateSuspendFunctionViewIfNeeded(context)
val calleeParent = callee.parent
if (calleeParent !is IrClass) {
// Non-class parent is only possible for intrinsics created in IrBuiltIns, such as dataClassArrayMemberHashCode. In that case,
@@ -331,7 +331,7 @@
private fun mapOverriddenSpecialBuiltinIfNeeded(callee: IrFunction, superCall: Boolean): JvmMethodSignature? {
val overriddenSpecialBuiltinFunction = callee.descriptor.original.getOverriddenBuiltinReflectingJvmDescriptor()
if (overriddenSpecialBuiltinFunction != null && !superCall) {
- return mapSignatureSkipGeneric(context.referenceFunction(overriddenSpecialBuiltinFunction.original).owner)
+ return mapSignatureSkipGeneric(context.referenceFunction(overriddenSpecialBuiltinFunction.original))
}
return null
@@ -342,7 +342,7 @@
var current = function
while (current.isFakeOverride) {
// TODO: probably isJvmInterface instead of isInterface, here and in KotlinTypeMapper
- val classCallable = current.overriddenSymbols.firstOrNull { !it.owner.parentAsClass.isInterface }?.owner
+ val classCallable = current.overridden.firstOrNull { !it.parentAsClass.isInterface }
if (classCallable != null) {
current = classCallable
continue
@@ -351,7 +351,7 @@
return current
}
- current = current.overriddenSymbols.firstOrNull()?.owner
+ current = current.overridden.firstOrNull()
?: error("Fake override should have at least one overridden descriptor: ${current.render()}")
}
return current
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt
index 849c529..10e6321 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt
@@ -80,12 +80,12 @@
private fun areConstComparisons(conditions: List<IrCall>): Boolean {
// All branches must be CALL 'EQEQ(Any?, Any?)': Boolean
- if (conditions.any { it.symbol != codegen.classCodegen.context.irBuiltIns.eqeqSymbol })
+ if (conditions.any { it.target != codegen.classCodegen.context.irBuiltIns.eqeqSymbol.owner })
return false
// All LHS refer to the same tmp variable.
val lhs = conditions.map { it.getValueArgument(0) as? IrGetValue }
- if (lhs.any { it == null || it.symbol != lhs[0]!!.symbol })
+ if (lhs.any { it == null || it.target != lhs[0]!!.target })
return false
// All RHS are constants
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt
index 9c72f2e..92d8a4d 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt
@@ -26,8 +26,6 @@
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.*
@@ -48,31 +46,31 @@
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
-class IrFrameMap : FrameMapBase<IrSymbol>() {
- private val typeMap = mutableMapOf<IrSymbol, Type>()
+class IrFrameMap : FrameMapBase<IrSymbolOwner>() {
+ private val typeMap = mutableMapOf<IrSymbolOwner, Type>()
- override fun enter(descriptor: IrSymbol, type: Type): Int {
+ override fun enter(descriptor: IrSymbolOwner, type: Type): Int {
typeMap[descriptor] = type
return super.enter(descriptor, type)
}
- override fun leave(descriptor: IrSymbol): Int {
+ override fun leave(descriptor: IrSymbolOwner): Int {
typeMap.remove(descriptor)
return super.leave(descriptor)
}
- fun typeOf(descriptor: IrSymbol): Type = typeMap.getValue(descriptor)
+ fun typeOf(descriptor: IrSymbolOwner): Type = typeMap.getValue(descriptor)
}
internal val IrFunction.isStatic
get() = (this.dispatchReceiverParameter == null && this !is IrConstructor)
fun IrFrameMap.enter(irDeclaration: IrSymbolOwner, type: Type): Int {
- return enter(irDeclaration.symbol, type)
+ return enter(irDeclaration, type)
}
fun IrFrameMap.leave(irDeclaration: IrSymbolOwner): Int {
- return leave(irDeclaration.symbol)
+ return leave(irDeclaration)
}
val IrClass.isJvmInterface get() = isAnnotationClass || isInterface
@@ -375,7 +373,7 @@
val kotlinMarkerInterfaces = LinkedHashSet<String>()
for (superType in irClass.superTypes) {
- val superClass = superType.safeAs<IrSimpleType>()?.classifier?.safeAs<IrClassSymbol>()?.owner ?: continue
+ val superClass = superType.safeAs<IrSimpleType>()?.classifier?.safeAs<IrClass>() ?: continue
if (superClass.isJvmInterface) {
val kotlinInterfaceName = superClass.fqNameWhenAvailable!!
@@ -548,7 +546,7 @@
val IrAnnotationContainer.deprecationFlags: Int
get() {
val annotation = annotations.findAnnotation(FQ_NAMES.deprecated) ?: return 0
- val isHidden = (annotation.getValueArgument(2) as? IrGetEnumValue)?.symbol?.owner
+ val isHidden = (annotation.getValueArgument(2) as? IrGetEnumValue)?.target
?.name?.asString() == DeprecationLevel.HIDDEN.name
return Opcodes.ACC_DEPRECATED or if (isHidden) Opcodes.ACC_SYNTHETIC else 0
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt
index 3f499ea..5f81b0e 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt
@@ -25,8 +25,6 @@
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrExternalPackageFragmentSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
@@ -162,8 +160,8 @@
else
objectRefProvider
- private fun getElementFieldSymbol(valueType: IrType): IrFieldSymbol {
- return getProvider(valueType).elementField.symbol
+ private fun getElementField(valueType: IrType): IrField {
+ return getProvider(valueType).elementField
}
override fun declareSharedVariable(originalDeclaration: IrVariable): IrVariable {
@@ -174,7 +172,7 @@
val refConstructorCall = IrConstructorCallImpl.fromSymbolOwner(
refType,
- refConstructor.symbol,
+ refConstructor,
SHARED_VARIABLE_CONSTRUCTOR_CALL_ORIGIN
).apply {
List(refConstructor.parentAsClass.typeParameters.size) { i ->
@@ -207,8 +205,8 @@
val sharedVariableInitialization = IrSetFieldImpl(
initializer.startOffset, initializer.endOffset,
- getElementFieldSymbol(valueType),
- IrGetValueImpl(initializer.startOffset, initializer.endOffset, sharedVariableDeclaration.symbol),
+ getElementField(valueType),
+ IrGetValueImpl(initializer.startOffset, initializer.endOffset, sharedVariableDeclaration),
initializer,
valueType
)
@@ -219,7 +217,7 @@
)
}
- override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue): IrExpression =
+ override fun getSharedValue(sharedVariable: IrVariable, originalGet: IrGetValue): IrExpression =
IrTypeOperatorCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
originalGet.type,
@@ -227,18 +225,18 @@
originalGet.type,
IrGetFieldImpl(
originalGet.startOffset, originalGet.endOffset,
- getElementFieldSymbol(originalGet.symbol.owner.type),
+ getElementField(originalGet.target.type),
originalGet.type,
- IrGetValueImpl(originalGet.startOffset, originalGet.endOffset, sharedVariableSymbol),
+ IrGetValueImpl(originalGet.startOffset, originalGet.endOffset, sharedVariable),
originalGet.origin
)
)
- override fun setSharedValue(sharedVariableSymbol: IrVariableSymbol, originalSet: IrSetVariable): IrExpression =
+ override fun setSharedValue(sharedVariable: IrVariable, originalSet: IrSetVariable): IrExpression =
IrSetFieldImpl(
originalSet.startOffset, originalSet.endOffset,
- getElementFieldSymbol(originalSet.symbol.owner.type),
- IrGetValueImpl(originalSet.startOffset, originalSet.endOffset, sharedVariableSymbol),
+ getElementField(originalSet.target.type),
+ IrGetValueImpl(originalSet.startOffset, originalSet.endOffset, sharedVariable),
originalSet.value,
originalSet.type,
originalSet.origin
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayIterator.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayIterator.kt
index 3ea8e81..f070705 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayIterator.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayIterator.kt
@@ -29,7 +29,7 @@
signature: JvmMethodSignature,
context: JvmBackendContext
): IrIntrinsicFunction {
- val owner = context.typeMapper.mapClass(expression.symbol.owner.parentAsClass)
+ val owner = context.typeMapper.mapClass(expression.target.parentAsClass)
return IrIntrinsicFunction.create(expression, signature, context, owner) {
val methodSignature = "(${owner.descriptor})${signature.returnType.descriptor}"
val intrinsicOwner =
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/BinaryOp.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/BinaryOp.kt
index f3a7cb0..168abb3 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/BinaryOp.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/BinaryOp.kt
@@ -38,7 +38,7 @@
): IrIntrinsicFunction {
val returnType = signature.returnType
val intermediateResultType = numberFunctionOperandType(returnType)
- val argTypes = if (!expression.symbol.owner.parentAsClass.defaultType.isChar()) {
+ val argTypes = if (!expression.target.parentAsClass.defaultType.isChar()) {
listOf(intermediateResultType, if (shift()) Type.INT_TYPE else intermediateResultType)
} else {
listOf(Type.CHAR_TYPE, signature.valueParameters[0].asmType)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IntrinsicMethod.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IntrinsicMethod.kt
index 6321074..a3dea80 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IntrinsicMethod.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IntrinsicMethod.kt
@@ -25,7 +25,7 @@
open fun invoke(expression: IrFunctionAccessExpression, codegen: ExpressionCodegen, data: BlockInfo): PromisedValue? =
with(codegen) {
- val descriptor = methodSignatureMapper.mapSignatureSkipGeneric(expression.symbol.owner)
+ val descriptor = methodSignatureMapper.mapSignatureSkipGeneric(expression.target)
val stackValue = toCallable(expression, descriptor, context).invoke(mv, codegen, data)
return object : PromisedValue(this, stackValue.type, expression.type) {
override fun materialize() = stackValue.put(mv)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicFunction.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicFunction.kt
index 6648cad..2f5c86d 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicFunction.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicFunction.kt
@@ -74,7 +74,7 @@
var offset = 0
expression.dispatchReceiver?.let { genArg(it, codegen, offset++, data) }
expression.extensionReceiver?.let { genArg(it, codegen, offset++, data) }
- for ((i, valueParameter) in expression.symbol.owner.valueParameters.withIndex()) {
+ for ((i, valueParameter) in expression.target.valueParameters.withIndex()) {
val argument = expression.getValueArgument(i)
when {
argument != null ->
@@ -82,7 +82,7 @@
valueParameter.isVararg -> {
// TODO: is there an easier way to get the substituted type of an empty vararg argument?
val arrayType = codegen.typeMapper.mapType(
- valueParameter.type.substitute(expression.symbol.owner.typeParameters, expression.typeArguments)
+ valueParameter.type.substitute(expression.target.typeParameters, expression.typeArguments)
)
StackValue.operation(arrayType) {
it.aconst(0)
@@ -140,11 +140,10 @@
}
fun IrFunctionAccessExpression.argTypes(context: JvmBackendContext): ArrayList<Type> {
- val callee = symbol.owner
- val signature = context.methodSignatureMapper.mapSignatureSkipGeneric(callee)
+ val signature = context.methodSignatureMapper.mapSignatureSkipGeneric(target)
return arrayListOf<Type>().apply {
if (dispatchReceiver != null) {
- add(context.typeMapper.mapClass(callee.parentAsClass))
+ add(context.typeMapper.mapClass(target.parentAsClass))
}
addAll(signature.asmMethod.argumentTypes)
}
@@ -152,5 +151,5 @@
fun IrFunctionAccessExpression.receiverAndArgs(): List<IrExpression> {
return (arrayListOf(this.dispatchReceiver, this.extensionReceiver) +
- symbol.owner.valueParameters.mapIndexed { i, _ -> getValueArgument(i) }).filterNotNull()
+ target.valueParameters.mapIndexed { i, _ -> getValueArgument(i) }).filterNotNull()
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicMethods.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicMethods.kt
index 52df309..f2debf1 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicMethods.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/IrIntrinsicMethods.kt
@@ -21,10 +21,6 @@
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.types.classifierOrNull
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
@@ -138,7 +134,7 @@
private val PrimitiveType.symbol
get() = irBuiltIns.primitiveTypeToIrType[this]!!.classOrNull!!
- fun getIntrinsic(symbol: IrFunctionSymbol): IntrinsicMethod? = intrinsicsMap[symbol.toKey()]
+ fun getIntrinsic(target: IrFunction): IntrinsicMethod? = intrinsicsMap[target.toKey()]
private fun unaryFunForPrimitives(name: String, intrinsic: IntrinsicMethod): List<Pair<Key, IntrinsicMethod>> =
PrimitiveType.values().map { type ->
@@ -154,12 +150,12 @@
private fun binaryFunForPrimitives(
name: String,
intrinsic: IntrinsicMethod,
- parameter: IrClassifierSymbol
+ parameter: IrClassifier
): List<Pair<Key, IntrinsicMethod>> =
PrimitiveType.values().map { type ->
createKeyMapping(
intrinsic,
- type.symbol,
+ type.symbol.owner,
name,
parameter
)
@@ -175,12 +171,12 @@
private fun arrayMethods(): List<Pair<Key, IntrinsicMethod>> =
symbols.primitiveArrays.flatMap { (key, value) ->
arrayMethods(
- key.symbol,
+ key.symbol.owner,
value
)
} + arrayMethods(symbols.array.owner.typeParameters.single().symbol, symbols.array)
- private fun arrayMethods(elementClass: IrClassifierSymbol, arrayClass: IrClassSymbol) =
+ private fun arrayMethods(elementClass: IrClassifier, arrayClass: IrClass) =
listOf(
createKeyMapping(ArraySize, arrayClass, "<get-size>"),
createKeyMapping(NewArray, arrayClass, "<init>", irBuiltIns.intClass),
@@ -200,8 +196,8 @@
private val DEC = Increment(-1)
private val EQUALS = Equals(KtTokens.EQEQ)
- private fun IrFunctionSymbol.toKey(): Key? {
- val parent = owner.parent
+ private fun IrFunction.toKey(): Key? {
+ val parent = this.parent
val ownerFqName = when {
parent is IrClass && parent.origin == IrDeclarationOrigin.FILE_CLASS ->
(parent.parent as IrPackageFragment).fqName
@@ -211,17 +207,17 @@
}
return Key(
ownerFqName,
- getParameterFqName(owner.extensionReceiverParameter),
- owner.name.asString(),
- owner.valueParameters.map(::getParameterFqName)
+ getParameterFqName(extensionReceiverParameter),
+ name.asString(),
+ valueParameters.map(::getParameterFqName)
)
}
private fun getParameterFqName(parameter: IrValueParameter?): FqName? =
getParameterFqName(parameter?.type?.classifierOrNull)
- private fun getParameterFqName(parameter: IrClassifierSymbol?): FqName? =
- parameter?.owner?.let {
+ private fun getParameterFqName(parameter: IrClassifier?): FqName? =
+ parameter?.let {
when (it) {
is IrClass -> it.fqNameWhenAvailable
is IrTypeParameter -> FqName(it.name.asString())
@@ -231,26 +227,26 @@
private fun createKeyMapping(
intrinsic: IntrinsicMethod,
- klass: IrClassSymbol,
+ klass: IrClass,
name: String,
- vararg args: IrClassifierSymbol
+ vararg args: IrClassifier
): Pair<Key, IntrinsicMethod> =
- Key(klass.owner.fqNameWhenAvailable!!, null, name, args.map {
+ Key(klass.fqNameWhenAvailable!!, null, name, args.map {
getParameterFqName(it)
}) to intrinsic
- private fun numberConversionMethods(numberClass: IrClassSymbol) =
+ private fun numberConversionMethods(numberClass: IrClass) =
OperatorConventions.NUMBER_CONVERSIONS.map { method ->
createKeyMapping(NumberCast, numberClass, method.asString())
}
private fun primitiveComparisonIntrinsics(
- typeToIrFun: Map<SimpleType, IrSimpleFunctionSymbol>,
+ typeToIrFun: Map<SimpleType, IrSimpleFunction>,
operator: KtSingleValueToken
): List<Pair<Key, PrimitiveComparison>> =
- typeToIrFun.map { (type, irFunSymbol) ->
- irFunSymbol.toKey()!! to PrimitiveComparison(type, operator)
+ typeToIrFun.map { (type, irFun) ->
+ irFun.toKey()!! to PrimitiveComparison(type, operator)
}
}
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrArrayBuilder.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrArrayBuilder.kt
index 9d46bae..c82d777 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrArrayBuilder.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrArrayBuilder.kt
@@ -65,7 +65,7 @@
val arrayConstructor = if (unwrappedArrayType.isBoxedArray)
builder.irSymbols.arrayOfNulls
else
- unwrappedArrayType.classOrNull!!.constructors.single { it.owner.valueParameters.size == 1 }
+ unwrappedArrayType.classOrNull!!.constructors.single { it.valueParameters.size == 1 }
return builder.irCall(arrayConstructor, unwrappedArrayType).apply {
if (typeArgumentsCount != 0)
@@ -80,7 +80,7 @@
val result = irTemporary(newArray(elements.size))
val set = unwrappedArrayType.classOrNull!!.functions.single {
- it.owner.name.asString() == "set"
+ it.name.asString() == "set"
}
for ((index, element) in elements.withIndex()) {
@@ -97,11 +97,11 @@
// Copy a single spread expression, unless it refers to a newly constructed array.
private fun copyArray(spread: IrExpression): IrExpression {
if (spread is IrConstructorCall ||
- (spread is IrFunctionAccessExpression && spread.symbol == builder.irSymbols.arrayOfNulls))
+ (spread is IrFunctionAccessExpression && spread.target == builder.irSymbols.arrayOfNulls))
return spread
return builder.irBlock {
- val spreadVar = if (spread is IrGetValue) spread.symbol.owner else irTemporary(spread)
+ val spreadVar = if (spread is IrGetValue) spread.target else irTemporary(spread)
val size = unwrappedArrayType.classOrNull!!.getPropertyGetter("size")!!
fun getSize() = irCall(size).apply { dispatchReceiver = irGet(spreadVar) }
val result = irTemporary(newArray(getSize()))
@@ -123,9 +123,9 @@
else
builder.irSymbols.primitiveSpreadBuilders.getValue(elementType)
- val addElement = spreadBuilder.functions.single { it.owner.name.asString() == "add" }
- val addSpread = spreadBuilder.functions.single { it.owner.name.asString() == "addSpread" }
- val toArray = spreadBuilder.functions.single { it.owner.name.asString() == "toArray" }
+ val addElement = spreadBuilder.functions.single { it.name.asString() == "add" }
+ val addSpread = spreadBuilder.functions.single { it.name.asString() == "addSpread" }
+ val toArray = spreadBuilder.functions.single { it.name.asString() == "toArray" }
return builder.irBlock {
val spreadBuilderVar = irTemporary(irCallConstructor(spreadBuilder.constructors.single(), listOf()).apply {
@@ -142,7 +142,7 @@
val toArrayCall = irCall(toArray).apply {
dispatchReceiver = irGet(spreadBuilderVar)
if (unwrappedArrayType.isBoxedArray) {
- val size = spreadBuilder.functions.single { it.owner.name.asString() == "size" }
+ val size = spreadBuilder.functions.single { it.name.asString() == "size" }
putValueArgument(0, irCall(builder.irSymbols.arrayOfNulls, arrayType).apply {
putTypeArgument(0, elementType)
putValueArgument(0, irCall(size).apply {
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt
index c60a9c8b..35a5eb9 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt
@@ -16,7 +16,6 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
@@ -102,12 +101,12 @@
// An IR builder with a reference to the JvmBackendContext
class JvmIrBuilder(
val backendContext: JvmBackendContext,
- val symbol: IrSymbol,
+ val owner: IrSymbolOwner,
startOffset: Int = UNDEFINED_OFFSET,
endOffset: Int = UNDEFINED_OFFSET
) : IrBuilderWithScope(
IrLoweringContext(backendContext),
- Scope(symbol),
+ Scope(owner),
startOffset,
endOffset
) {
@@ -116,7 +115,7 @@
}
fun JvmBackendContext.createJvmIrBuilder(
- symbol: IrSymbol,
+ owner: IrSymbolOwner,
startOffset: Int = UNDEFINED_OFFSET,
endOffset: Int = UNDEFINED_OFFSET
-) = JvmIrBuilder(this, symbol, startOffset, endOffset)
+) = JvmIrBuilder(this, owner, startOffset, endOffset)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt
index f2fb98d..740d728 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt
@@ -31,7 +31,6 @@
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
@@ -85,15 +84,15 @@
if (!expression.isSuspend)
return expression
- val constructor = suspendLambdas.singleOrNull { it.function == expression.symbol.owner }?.constructor
+ val constructor = suspendLambdas.singleOrNull { it.function == expression.target }?.constructor
?: return expression
val expressionArguments = expression.getArguments().map { it.second }
assert(constructor.valueParameters.size == expressionArguments.size) {
"Inconsistency between callable reference to suspend lambda and the corresponding continuation"
}
- val irBuilder = context.createIrBuilder(expression.symbol, expression.startOffset, expression.endOffset)
+ val irBuilder = context.createIrBuilder(expression.target, expression.startOffset, expression.endOffset)
irBuilder.run {
- return irCall(constructor.symbol).apply {
+ return irCall(constructor).apply {
expressionArguments.forEachIndexed { index, argument ->
putValueArgument(index, argument)
}
@@ -104,13 +103,12 @@
}
private fun generateContinuationClassForLambda(info: SuspendLambdaInfo) {
- val suspendLambda = suspendLambda.owner
suspendLambda.createContinuationClassFor(info.function).apply {
copyAttributes(info.reference)
val functionNClass = context.ir.symbols.getJvmFunctionClass(info.arity + 1)
superTypes.add(
IrSimpleTypeImpl(
- functionNClass,
+ functionNClass.symbol,
hasQuestionMark = false,
arguments = (info.function.explicitParameters.subList(0, info.arity).map { it.type }
+ info.function.continuationType() + info.function.returnType)
@@ -130,7 +128,7 @@
val constructor = addPrimaryConstructorForLambda(info.arity, info.function, parametersFields)
val secondaryConstructor = addSecondaryConstructorForLambda(constructor)
val invokeToOverride = functionNClass.functions.single {
- it.owner.valueParameters.size == info.arity + 1 && it.owner.name.asString() == "invoke"
+ it.valueParameters.size == info.arity + 1 && it.name.asString() == "invoke"
}
val invokeSuspend = addInvokeSuspendForLambda(info.function, parametersFields, receiverField)
if (info.arity <= 1) {
@@ -152,38 +150,38 @@
receiverField: IrField?
): IrFunction {
val superMethod = suspendLambda.functions.single {
- it.owner.name.asString() == INVOKE_SUSPEND_METHOD_NAME && it.owner.valueParameters.size == 1 &&
- it.owner.valueParameters[0].type.isKotlinResult()
- }.owner
+ it.name.asString() == INVOKE_SUSPEND_METHOD_NAME && it.valueParameters.size == 1 &&
+ it.valueParameters[0].type.isKotlinResult()
+ }
return addFunctionOverride(superMethod)
.also { function ->
function.copyTypeParametersFrom(irFunction)
function.body = irFunction.body?.deepCopyWithSymbols(function)
function.body?.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitGetValue(expression: IrGetValue): IrExpression {
- if (expression.symbol.owner == irFunction.extensionReceiverParameter) {
+ if (expression.target == irFunction.extensionReceiverParameter) {
assert(receiverField != null)
return IrGetFieldImpl(
expression.startOffset,
expression.endOffset,
- receiverField!!.symbol,
+ receiverField!!,
receiverField.type
).also {
it.receiver =
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, function.dispatchReceiverParameter!!.symbol)
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, function.dispatchReceiverParameter!!)
}
- } else if (expression.symbol.owner == irFunction.dispatchReceiverParameter) {
- return IrGetValueImpl(expression.startOffset, expression.endOffset, function.dispatchReceiverParameter!!.symbol)
+ } else if (expression.target == irFunction.dispatchReceiverParameter) {
+ return IrGetValueImpl(expression.startOffset, expression.endOffset, function.dispatchReceiverParameter!!)
}
- val field = fields.find { it.name == expression.symbol.owner.name } ?: return expression
- return IrGetFieldImpl(expression.startOffset, expression.endOffset, field.symbol, field.type).also {
- it.receiver = IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, function.dispatchReceiverParameter!!.symbol)
+ val field = fields.find { it.name == expression.target.name } ?: return expression
+ return IrGetFieldImpl(expression.startOffset, expression.endOffset, field, field.type).also {
+ it.receiver = IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, function.dispatchReceiverParameter!!)
}
}
override fun visitReturn(expression: IrReturn): IrExpression {
val ret = super.visitReturn(expression) as IrReturn
- return IrReturnImpl(ret.startOffset, ret.endOffset, context.irBuiltIns.anyType, function.symbol, ret.value)
+ return IrReturnImpl(ret.startOffset, ret.endOffset, context.irBuiltIns.anyType, function, ret.value)
}
})
(irFunction.parent as IrDeclarationContainer).declarations.remove(irFunction)
@@ -195,19 +193,19 @@
modality: Modality = Modality.FINAL
): IrSimpleFunction =
addFunction(function.name.asString(), function.returnType, modality).apply {
- overriddenSymbols.add(function.symbol)
+ overridden.add(function)
function.valueParameters.mapTo(valueParameters) { it.copyTo(this) }
}
private fun IrClass.addInvoke(
create: IrFunction,
invokeSuspend: IrFunction,
- invokeToOverride: IrSimpleFunctionSymbol
+ invokeToOverride: IrSimpleFunction
) {
val unitClass = context.irBuiltIns.unitClass
val unitField = context.declarationFactory.getFieldForObjectInstance(unitClass.owner)
- addFunctionOverride(invokeToOverride.owner).also { function ->
- function.body = context.createIrBuilder(function.symbol).irBlockBody {
+ addFunctionOverride(invokeToOverride).also { function ->
+ function.body = context.createIrBuilder(function).irBlockBody {
+irReturn(irCall(invokeSuspend).also { invokeSuspendCall ->
invokeSuspendCall.dispatchReceiver = irCall(create).also {
it.dispatchReceiver = irGet(function.dispatchReceiverParameter!!)
@@ -234,7 +232,7 @@
if (arity == 1) it.valueParameters.first().type.isNullableAny() else true
}
return addFunctionOverride(create).also { function ->
- function.body = context.createIrBuilder(function.symbol).irBlockBody {
+ function.body = context.createIrBuilder(function).irBlockBody {
val constructorCall = irCall(constructor).also {
for ((i, field) in parametersFields.withIndex()) {
it.putValueArgument(i, irGetField(irGet(function.dispatchReceiverParameter!!), field))
@@ -277,15 +275,15 @@
returnType = defaultType
}.also { constructor ->
irFunction.valueParameters.mapTo(constructor.valueParameters) { it.copyTo(constructor) }
- val completionParameterSymbol = constructor.addCompletionValueParameter()
+ val completionParameter = constructor.addCompletionValueParameter()
- val superClassConstructor = suspendLambda.owner.constructors.single {
+ val superClassConstructor = suspendLambda.constructors.single {
it.valueParameters.size == 2 && it.valueParameters[0].type.isInt() && it.valueParameters[1].type.isNullableContinuation()
}
- constructor.body = context.createIrBuilder(constructor.symbol).irBlockBody {
+ constructor.body = context.createIrBuilder(constructor).irBlockBody {
+irDelegatingConstructorCall(superClassConstructor).also {
it.putValueArgument(0, irInt(arity + 1))
- it.putValueArgument(1, irGet(completionParameterSymbol))
+ it.putValueArgument(1, irGet(completionParameter))
}
for ((index, param) in constructor.valueParameters.dropLast(1).withIndex()) {
@@ -301,7 +299,7 @@
}.also { constructor ->
constructor.valueParameters.addAll(primary.valueParameters.dropLast(1).map { it.copyTo(constructor) })
- constructor.body = context.createIrBuilder(constructor.symbol).irBlockBody {
+ constructor.body = context.createIrBuilder(constructor).irBlockBody {
+irDelegatingConstructorCall(primary).also {
for ((index, param) in constructor.valueParameters.withIndex()) {
it.putValueArgument(index, irGet(param))
@@ -318,7 +316,7 @@
continuation.createType(true, listOf(makeTypeProjection(returnType, Variance.INVARIANT)))
private fun generateContinuationClassForNamedFunction(irFunction: IrFunction) {
- continuationImpl.owner.createContinuationClassFor(irFunction).apply {
+ continuationImpl.createContinuationClassFor(irFunction).apply {
val resultField = addField(
context.state.languageVersionSettings.dataFieldName(),
context.irBuiltIns.anyType,
@@ -338,15 +336,15 @@
returnType = defaultType
}.also { constructor ->
val capturedThisParameter = capturedThisField?.let { constructor.addValueParameter(it.name.asString(), it.type) }
- val completionParameterSymbol = constructor.addCompletionValueParameter()
+ val completionParameter = constructor.addCompletionValueParameter()
- val superClassConstructor = continuationImpl.owner.constructors.single { it.valueParameters.size == 1 }
- constructor.body = context.createIrBuilder(constructor.symbol).irBlockBody {
+ val superClassConstructor = continuationImpl.constructors.single { it.valueParameters.size == 1 }
+ constructor.body = context.createIrBuilder(constructor).irBlockBody {
if (capturedThisField != null) {
+irSetField(irGet(thisReceiver!!), capturedThisField, irGet(capturedThisParameter!!))
}
+irDelegatingConstructorCall(superClassConstructor).also {
- it.putValueArgument(0, irGet(completionParameterSymbol))
+ it.putValueArgument(0, irGet(completionParameter))
}
}
}
@@ -357,9 +355,9 @@
labelField: IrField,
capturedThisField: IrField?
) {
- val invokeSuspend = continuationImpl.owner.functions.single { it.name == Name.identifier(INVOKE_SUSPEND_METHOD_NAME) }
+ val invokeSuspend = continuationImpl.functions.single { it.name == Name.identifier(INVOKE_SUSPEND_METHOD_NAME) }
addFunctionOverride(invokeSuspend).also { function ->
- function.body = context.createIrBuilder(function.symbol).irBlockBody {
+ function.body = context.createIrBuilder(function).irBlockBody {
+irSetField(irGet(function.dispatchReceiverParameter!!), resultField, irGet(function.valueParameters[0]))
// There can be three kinds of suspend function call:
// 1) direct call from another suspend function/lambda
@@ -373,7 +371,7 @@
+irSetField(
irGet(function.dispatchReceiverParameter!!), labelField,
irCallOp(
- context.irBuiltIns.intClass.functions.single { it.owner.name == OperatorNameConventions.OR },
+ context.irBuiltIns.intClass.functions.single { it.name == OperatorNameConventions.OR },
context.irBuiltIns.intType,
irGetField(irGet(function.dispatchReceiverParameter!!), labelField),
irInt(signBit)
@@ -427,7 +425,7 @@
}
override fun visitCall(expression: IrCall) {
- val owner = expression.symbol.owner
+ val owner = expression.target
if (owner.isInline) {
for (i in 0 until expression.valueArgumentsCount) {
if (owner.valueParameters[i].isNoinline) continue
@@ -449,7 +447,7 @@
if (expression.isSuspend && expression !in inlineLambdas) {
suspendLambdas += SuspendLambdaInfo(
- expression.symbol.owner,
+ expression.target,
(expression.type as IrSimpleType).arguments.size - 1,
expression
)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt
index 88ceff8..ab0805e 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt
@@ -141,7 +141,7 @@
irClass.annotations.add(
IrConstructorCallImpl.fromSymbolOwner(
- UNDEFINED_OFFSET, UNDEFINED_OFFSET, documentedConstructor.returnType, documentedConstructor.symbol
+ UNDEFINED_OFFSET, UNDEFINED_OFFSET, documentedConstructor.returnType, documentedConstructor
)
)
}
@@ -156,18 +156,18 @@
if (irClass.hasAnnotation(FqName("java.lang.annotation.Retention"))) return
val kotlinRetentionPolicyCall = irClass.getAnnotation(FqName("kotlin.annotation.Retention"))
val kotlinRetentionPolicyName =
- kotlinRetentionPolicyCall?.getValueArgument(0)?.safeAs<IrGetEnumValue>()?.symbol?.owner?.name?.asString()
+ kotlinRetentionPolicyCall?.getValueArgument(0)?.safeAs<IrGetEnumValue>()?.target?.name?.asString()
val kotlinRetentionPolicy = kotlinRetentionPolicyName?.let { KotlinRetention.valueOf(it) }
val javaRetentionPolicy = kotlinRetentionPolicy?.let { annotationRetentionMap[it] } ?: rpRuntime
irClass.annotations.add(
IrConstructorCallImpl.fromSymbolOwner(
- UNDEFINED_OFFSET, UNDEFINED_OFFSET, retentionConstructor.returnType, retentionConstructor.symbol
+ UNDEFINED_OFFSET, UNDEFINED_OFFSET, retentionConstructor.returnType, retentionConstructor
).apply {
putValueArgument(
0,
IrGetEnumValueImpl(
- UNDEFINED_OFFSET, UNDEFINED_OFFSET, retentionPolicyEnum.defaultType, javaRetentionPolicy.symbol
+ UNDEFINED_OFFSET, UNDEFINED_OFFSET, retentionPolicyEnum.defaultType, javaRetentionPolicy
)
)
}
@@ -223,14 +223,14 @@
for (target in javaTargets) {
vararg.elements.add(
IrGetEnumValueImpl(
- UNDEFINED_OFFSET, UNDEFINED_OFFSET, elementTypeEnum.defaultType, target.symbol
+ UNDEFINED_OFFSET, UNDEFINED_OFFSET, elementTypeEnum.defaultType, target
)
)
}
irClass.annotations.add(
IrConstructorCallImpl.fromSymbolOwner(
- UNDEFINED_OFFSET, UNDEFINED_OFFSET, targetConstructor.returnType, targetConstructor.symbol
+ UNDEFINED_OFFSET, UNDEFINED_OFFSET, targetConstructor.returnType, targetConstructor
).apply {
putValueArgument(0, vararg)
}
@@ -241,7 +241,7 @@
// To be generalized to IrMemberAccessExpression as soon as properties get symbols.
private fun IrConstructorCall.getValueArgument(name: Name): IrExpression? {
- val index = symbol.owner.valueParameters.find { it.name == name }?.index ?: return null
+ val index = target.valueParameters.find { it.name == name }?.index ?: return null
return getValueArgument(index)
}
@@ -258,6 +258,6 @@
val valueArgument = targetEntry.getValueArgument(TARGET_ALLOWED_TARGETS)
as? IrVararg ?: return null
return valueArgument.elements.filterIsInstance<IrGetEnumValue>().mapNotNull {
- KotlinTarget.valueOrNull(it.symbol.owner.name.asString())
+ KotlinTarget.valueOrNull(it.target.name.asString())
}.toSet()
}
\ No newline at end of file
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AssertionLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AssertionLowering.kt
index f609cea..fc3a0e3 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AssertionLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AssertionLowering.kt
@@ -77,7 +77,7 @@
}
override fun visitCall(expression: IrCall, data: ClassInfo?): IrElement {
- val function = expression.symbol.owner
+ val function = expression.target
if (!function.isAssert)
return super.visitCall(expression, data)
@@ -85,7 +85,7 @@
if (mode == JVMAssertionsMode.ALWAYS_DISABLE)
return IrCompositeImpl(expression.startOffset, expression.endOffset, context.irBuiltIns.unitType)
- context.createIrBuilder(expression.symbol).run {
+ context.createIrBuilder(expression.target).run {
at(expression)
val assertCondition = expression.getValueArgument(0)!!
val lambdaArgument = if (function.valueParameters.size == 2) expression.getValueArgument(1) else null
@@ -116,7 +116,7 @@
lambdaArgument != null -> {
val invoke =
lambdaArgument.type.getClass()!!.functions.single { it.name == OperatorNameConventions.INVOKE }
- irCallOp(invoke.symbol, invoke.returnType, irGet(invokeVar!!))
+ irCallOp(invoke, invoke.returnType, irGet(invokeVar!!))
}
else -> irString("Assertion failed")
}
@@ -140,7 +140,7 @@
isStatic = true
}.apply {
parent = irClass
- initializer = context.createIrBuilder(irClass.symbol).run {
+ initializer = context.createIrBuilder(irClass).run {
at(this@apply)
irExprBody(irNot(irCall(this@AssertionLowering.context.ir.symbols.desiredAssertionStatus).apply {
dispatchReceiver = getJavaClass(topLevelClass)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt
index 12d35af..523d128 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt
@@ -73,12 +73,12 @@
if (irFunction.isMethodOfAny()) return
if (irFunction.origin === IrDeclarationOrigin.FAKE_OVERRIDE &&
- irFunction.overriddenSymbols.all {
- !it.owner.comesFromJava() &&
- if ((it.owner.parent as? IrClass)?.isInterface == true)
- it.owner.hasJvmDefault() // TODO: Remove this after modality is corrected in InterfaceLowering.
+ irFunction.overridden.all {
+ !it.comesFromJava() &&
+ if ((it.parent as? IrClass)?.isInterface == true)
+ it.hasJvmDefault() // TODO: Remove this after modality is corrected in InterfaceLowering.
else
- it.owner.modality !== Modality.ABSTRACT
+ it.modality !== Modality.ABSTRACT
}
) {
// All needed bridges will be generated where functions are implemented.
@@ -118,7 +118,7 @@
}
} else if (irFunction.origin == IrDeclarationOrigin.FAKE_OVERRIDE &&
irFunction.modality == Modality.ABSTRACT &&
- irFunction.overriddenSymbols.all { it.owner.getJvmName() != ourMethodName }
+ irFunction.overridden.all { it.getJvmName() != ourMethodName }
) {
// Bridges for abstract fake overrides whose JVM names differ from overridden functions.
val bridge = irFunction.orphanedCopy()
@@ -191,8 +191,8 @@
// For lambda classes, we move override from the `invoke` function to its bridge. This will allow us to avoid boxing
// the return type of `invoke` in codegen, in case lambda's return type is primitive.
if (method.name == OperatorNameConventions.INVOKE && irClass.origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL) {
- target.overriddenSymbols.remove(method.symbol)
- bridge.overriddenSymbols.add(method.symbol)
+ target.overridden.remove(method)
+ bridge.overridden.add(method)
}
signaturesToSkip.add(signature)
@@ -281,9 +281,9 @@
IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
maybeOrphanedTarget.returnType,
- maybeOrphanedTarget.symbol, maybeOrphanedTarget.descriptor,
+ maybeOrphanedTarget, maybeOrphanedTarget.descriptor,
origin = IrStatementOrigin.BRIDGE_DELEGATION,
- superQualifierSymbol = if (invokeStatically) maybeOrphanedTarget.parentAsClass.symbol else null
+ irSuperQualifier = if (invokeStatically) maybeOrphanedTarget.parentAsClass else null
).apply {
passTypeArgumentsFrom(this@createBridgeBody)
dispatchReceiver = irGet(dispatchReceiverParameter!!)
@@ -303,7 +303,7 @@
/* A hacky way to make sure the code generator calls the right function, and not some standard interface it implements. */
private fun IrSimpleFunction.orphanedCopy() =
- if (overriddenSymbols.size == 0)
+ if (overridden.size == 0)
this
else
WrappedSimpleFunctionDescriptor(descriptor.annotations).let { wrappedDescriptor ->
@@ -373,7 +373,7 @@
override val isAbstract get() = irFunction.modality == Modality.ABSTRACT
override val mayBeUsedAsSuperImplementation get() = !irFunction.parentAsClass.isInterface || irFunction.hasJvmDefault()
- override fun getOverridden() = irFunction.overriddenSymbols.map { FunctionHandleForIrFunction(it.owner) }
+ override fun getOverridden() = irFunction.overridden.map { FunctionHandleForIrFunction(it) }
override fun hashCode(): Int =
irFunction.parent.safeAs<IrClass>()?.fqNameWhenAvailable.hashCode() + 31 * irFunction.getJvmSignature().hashCode()
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt
index 93528b0..2daecd8 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt
@@ -56,7 +56,7 @@
// Mark function references appearing as inlined arguments to inline functions.
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
- val function = expression.symbol.owner
+ val function = expression.target
if (function.isInlineFunctionCall(context)) {
for (parameter in function.valueParameters) {
if (!parameter.isInlineParameter())
@@ -120,7 +120,7 @@
private inner class FunctionReferenceBuilder(val irFunctionReference: IrFunctionReference, val samSuperType: IrType? = null) {
private val isLambda = irFunctionReference.origin.isLambda
- private val callee = irFunctionReference.symbol.owner
+ private val callee = irFunctionReference.target
// Only function references can bind a receiver and even then we can only bind either an extension or a dispatch receiver.
// However, when we bind a value of an inline class type as a receiver, the receiver will turn into an argument of
@@ -137,9 +137,9 @@
private val functionSuperClass =
samSuperType?.classOrNull ?: context.ir.symbols.getJvmFunctionClass(argumentTypes.size)
private val superMethod =
- functionSuperClass.functions.single { it.owner.modality == Modality.ABSTRACT }
+ functionSuperClass.functions.single { it.modality == Modality.ABSTRACT }
private val superType =
- samSuperType ?: (if (isLambda) context.ir.symbols.lambdaClass else context.ir.symbols.functionReference).owner.typeWith()
+ samSuperType ?: (if (isLambda) context.ir.symbols.lambdaClass else context.ir.symbols.functionReference).typeWith()
private val functionReferenceClass = buildClass {
setSourceRange(irFunctionReference)
@@ -157,7 +157,7 @@
copyAttributes(irFunctionReference)
}
- fun build(): IrExpression = context.createJvmIrBuilder(currentScope!!.scope.scopeOwnerSymbol).run {
+ fun build(): IrExpression = context.createJvmIrBuilder(currentScope!!.scope.irScopeOwner).run {
irBlock {
val constructor = createConstructor()
createInvokeMethod(
@@ -167,13 +167,13 @@
)
if (!isLambda && samSuperType == null) {
- createGetSignatureMethod(this@run.irSymbols.functionReferenceGetSignature.owner)
- createGetNameMethod(this@run.irSymbols.functionReferenceGetName.owner)
- createGetOwnerMethod(this@run.irSymbols.functionReferenceGetOwner.owner)
+ createGetSignatureMethod(this@run.irSymbols.functionReferenceGetSignature)
+ createGetNameMethod(this@run.irSymbols.functionReferenceGetName)
+ createGetOwnerMethod(this@run.irSymbols.functionReferenceGetOwner)
}
+functionReferenceClass
- +irCall(constructor.symbol).apply {
+ +irCall(constructor).apply {
if (valueArgumentsCount > 0) putValueArgument(0, boundReceiver!!.second)
}
}
@@ -217,17 +217,17 @@
putValueArgument(1, irGet(valueParameters.first()))
}
}
- +IrInstanceInitializerCallImpl(startOffset, endOffset, functionReferenceClass.symbol, context.irBuiltIns.unitType)
+ +IrInstanceInitializerCallImpl(startOffset, endOffset, functionReferenceClass, context.irBuiltIns.unitType)
}
}
private fun createInvokeMethod(receiverVar: IrValueDeclaration?): IrSimpleFunction =
functionReferenceClass.addFunction {
- name = superMethod.owner.name
+ name = superMethod.name
returnType = callee.returnType
isSuspend = callee.isSuspend
}.apply {
- overriddenSymbols += superMethod
+ overridden += superMethod
dispatchReceiverParameter = parentAsClass.thisReceiver!!.copyTo(this)
if (isLambda) createLambdaInvokeMethod() else createFunctionReferenceInvokeMethod(receiverVar)
}
@@ -244,7 +244,7 @@
callee.body?.statements?.forEach { statement ->
+statement.transform(object : IrElementTransformerVoid() {
override fun visitGetValue(expression: IrGetValue): IrExpression {
- val replacement = valueParameterMap[expression.symbol.owner]
+ val replacement = valueParameterMap[expression.target]
?: return super.visitGetValue(expression)
at(expression.startOffset, expression.endOffset)
@@ -252,7 +252,7 @@
}
override fun visitReturn(expression: IrReturn): IrExpression =
- if (expression.returnTargetSymbol != callee.symbol) {
+ if (expression.irReturnTarget != callee) {
super.visitReturn(expression)
} else {
at(expression.startOffset, expression.endOffset)
@@ -281,7 +281,7 @@
var unboundIndex = 0
irExprBody(irCall(callee).apply {
for ((typeParameter, typeArgument) in typeArgumentsMap) {
- putTypeArgument(typeParameter.owner.index, typeArgument)
+ putTypeArgument(typeParameter.index, typeArgument)
}
for (parameter in callee.explicitParameters) {
@@ -292,7 +292,7 @@
// will put it into a field.
if (samSuperType == null)
irImplicitCast(
- irGetField(irGet(dispatchReceiverParameter!!), irSymbols.functionReferenceReceiverField.owner),
+ irGetField(irGet(dispatchReceiverParameter!!), irSymbols.functionReferenceReceiverField),
boundReceiver.second.type
)
else
@@ -339,7 +339,7 @@
visibility = superFunction.visibility
isSuspend = superFunction.isSuspend
}.apply {
- overriddenSymbols += superFunction.symbol
+ overridden += superFunction
dispatchReceiverParameter = functionReferenceClass.thisReceiver?.copyTo(this)
}
@@ -351,8 +351,8 @@
body = context.createIrBuilder(symbol, startOffset, endOffset).run {
// TODO do not use descriptors
val declaration = codegenContext.referenceFunction(
- DescriptorUtils.unwrapFakeOverride(irFunctionReference.symbol.descriptor).original
- ).owner
+ DescriptorUtils.unwrapFakeOverride(irFunctionReference.target.descriptor).original
+ )
val method = codegenContext.methodSignatureMapper.mapAsmMethod(declaration)
irExprBody(irString(method.name + method.descriptor))
}
@@ -378,7 +378,7 @@
)
private fun IrBuilderWithScope.kClassToJavaClass(kClassReference: IrExpression, context: JvmBackendContext) =
- irGet(context.ir.symbols.javaLangClass.typeWith(), null, context.ir.symbols.kClassJava.owner.getter!!.symbol).apply {
+ irGet(context.ir.symbols.javaLangClass.typeWith(), null, context.ir.symbols.kClassJava.getter!!).apply {
extensionReceiver = kClassReference
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CheckLocalNamesWithOldBackend.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CheckLocalNamesWithOldBackend.kt
index a28d1d1..1684b699 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CheckLocalNamesWithOldBackend.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CheckLocalNamesWithOldBackend.kt
@@ -37,7 +37,7 @@
override fun visitClass(declaration: IrClass) {
val actualName = context.getLocalClassInfo(declaration)?.internalName
if (actualName != null) {
- val expectedName = context.state.bindingTrace.get(CodegenBinding.ASM_TYPE, declaration.symbol.descriptor)?.internalName
+ val expectedName = context.state.bindingTrace.get(CodegenBinding.ASM_TYPE, declaration.descriptor)?.internalName
if (expectedName != null && expectedName != actualName) {
throw AssertionError(
"Incorrect name for the class.\n" +
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt
index 30757c4..068022d 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt
@@ -17,13 +17,8 @@
import org.jetbrains.kotlin.ir.builders.irBlockBody
import org.jetbrains.kotlin.ir.builders.irCall
import org.jetbrains.kotlin.ir.builders.irString
-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.IrValueParameter
+import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
@@ -58,7 +53,7 @@
if (existingMethod != null) {
// In the case that we find a defined method that matches the stub signature, we add the overridden symbols to that
// defined method, so that bridge lowering can still generate correct bridge for that method
- existingMethod.overriddenSymbols.addAll(member.overriddenSymbols)
+ existingMethod.overridden.addAll(member.overridden)
} else {
irClass.declarations.add(member)
}
@@ -68,7 +63,7 @@
private fun IrSimpleFunction.toSignature(): String = methodSignatureMapper.mapAsmMethod(this).toString()
private fun createStubMethod(
- function: IrSimpleFunction, irClass: IrClass, substitutionMap: Map<IrTypeParameterSymbol, IrType>
+ function: IrSimpleFunction, irClass: IrClass, substitutionMap: Map<IrTypeParameter, IrType>
): IrSimpleFunction {
return buildFun {
name = function.name
@@ -79,7 +74,7 @@
}.apply {
// Replace Function metadata with the data from class
// Add the abstract function symbol to stub function for bridge lowering
- overriddenSymbols.add(function.symbol)
+ overridden.add(function)
parent = irClass
dispatchReceiverParameter = function.dispatchReceiverParameter?.copyWithSubstitution(this, substitutionMap)
extensionReceiverParameter = function.extensionReceiverParameter?.copyWithSubstitution(this, substitutionMap)
@@ -88,10 +83,10 @@
}
val exception = context.getTopLevelClass(FqName("java.lang.UnsupportedOperationException"))
// Function body consist only of throwing UnsupportedOperationException statement
- body = context.createIrBuilder(function.symbol).irBlockBody {
+ body = context.createIrBuilder(function).irBlockBody {
+irThrow(
irCall(
- exception.owner.constructors.single {
+ exception.constructors.single {
it.valueParameters.size == 1 && it.valueParameters.single().type.isNullableString()
}
).apply {
@@ -103,7 +98,7 @@
}
// Copy value parameter with type substitution
- private fun IrValueParameter.copyWithSubstitution(target: IrSimpleFunction, substitutionMap: Map<IrTypeParameterSymbol, IrType>)
+ private fun IrValueParameter.copyWithSubstitution(target: IrSimpleFunction, substitutionMap: Map<IrTypeParameter, IrType>)
: IrValueParameter {
val descriptor = WrappedValueParameterDescriptor(this.descriptor.annotations)
return IrValueParameterImpl(
@@ -125,11 +120,11 @@
// Compute a substitution map for type parameters between source class (Mutable Collection classes) to
// target class (class currently in lowering phase), this map is later used for substituting type parameters in generated functions
private fun computeSubstitutionMap(readOnlyClass: IrClass, mutableClass: IrClass, targetClass: IrClass)
- : Map<IrTypeParameterSymbol, IrType> {
+ : Map<IrTypeParameter, IrType> {
// We find the most specific type for the immutable collection class from the inheritance chain of target class
// Perform type substitution along searching, then use the type arguments obtained from the most specific type
// for type substitution.
- val readOnlyClassType = getAllSupertypes(targetClass).findMostSpecificTypeForClass(readOnlyClass.symbol)
+ val readOnlyClassType = getAllSupertypes(targetClass).findMostSpecificTypeForClass(readOnlyClass)
val readOnlyClassTypeArguments = (readOnlyClassType as IrSimpleType).arguments.mapNotNull { (it as? IrTypeProjection)?.type }
if (readOnlyClassTypeArguments.isEmpty() || readOnlyClassTypeArguments.size != mutableClass.typeParameters.size) {
@@ -139,17 +134,16 @@
"class ${targetClass.fqNameWhenAvailable}"
)
}
- return mutableClass.typeParameters.map { it.symbol }.zip(readOnlyClassTypeArguments).toMap()
+ return mutableClass.typeParameters.zip(readOnlyClassTypeArguments).toMap()
}
private inner class StubsForCollectionClass(
- val readOnlyClass: IrClassSymbol,
- val mutableClass: IrClassSymbol
+ val readOnlyClass: IrClass,
+ val mutableClass: IrClass
) {
val mutableOnlyMethods: Collection<IrSimpleFunction> by lazy {
- val readOnlyMethodSignatures = readOnlyClass.functions.map { it.owner.toSignature() }.toHashSet()
+ val readOnlyMethodSignatures = readOnlyClass.functions.map { it.toSignature() }.toHashSet()
mutableClass.functions
- .map { it.owner }
.filter { it.toSignature() !in readOnlyMethodSignatures }
.toHashSet()
}
@@ -179,14 +173,14 @@
// Compute stubs that should be generated, compare based on signature
private fun generateRelevantStubMethods(irClass: IrClass): Set<IrSimpleFunction> {
val ourStubsForCollectionClasses = preComputedStubs.filter { (readOnlyClass, mutableClass) ->
- irClass.superTypes.any { supertypeSymbol ->
- val supertype = supertypeSymbol.classOrNull?.owner
+ irClass.superTypes.any { supertype ->
+ val supertypeCLass = supertype.classOrNull?.owner
// We need to generate stub methods for following 2 cases:
// current class's direct super type is a java class or kotlin interface, and is an subtype of an immutable collection
- supertype != null
- && (supertype.comesFromJava() || supertype.isInterface)
- && supertypeSymbol.isSubtypeOfClass(readOnlyClass)
- && !irClass.symbol.isSubtypeOfClass(mutableClass)
+ supertypeCLass != null
+ && (supertypeCLass.comesFromJava() || supertypeCLass.isInterface)
+ && supertype.isSubtypeOfClass(readOnlyClass)
+ && !irClass.isSubtypeOfClass(mutableClass)
}
}
@@ -199,7 +193,7 @@
return ourStubsForCollectionClasses.filter { (readOnlyClass) ->
readOnlyClass !in redundantClasses
}.flatMap { (readOnlyClass, mutableClass, mutableOnlyMethods) ->
- val substitutionMap = computeSubstitutionMap(readOnlyClass.owner, mutableClass.owner, irClass)
+ val substitutionMap = computeSubstitutionMap(readOnlyClass, mutableClass, irClass)
mutableOnlyMethods.map { function ->
createStubMethod(function, irClass, substitutionMap)
}
@@ -208,9 +202,9 @@
fun IrClass.comesFromJava() = origin in ORIGINS_FROM_JAVA
- private fun Collection<IrType>.findMostSpecificTypeForClass(classifier: IrClassSymbol): IrType {
- val types = this.filter { it.classifierOrNull == classifier }
- if (types.isEmpty()) error("No supertype of $classifier in $this")
+ private fun Collection<IrType>.findMostSpecificTypeForClass(clazz: IrClass): IrType {
+ val types = this.filter { it.classifierOrNull == clazz.symbol }
+ if (types.isEmpty()) error("No supertype of $clazz in $this")
if (types.size == 1) return types.first()
// Find the first type in the list such that it's a subtype of every other type in that list
return types.first { type ->
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ConstLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ConstLowering.kt
index 926af82..6451b54 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ConstLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ConstLowering.kt
@@ -39,7 +39,7 @@
}
override fun visitCall(expression: IrCall): IrExpression {
- val function = (expression.symbol.owner as? IrSimpleFunction) ?: return super.visitCall(expression)
+ val function = (expression.target as? IrSimpleFunction) ?: return super.visitCall(expression)
val property = function.correspondingPropertySymbol?.owner ?: return super.visitCall(expression)
if (function != property.getter)
return super.visitCall(expression)
@@ -47,5 +47,5 @@
}
override fun visitGetField(expression: IrGetField): IrExpression =
- expression.symbol.owner.constantValue() ?: super.visitGetField(expression)
+ expression.target.constantValue() ?: super.visitGetField(expression)
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt
index ec21a6e..e5ba7de 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt
@@ -25,8 +25,6 @@
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
@@ -60,8 +58,8 @@
private inner class EnumClassTransformer(val irClass: IrClass) {
private val enumEntryOrdinals = TObjectIntHashMap<IrEnumEntry>()
private val enumEntryClassToEntry = HashMap<IrClass, IrEnumEntry>()
- private val loweredEnumConstructors = HashMap<IrConstructorSymbol, IrConstructorImpl>()
- private val loweredEnumConstructorParameters = HashMap<IrValueParameterSymbol, IrValueParameter>()
+ private val loweredEnumConstructors = HashMap<IrConstructor, IrConstructorImpl>()
+ private val loweredEnumConstructorParameters = HashMap<IrValueParameter, IrValueParameter>()
private val enumEntriesByField = HashMap<IrField, IrEnumEntry>()
private val enumEntryFields = ArrayList<IrField>()
@@ -125,13 +123,13 @@
valueParameters.add(1, ordinalParameter)
valueParameters.addAll(enumConstructor.valueParameters.map { param ->
param.copyTo(newConstructor, index = param.index + 2).also { newParam ->
- loweredEnumConstructorParameters[param.symbol] = newParam
+ loweredEnumConstructorParameters[param] = newParam
}
})
body = enumConstructor.body?.patchDeclarationParents(this)
- loweredEnumConstructors[enumConstructor.symbol] = this
+ loweredEnumConstructors[enumConstructor] = this
metadata = enumConstructor.metadata
}
}
@@ -247,9 +245,9 @@
}
private fun createSyntheticValuesFieldInitializerExpression(): IrExpression =
- context.createJvmIrBuilder(irClass.symbol).irArray(context.irBuiltIns.arrayClass.typeWith(irClass.defaultType)) {
+ context.createJvmIrBuilder(irClass).irArray(context.irBuiltIns.arrayClass.typeWith(irClass.defaultType)) {
enumEntryFields.forEach { irField ->
- +IrGetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irField.symbol, irField.type)
+ +IrGetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irField, irField.type)
}
}
@@ -268,7 +266,7 @@
startOffset,
endOffset,
context.irBuiltIns.unitType,
- enumConstructorCall.symbol,
+ enumConstructorCall.target,
enumConstructorCall.descriptor,
enumConstructorCall.typeArgumentsCount
)
@@ -276,7 +274,7 @@
assert(enumConstructorCall.typeArgumentsCount == 1) { "Enum<T> call expected:\n${result.dump()}" }
result.putTypeArgument(0, enumConstructorCall.getTypeArgument(0))
- assert(result.symbol.owner.valueParameters.size == 2) {
+ assert(result.target.valueParameters.size == 2) {
"Enum(String, Int) constructor call expected:\n${result.dump()}"
}
@@ -288,8 +286,8 @@
throw AssertionError("No 'ordinal' parameter in enum constructor: ${irEnumConstructor.dump()}")
}
- result.putValueArgument(0, IrGetValueImpl(startOffset, endOffset, nameParameter.symbol, origin))
- result.putValueArgument(1, IrGetValueImpl(startOffset, endOffset, ordinalParameter.symbol, origin))
+ result.putValueArgument(0, IrGetValueImpl(startOffset, endOffset, nameParameter, origin))
+ result.putValueArgument(1, IrGetValueImpl(startOffset, endOffset, ordinalParameter, origin))
return result
}
@@ -298,25 +296,25 @@
val startOffset = delegatingConstructorCall.startOffset
val endOffset = delegatingConstructorCall.endOffset
- val loweredDelegatedConstructor = loweredEnumConstructors.getOrElse(delegatingConstructorCall.symbol) {
- throw AssertionError("Constructor called in enum entry initializer should've been lowered: ${delegatingConstructorCall.symbol}")
+ val loweredDelegatedConstructor = loweredEnumConstructors.getOrElse(delegatingConstructorCall.target) {
+ throw AssertionError("Constructor called in enum entry initializer should've been lowered: ${delegatingConstructorCall.target}")
}
val result = IrDelegatingConstructorCallImpl(
startOffset,
endOffset,
context.irBuiltIns.unitType,
- loweredDelegatedConstructor.symbol,
+ loweredDelegatedConstructor,
loweredDelegatedConstructor.descriptor,
loweredDelegatedConstructor.typeParameters.size
)
assert(loweredDelegatedConstructor.typeParameters.size == 0) { "Enum delegating call expected:\n${result.dump()}" }
- result.putValueArgument(0, IrGetValueImpl(startOffset, endOffset, irEnumConstructor.valueParameters[0].symbol))
- result.putValueArgument(1, IrGetValueImpl(startOffset, endOffset, irEnumConstructor.valueParameters[1].symbol))
+ result.putValueArgument(0, IrGetValueImpl(startOffset, endOffset, irEnumConstructor.valueParameters[0]))
+ result.putValueArgument(1, IrGetValueImpl(startOffset, endOffset, irEnumConstructor.valueParameters[1]))
- delegatingConstructorCall.symbol.owner.valueParameters.forEach { valueParameter ->
+ delegatingConstructorCall.target.valueParameters.forEach { valueParameter ->
val i = valueParameter.index
result.putValueArgument(i + 2, delegatingConstructorCall.getValueArgument(i))
}
@@ -333,7 +331,7 @@
val startOffset = enumConstructorCall.startOffset
val endOffset = enumConstructorCall.endOffset
- val loweredConstructor = loweredEnumConstructors.getOrElse(enumConstructorCall.symbol) {
+ val loweredConstructor = loweredEnumConstructors.getOrElse(enumConstructorCall.target) {
throw AssertionError("Constructor called in enum entry initializer should've been lowered:\n${enumConstructorCall.dump()}")
}
@@ -342,7 +340,7 @@
result.putValueArgument(0, IrConstImpl.string(startOffset, endOffset, context.irBuiltIns.stringType, name))
result.putValueArgument(1, IrConstImpl.int(startOffset, endOffset, context.irBuiltIns.intType, ordinal))
- enumConstructorCall.symbol.owner.valueParameters.forEach { valueParameter ->
+ enumConstructorCall.target.valueParameters.forEach { valueParameter ->
val i = valueParameter.index
result.putValueArgument(i + 2, enumConstructorCall.getValueArgument(i))
}
@@ -367,7 +365,7 @@
startOffset,
endOffset,
context.irBuiltIns.unitType,
- loweredConstructor.symbol,
+ loweredConstructor,
loweredConstructor.descriptor,
loweredConstructor.typeParameters.size
)
@@ -378,8 +376,8 @@
IrConstructorCallImpl.fromSymbolDescriptor(
startOffset,
endOffset,
- loweredConstructor.symbol.owner.parentAsClass.defaultType,
- loweredConstructor.symbol
+ loweredConstructor.parentAsClass.defaultType,
+ loweredConstructor
)
}
@@ -439,7 +437,7 @@
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
expression.transformChildrenVoid(this)
- if (expression.symbol.owner.parentAsClass.kind == ClassKind.ENUM_CLASS) {
+ if (expression.target.parentAsClass.kind == ClassKind.ENUM_CLASS) {
val callTransformer = enumConstructorCallTransformer ?: throw AssertionError(
"Enum constructor call outside of enum entry initialization or enum class constructor:\n" +
irClass.dump()
@@ -452,9 +450,9 @@
}
override fun visitGetValue(expression: IrGetValue): IrExpression {
- val loweredParameter = loweredEnumConstructorParameters[expression.symbol]
+ val loweredParameter = loweredEnumConstructorParameters[expression.target]
return if (loweredParameter != null) {
- IrGetValueImpl(expression.startOffset, expression.endOffset, loweredParameter.symbol, expression.origin)
+ IrGetValueImpl(expression.startOffset, expression.endOffset, loweredParameter, expression.origin)
} else {
expression
}
@@ -492,7 +490,7 @@
)
irValueOfCall.putTypeArgument(0, irClass.defaultType)
irValueOfCall.putValueArgument(
- 0, IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, valueOfFunction.valueParameters[0].symbol)
+ 0, IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, valueOfFunction.valueParameters[0])
)
return IrBlockBodyImpl(
@@ -502,7 +500,7 @@
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
returnType,
- valueOfFunction.symbol,
+ valueOfFunction,
irValueOfCall
)
)
@@ -511,11 +509,11 @@
private fun createEnumValuesBody(valuesField: IrField): IrBody {
val cloneFun = context.irBuiltIns.arrayClass.owner.functions.find { it.name.asString() == "clone" }!!
- val returnType = valuesFunction.symbol.owner.returnType
+ val returnType = valuesFunction.returnType
val irCloneValues =
- IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, returnType, cloneFun.symbol, cloneFun.descriptor, 0).apply {
+ IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, returnType, cloneFun, cloneFun.descriptor, 0).apply {
dispatchReceiver =
- IrGetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, valuesField.symbol, valuesField.symbol.owner.type)
+ IrGetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, valuesField, valuesField.type)
}
return IrBlockBodyImpl(
@@ -525,7 +523,7 @@
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
returnType,
- valuesFunction.symbol,
+ valuesFunction,
irCloneValues
)
)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt
index cdc6ac2..6d61dfb 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt
@@ -110,7 +110,7 @@
private fun tryFoldingUnaryOps(call: IrCall): IrExpression {
val operand = call.dispatchReceiver as? IrConst<*> ?: return call
val evaluated = evaluateUnary(
- call.symbol.owner.name.toString(),
+ call.target.name.toString(),
operand.kind.toString(),
operand.value!!
) ?: return call
@@ -124,14 +124,14 @@
val evaluated = try {
fun String.toNonNullable() = if (this.endsWith('?')) this.dropLast(1) else this
evaluateBinary(
- call.symbol.owner.name.toString(),
+ call.target.name.toString(),
lhs.kind.toString(),
lhs.value!!,
// 1. Although some operators have nullable parameters, evaluators deals with non-nullable types only.
// The passed parameters are guaranteed to be non-null, since they are from IrConst.
// 2. The operators are registered with prototype as if virtual member functions. They are identified by
// actual_receiver_type.operator_name(parameter_type_in_prototype).
- call.symbol.owner.valueParameters[0].type.toKotlinType().toString().toNonNullable(),
+ call.target.valueParameters[0].type.toKotlinType().toString().toNonNullable(),
rhs.value!!
) ?: return call
} catch (e: Exception) {
@@ -144,7 +144,7 @@
private fun tryFoldingBuiltinBinaryOps(call: IrCall): IrExpression {
// Make sure that this is a IrBuiltIn
- if (call.symbol.owner.fqNameWhenAvailable?.parent() != IrBuiltIns.KOTLIN_INTERNAL_IR_FQN)
+ if (call.target.fqNameWhenAvailable?.parent() != IrBuiltIns.KOTLIN_INTERNAL_IR_FQN)
return call
val lhs = call.getValueArgument(0) as? IrConst<*> ?: return call
@@ -152,7 +152,7 @@
val evaluated = try {
val evaluator =
- BINARY_OP_TO_EVALUATOR[BinaryOp(lhs.kind.toString(), rhs.kind.toString(), call.symbol.owner.name.toString())] ?: return call
+ BINARY_OP_TO_EVALUATOR[BinaryOp(lhs.kind.toString(), rhs.kind.toString(), call.target.name.toString())] ?: return call
evaluator(lhs.value!!, rhs.value!!)
} catch (e: Exception) {
return call
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargBridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargBridgeLowering.kt
index 41d07c4..4bfcbc8 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargBridgeLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargBridgeLowering.kt
@@ -48,11 +48,11 @@
// Change calls to big arity invoke functions to vararg calls.
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
if (expression.valueArgumentsCount < FunctionInvokeDescriptor.BIG_ARITY ||
- !expression.symbol.owner.parentAsClass.defaultType.isFunctionOrKFunction() ||
- expression.symbol.owner.name.asString() != "invoke")
+ !expression.target.parentAsClass.defaultType.isFunctionOrKFunction() ||
+ expression.target.name.asString() != "invoke")
return super.visitFunctionAccess(expression)
- return context.createJvmIrBuilder(currentScope!!.scope.scopeOwnerSymbol).run {
+ return context.createJvmIrBuilder(currentScope!!.scope.irScopeOwner).run {
at(expression)
irCall(functionNInvokeFun).apply {
dispatchReceiver = expression.dispatchReceiver
@@ -90,8 +90,8 @@
val invokeFunction = declaration.functions.single {
it.name.asString() == "invoke" && it.valueParameters.size == superType.arguments.size - 1
}
- invokeFunction.overriddenSymbols.clear()
- declaration.addBridge(invokeFunction, functionNInvokeFun.owner)
+ invokeFunction.overridden.clear()
+ declaration.addBridge(invokeFunction, functionNInvokeFun)
return declaration
}
@@ -104,7 +104,7 @@
visibility = Visibilities.PUBLIC
origin = IrDeclarationOrigin.BRIDGE
}.apply {
- overriddenSymbols += superFunction.symbol
+ overridden += superFunction
dispatchReceiverParameter = thisReceiver!!.copyTo(this)
valueParameters += superFunction.valueParameters.single().copyTo(this)
@@ -154,14 +154,14 @@
}
private val functionNInvokeFun =
- context.ir.symbols.functionN.functions.single { it.owner.name.toString() == "invoke" }
+ context.ir.symbols.functionN.functions.single { it.name.toString() == "invoke" }
private val arraySizePropertyGetter by lazy {
context.irBuiltIns.arrayClass.owner.properties.single { it.name.toString() == "size" }.getter!!
}
private val arrayGetFun by lazy {
- context.irBuiltIns.arrayClass.functions.single { it.owner.name.toString() == "get" }
+ context.irBuiltIns.arrayClass.functions.single { it.name.toString() == "get" }
}
private val FUNCTIONS_PACKAGE_FQ_NAME =
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt
index d9324d1..cf23c99 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt
@@ -39,8 +39,6 @@
import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.transformFlat
@@ -59,8 +57,8 @@
context: JvmBackendContext,
input: IrModuleFragment
): IrModuleFragment {
- val movedFields = mutableMapOf<IrFieldSymbol, IrFieldSymbol>()
- val functionDelegates = mutableMapOf<IrFunctionSymbol, IrFunctionSymbol>()
+ val movedFields = mutableMapOf<IrField, IrField>()
+ val functionDelegates = mutableMapOf<IrFunction, IrFunction>()
input.files.addAll(generateMultifileFacades(input.descriptor, context, movedFields, functionDelegates))
@@ -99,8 +97,8 @@
private fun generateMultifileFacades(
module: ModuleDescriptor,
context: JvmBackendContext,
- movedFields: MutableMap<IrFieldSymbol, IrFieldSymbol>,
- functionDelegates: MutableMap<IrFunctionSymbol, IrFunctionSymbol>
+ movedFields: MutableMap<IrField, IrField>,
+ functionDelegates: MutableMap<IrFunction, IrFunction>
): List<IrFile> =
context.multifileFacadesToAdd.map { (jvmClassName, partClasses) ->
val fileEntry = MultifileFacadeFileEntry(jvmClassName, partClasses.map(IrClass::fileParent))
@@ -123,7 +121,7 @@
if (member is IrFunction) {
val newMember = member.createMultifileDelegateIfNeeded(context, facadeClass)
if (newMember != null) {
- functionDelegates[member.symbol] = newMember.symbol
+ functionDelegates[member] = newMember
}
}
}
@@ -135,7 +133,7 @@
private fun moveFieldsOfConstProperties(
partClass: IrClass,
facadeClass: IrClass,
- movedFields: MutableMap<IrFieldSymbol, IrFieldSymbol>
+ movedFields: MutableMap<IrField, IrField>
) {
partClass.declarations.transformFlat { member ->
if (member is IrField && member.shouldMoveToFacade()) {
@@ -143,7 +141,7 @@
(it as IrFieldImpl).metadata = member.metadata
}
facadeClass.declarations.add(field)
- movedFields[member.symbol] = field.symbol
+ movedFields[member] = field
emptyList()
} else null
}
@@ -198,29 +196,29 @@
}
private class UpdateFieldCallSites(
- private val movedFields: Map<IrFieldSymbol, IrFieldSymbol>
+ private val movedFields: Map<IrField, IrField>
) : FileLoweringPass, IrElementTransformerVoid() {
override fun lower(irFile: IrFile) {
irFile.transformChildrenVoid(this)
}
override fun visitGetField(expression: IrGetField): IrExpression {
- val newField = movedFields[expression.symbol] ?: return super.visitGetField(expression)
+ val newField = movedFields[expression.target] ?: return super.visitGetField(expression)
return expression.run {
- IrGetFieldImpl(startOffset, endOffset, newField, type, receiver, origin, superQualifierSymbol)
+ IrGetFieldImpl(startOffset, endOffset, newField, type, receiver, origin, irSuperQualifier)
}
}
}
private class UpdateFunctionCallSites(
- private val functionDelegates: MutableMap<IrFunctionSymbol, IrFunctionSymbol>
+ private val functionDelegates: MutableMap<IrFunction, IrFunction>
) : FileLoweringPass, IrElementTransformerVoid() {
override fun lower(irFile: IrFile) {
irFile.transformChildrenVoid(this)
}
override fun visitCall(expression: IrCall): IrExpression {
- val newFunction = functionDelegates[expression.symbol] ?: return super.visitCall(expression)
+ val newFunction = functionDelegates[expression.target] ?: return super.visitCall(expression)
return expression.run {
// TODO: deduplicate this with ReplaceKFunctionInvokeWithFunctionInvoke
IrCallImpl(startOffset, endOffset, type, newFunction).apply {
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableRefereceToLambda.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableRefereceToLambda.kt
index a17fe24..3002644 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableRefereceToLambda.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableRefereceToLambda.kt
@@ -11,7 +11,6 @@
import org.jetbrains.kotlin.backend.common.ir.copyTo
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
import org.jetbrains.kotlin.backend.common.ir.copyValueParametersToStatic
-import org.jetbrains.kotlin.backend.jvm.ir.isInlineParameter
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.backend.common.lower.irBlock
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
@@ -19,6 +18,7 @@
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineFunctionCall
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineIrExpression
+import org.jetbrains.kotlin.backend.jvm.ir.isInlineParameter
import org.jetbrains.kotlin.codegen.AsmUtil.BOUND_REFERENCE_RECEIVER
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.builders.*
@@ -55,7 +55,7 @@
irFile.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
- val callee = expression.symbol.owner
+ val callee = expression.target
if (callee.isInlineFunctionCall(context)) {
for (valueParameter in callee.valueParameters) {
if (valueParameter.isInlineParameter()) {
@@ -79,11 +79,11 @@
//Use getter if field is absent...
val field =
- expression.field?.owner ?: return functionReferenceToLambda(currentScope!!, expression, expression.getter!!.owner)
+ expression.field ?: return functionReferenceToLambda(currentScope!!, expression, expression.getter!!)
//..else use field itself
val irBuilder =
- context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset)
+ context.createIrBuilder(currentScope!!.scope.irScopeOwner, expression.startOffset, expression.endOffset)
val boundReceiver = expression.dispatchReceiver ?: expression.extensionReceiver
return irBuilder.irBlock(expression, IrStatementOrigin.LAMBDA) {
lateinit var variableForBoundReceiver: IrVariable
@@ -107,7 +107,7 @@
else -> addValueParameter("receiver", field.parentAsClass.defaultType)
}
- val lambdaBodyBuilder = this@InlineCallableReferenceToLambdaPhase.context.createIrBuilder(this.symbol)
+ val lambdaBodyBuilder = this@InlineCallableReferenceToLambdaPhase.context.createIrBuilder(this)
body = lambdaBodyBuilder.irBlockBody(startOffset, endOffset) {
+irReturn(irGetField(if (receiver != null) irGet(receiver) else null, field))
}
@@ -116,7 +116,7 @@
+IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset, field.type,
- newLambda.symbol, newLambda.symbol.descriptor, 0,
+ newLambda, newLambda.descriptor, 0,
IrStatementOrigin.LAMBDA
)
}
@@ -124,7 +124,7 @@
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
if (inlinableCR.contains(expression)) {
- val referencedFunction = expression.symbol.owner
+ val referencedFunction = expression.target
return functionReferenceToLambda(currentScope!!, expression, referencedFunction)
}
@@ -139,7 +139,7 @@
referencedFunction: IrFunction
): IrExpression {
val irBuilder =
- context.createIrBuilder(scope.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset)
+ context.createIrBuilder(scope.scope.irScopeOwner, expression.startOffset, expression.endOffset)
val boundReceiver = expression.dispatchReceiver ?: expression.extensionReceiver
return irBuilder.irBlock(expression, IrStatementOrigin.LAMBDA) {
@@ -173,13 +173,13 @@
)
}
}
- val lambdaBodyBuilder = this@InlineCallableReferenceToLambdaPhase.context.createIrBuilder(this.symbol)
+ val lambdaBodyBuilder = this@InlineCallableReferenceToLambdaPhase.context.createIrBuilder(this)
body = lambdaBodyBuilder.irBlockBody(startOffset, endOffset) {
var shift = 0
val irCall =
if (expression is IrPropertyReference)
- irGet(referencedFunction.returnType, null, referencedFunction.symbol)
- else irCall(referencedFunction.symbol)
+ irGet(referencedFunction.returnType, null, referencedFunction)
+ else irCall(referencedFunction)
+irReturn(
irCall.also { call ->
@@ -207,7 +207,7 @@
+IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset, referencedFunction.returnType,
- newLambda.symbol, newLambda.symbol.descriptor, referencedFunction.typeParameters.size,
+ newLambda, newLambda.descriptor, referencedFunction.typeParameters.size,
IrStatementOrigin.LAMBDA
)
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt
index 4b79211..e44793e 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt
@@ -33,7 +33,6 @@
import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrPropertySymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
import org.jetbrains.kotlin.ir.util.*
@@ -48,12 +47,12 @@
)
private class InterfaceDelegationLowering(val context: JvmBackendContext) : IrElementVisitorVoid, FileLoweringPass {
- val replacementMap = mutableMapOf<IrSimpleFunctionSymbol, IrSimpleFunctionSymbol>()
+ val replacementMap = mutableMapOf<IrSimpleFunction, IrSimpleFunction>()
override fun lower(irFile: IrFile) {
irFile.acceptChildrenVoid(this)
// TODO: Replacer should be run on whole module, not on a single file.
- irFile.acceptVoid(OverriddenSymbolsReplacer(replacementMap))
+ irFile.acceptVoid(OverriddenReplacer(replacementMap))
}
override fun visitElement(element: IrElement) {
@@ -81,9 +80,9 @@
// In classes, only generate interface delegation for functions immediately inherited from am interface.
// (Otherwise, delegation will be present in the parent class)
if (!isDefaultImplsGeneration &&
- function.overriddenSymbols.any {
- (!it.owner.parentAsClass.isInterface || it.owner.hasJvmDefault()) &&
- it.owner.modality != Modality.ABSTRACT
+ function.overridden.any {
+ (!it.parentAsClass.isInterface || it.hasJvmDefault()) &&
+ it.modality != Modality.ABSTRACT
}
) {
continue
@@ -100,7 +99,7 @@
val delegation = generateDelegationToDefaultImpl(irClass, implementation, function, isDefaultImplsGeneration)
if (!isDefaultImplsGeneration) {
toRemove.add(function)
- replacementMap[function.symbol] = delegation.symbol
+ replacementMap[function] = delegation
}
}
irClass.declarations.removeAll(toRemove)
@@ -134,7 +133,7 @@
).apply {
descriptor.bind(this)
parent = irClass
- overriddenSymbols.addAll(inheritedFun.overriddenSymbols)
+ overridden.addAll(inheritedFun.overridden)
copyParameterDeclarationsFrom(inheritedFun)
annotations.addAll(inheritedFun.annotations)
@@ -155,10 +154,10 @@
irClass.declarations.add(irFunction)
- context.createIrBuilder(irFunction.symbol, UNDEFINED_OFFSET, UNDEFINED_OFFSET).apply {
+ context.createIrBuilder(irFunction, UNDEFINED_OFFSET, UNDEFINED_OFFSET).apply {
irFunction.body = irBlockBody {
+irReturn(
- irCall(defaultImplFun.symbol, irFunction.returnType).apply {
+ irCall(defaultImplFun, irFunction.returnType).apply {
var offset = 0
passTypeArgumentsFrom(irFunction)
irFunction.dispatchReceiverParameter?.let { putValueArgument(offset++, irGet(it)) }
@@ -172,7 +171,7 @@
return irFunction
}
- private class OverriddenSymbolsReplacer(val replacementMap: Map<IrSimpleFunctionSymbol, IrSimpleFunctionSymbol>) :
+ private class OverriddenReplacer(val replacementMap: Map<IrSimpleFunction, IrSimpleFunction>) :
IrElementVisitorVoid {
override fun visitElement(element: IrElement) {
@@ -180,7 +179,7 @@
}
override fun visitSimpleFunction(declaration: IrSimpleFunction) {
- declaration.overriddenSymbols.replaceAll(UnaryOperator { symbol -> replacementMap[symbol] ?: symbol })
+ declaration.overridden.replaceAll(UnaryOperator { function -> replacementMap[function] ?: function })
super.visitSimpleFunction(declaration)
}
}
@@ -202,10 +201,10 @@
}
override fun visitCall(expression: IrCall): IrExpression {
- if (expression.superQualifierSymbol?.owner?.isInterface != true) {
+ if (expression.irSuperQualifier?.isInterface != true) {
return super.visitCall(expression)
}
- val superCallee = (expression.symbol.owner as IrSimpleFunction).resolveFakeOverride()!!
+ val superCallee = (expression.target as IrSimpleFunction).resolveFakeOverride()!!
if (superCallee.isDefinitelyNotDefaultImplsMethod()) return super.visitCall(expression)
val redirectTarget = context.declarationFactory.getDefaultImplsFunction(superCallee)
@@ -228,7 +227,7 @@
}
override fun visitCall(expression: IrCall): IrExpression {
- val callee = expression.symbol.owner
+ val callee = expression.target
if (callee.parent.safeAs<IrClass>()?.isInterface != true ||
callee.origin != IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt
index 5462071..ce9ecc3 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt
@@ -20,8 +20,6 @@
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
import org.jetbrains.kotlin.ir.expressions.IrReturn
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
import org.jetbrains.kotlin.ir.util.copyTypeAndValueArgumentsFrom
import org.jetbrains.kotlin.ir.util.irCall
import org.jetbrains.kotlin.ir.util.isInterface
@@ -38,7 +36,7 @@
private class InterfaceLowering(val context: JvmBackendContext) : IrElementTransformerVoid(), ClassLoweringPass {
val state = context.state
- val removedFunctions = hashMapOf<IrFunctionSymbol, IrFunctionSymbol>()
+ val removedFunctions = hashMapOf<IrFunction, IrFunction>()
override fun lower(irClass: IrClass) {
if (!irClass.isInterface) return
@@ -53,7 +51,7 @@
if (function.modality != Modality.ABSTRACT && function.origin != IrDeclarationOrigin.FAKE_OVERRIDE) {
val element = context.declarationFactory.getDefaultImplsFunction(function).also {
if (shouldRemoveFunction(function))
- removedFunctions[function.symbol] = it.symbol
+ removedFunctions[function] = it
}
members.add(element)
element.body = function.body?.patchDeclarationParents(element)
@@ -73,14 +71,14 @@
irClass.transformChildrenVoid(this)
irClass.declarations.removeAll {
- it is IrFunction && removedFunctions.containsKey(it.symbol)
+ it is IrFunction && removedFunctions.containsKey(it)
}
// Move metadata for local delegated properties from the interface to DefaultImpls, since this is where kotlin-reflect looks for it.
val localDelegatedProperties = context.localDelegatedProperties[irClass.attributeOwnerId as IrClass]
if (localDelegatedProperties != null) {
context.localDelegatedProperties[defaultImplsIrClass.attributeOwnerId as IrClass] = localDelegatedProperties
- context.localDelegatedProperties[irClass.attributeOwnerId as IrClass] = emptyList<IrLocalDelegatedPropertySymbol>()
+ context.localDelegatedProperties[irClass.attributeOwnerId as IrClass] = emptyList<IrLocalDelegatedProperty>()
}
// Move $$delegatedProperties array
@@ -103,28 +101,28 @@
val startOffset = interfaceMethod.startOffset
val endOffset = interfaceMethod.endOffset
- return IrCallImpl(startOffset, endOffset, interfaceMethod.returnType, defaultImpls.symbol).apply {
+ return IrCallImpl(startOffset, endOffset, interfaceMethod.returnType, defaultImpls).apply {
passTypeArgumentsFrom(interfaceMethod)
var offset = 0
interfaceMethod.dispatchReceiverParameter?.let {
- putValueArgument(offset++, IrGetValueImpl(startOffset, endOffset, it.symbol))
+ putValueArgument(offset++, IrGetValueImpl(startOffset, endOffset, it))
}
interfaceMethod.extensionReceiverParameter?.let {
- putValueArgument(offset++, IrGetValueImpl(startOffset, endOffset, it.symbol))
+ putValueArgument(offset++, IrGetValueImpl(startOffset, endOffset, it))
}
interfaceMethod.valueParameters.forEachIndexed { i, it ->
- putValueArgument(i + offset, IrGetValueImpl(startOffset, endOffset, it.symbol))
+ putValueArgument(i + offset, IrGetValueImpl(startOffset, endOffset, it))
}
}
}
override fun visitReturn(expression: IrReturn): IrExpression {
- val newFunction = removedFunctions[expression.returnTargetSymbol]?.owner
+ val newFunction = removedFunctions[expression.irReturnTarget]
return super.visitReturn(
if (newFunction != null) {
with(expression) {
- IrReturnImpl(startOffset, endOffset, type, newFunction.symbol, value)
+ IrReturnImpl(startOffset, endOffset, type, newFunction, value)
}
} else {
expression
@@ -133,7 +131,7 @@
}
override fun visitCall(expression: IrCall): IrExpression {
- val newFunction = removedFunctions[expression.symbol]?.owner
+ val newFunction = removedFunctions[expression.target]
return super.visitCall(
if (newFunction != null) {
irCall(expression, newFunction, receiversAsArguments = true)
@@ -144,7 +142,7 @@
}
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
- val newFunction = removedFunctions[expression.symbol]?.owner
+ val newFunction = removedFunctions[expression.target]
return super.visitFunctionReference(
if (newFunction != null) {
with(expression) {
@@ -152,7 +150,7 @@
startOffset,
endOffset,
type,
- newFunction.symbol,
+ newFunction,
newFunction.descriptor,
typeArgumentsCount,
origin
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt
index f452ab4..e097cf5 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InventNamesForLocalClasses.kt
@@ -12,8 +12,6 @@
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
-import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.ir.util.isAnonymousObject
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
import org.jetbrains.kotlin.name.Name
@@ -44,7 +42,7 @@
private inner class NameInventor : IrElementVisitor<Unit, Data> {
private val anonymousClassesCount = mutableMapOf<String, Int>()
- private val localFunctionNames = mutableMapOf<IrFunctionSymbol, String>()
+ private val localFunctionNames = mutableMapOf<IrFunction, String>()
override fun visitClass(declaration: IrClass, data: Data) {
if (!data.isLocal) {
@@ -104,7 +102,7 @@
declaration.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA -> {
inventName(null, data).also { name ->
// We save the name of the lambda to reuse it in the reference to it (produced by the closure conversion) later.
- localFunctionNames[(declaration as IrFunction).symbol] = name
+ localFunctionNames[declaration as IrFunction] = name
}
}
declaration is IrFunction && declaration.parent !is IrClass -> {
@@ -129,7 +127,7 @@
}
override fun visitFunctionReference(expression: IrFunctionReference, data: Data) {
- val internalName = localFunctionNames[expression.symbol] ?: inventName(null, data)
+ val internalName = localFunctionNames[expression.target] ?: inventName(null, data)
context.putLocalClassInfo(expression, JvmBackendContext.LocalClassInfo(internalName))
expression.acceptChildren(this, data)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmBuiltinOptimizationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmBuiltinOptimizationLowering.kt
index 0e0d74f..ff06443 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmBuiltinOptimizationLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmBuiltinOptimizationLowering.kt
@@ -38,7 +38,7 @@
companion object {
fun isNegation(expression: IrExpression, context: JvmBackendContext): Boolean =
expression is IrCall &&
- context.state.intrinsics.getIntrinsic(expression.symbol.descriptor) is Not
+ context.state.intrinsics.getIntrinsic(expression.target.descriptor) is Not
}
private fun hasNoSideEffectsForNullCompare(expression: IrExpression): Boolean {
@@ -54,11 +54,11 @@
private fun getOperandsIfCallToEqeqOrEquals(call: IrCall): Pair<IrExpression, IrExpression>? {
- if (call.symbol == context.irBuiltIns.eqeqSymbol) {
+ if (call.target == context.irBuiltIns.eqeqSymbol.owner) {
val left = call.getValueArgument(0)!!
val right = call.getValueArgument(1)!!
return left to right
- } else if (call.symbol.owner.isObjectEquals) {
+ } else if (call.target.isObjectEquals) {
val left = call.dispatchReceiver!!
val right = call.getValueArgument(0)!!
return left to right
@@ -134,7 +134,7 @@
expression.startOffset,
expression.endOffset,
context.irBuiltIns.booleanType,
- context.irBuiltIns.andandSymbol
+ context.irBuiltIns.andandSymbol.owner
).apply {
putValueArgument(0, expression.branches[0].condition)
putValueArgument(1, expression.branches[0].result)
@@ -155,7 +155,7 @@
expression.startOffset,
expression.endOffset,
context.irBuiltIns.booleanType,
- context.irBuiltIns.ororSymbol
+ context.irBuiltIns.ororSymbol.owner
).apply {
putValueArgument(0, expression.branches[0].condition)
putValueArgument(1, expression.branches[1].result)
@@ -248,7 +248,7 @@
if (first is IrVariable
&& first.origin == IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
&& second is IrGetValue
- && first.symbol == second.symbol) {
+ && first == second.target) {
statements.clear()
first.initializer?.let { statements.add(it) }
}
@@ -270,7 +270,7 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
// Replace IrGetValue of an immutable temporary variable with a constant
// initializer with the constant initializer.
- val variable = expression.symbol.owner
+ val variable = expression.target
return if (isImmutableTemporaryVariableWithConstantValue(variable))
(variable as IrVariable).initializer!!
else
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmDefaultConstructorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmDefaultConstructorLowering.kt
index 957bf7d..3f80844 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmDefaultConstructorLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmDefaultConstructorLowering.kt
@@ -42,7 +42,7 @@
return
irClass.addConstructor().apply {
- val irBuilder = context.createIrBuilder(this.symbol, startOffset, endOffset)
+ val irBuilder = context.createIrBuilder(this, startOffset, endOffset)
body = irBuilder.irBlockBody {
+irDelegatingConstructorCall(primaryConstructor).apply {
passTypeArgumentsFrom(irClass)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt
index 37052c3..9a75b80 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt
@@ -27,8 +27,6 @@
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrSetVariableImpl
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.types.isNullable
@@ -54,7 +52,7 @@
*/
private class JvmInlineClassLowering(private val context: JvmBackendContext) : FileLoweringPass, IrElementTransformerVoidWithContext() {
private val manager = MemoizedInlineClassReplacements()
- private val valueMap = mutableMapOf<IrValueSymbol, IrValueDeclaration>()
+ private val valueMap = mutableMapOf<IrValueDeclaration, IrValueDeclaration>()
override fun lower(irFile: IrFile) {
irFile.transformChildrenVoid()
@@ -114,15 +112,15 @@
worker.body = function.body?.transform(this, null)?.patchDeclarationParents(worker)
// Don't create a wrapper for functions which are only used in an unboxed context
- if (function.overriddenSymbols.isEmpty() || worker.dispatchReceiverParameter != null)
+ if (function.overridden.isEmpty() || worker.dispatchReceiverParameter != null)
return listOf(worker)
// Replace the function body with a wrapper
- context.createIrBuilder(function.symbol).run {
+ context.createIrBuilder(function).run {
val call = irCall(worker).apply {
passTypeArgumentsFrom(function)
for (parameter in function.explicitParameters) {
- val newParameter = replacement.valueParameterMap[parameter.symbol] ?: continue
+ val newParameter = replacement.valueParameterMap[parameter] ?: continue
putArgument(newParameter, irGet(parameter))
}
}
@@ -140,11 +138,11 @@
valueMap.putAll(replacement.valueParameterMap)
worker.valueParameters.forEach { it.transformChildrenVoid() }
- worker.body = context.createIrBuilder(worker.symbol).irBlockBody(worker) {
+ worker.body = context.createIrBuilder(worker).irBlockBody(worker) {
val thisVar = irTemporaryVarDeclaration(
worker.returnType, nameHint = "\$this", isMutable = false
)
- valueMap[constructor.constructedClass.thisReceiver!!.symbol] = thisVar
+ valueMap[constructor.constructedClass.thisReceiver!!] = thisVar
constructor.body?.statements?.forEach { statement ->
+statement
@@ -160,7 +158,7 @@
// This is safe, since the delegating constructor call precedes all references to "this".
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
expression.transformChildrenVoid()
- return irSetVar(thisVar.symbol, expression)
+ return irSetVar(thisVar, expression)
}
// A constructor body has type unit and may contain explicit return statements.
@@ -177,7 +175,7 @@
// }
override fun visitReturn(expression: IrReturn): IrExpression {
expression.transformChildrenVoid()
- if (expression.returnTargetSymbol != constructor.symbol)
+ if (expression.irReturnTarget != constructor)
return expression
return irReturn(irBlock(expression.startOffset, expression.endOffset) {
@@ -210,7 +208,7 @@
copyTypeArgumentsFrom(original)
for ((parameter, argument) in typedArgumentList(originalFunction, original)) {
if (argument == null) continue
- val newParameter = replacement.valueParameterMap[parameter.symbol] ?: continue
+ val newParameter = replacement.valueParameterMap[parameter] ?: continue
putArgument(
replacement.function,
newParameter,
@@ -220,25 +218,25 @@
}
override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
- val replacement = manager.getReplacementFunction(expression.symbol.owner)
+ val replacement = manager.getReplacementFunction(expression.target)
?: return super.visitFunctionReference(expression)
val function = replacement.function
return IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset, expression.type,
- function.symbol, function.descriptor,
+ function, function.descriptor,
function.typeParameters.size, function.valueParameters.size,
expression.origin
).apply {
- buildReplacement(expression.symbol.owner, expression, replacement)
+ buildReplacement(expression.target, expression, replacement)
}.copyAttributes(expression)
}
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
- val function = expression.symbol.owner
+ val function = expression.target
val replacement = manager.getReplacementFunction(function)
?: return super.visitFunctionAccess(expression)
- return context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset)
+ return context.createIrBuilder(currentScope!!.scope.irScopeOwner, expression.startOffset, expression.endOffset)
.irCall(replacement.function).apply {
buildReplacement(function, expression, replacement)
}
@@ -276,7 +274,7 @@
val equalsMethod = if (rightIsUnboxed) {
manager.getSpecializedEqualsMethod(klass, context.irBuiltIns)
} else {
- val equals = klass.functions.single { it.name.asString() == "equals" && it.overriddenSymbols.isNotEmpty() }
+ val equals = klass.functions.single { it.name.asString() == "equals" && it.overridden.isNotEmpty() }
manager.getReplacementFunction(equals)!!.function
}
@@ -290,8 +288,8 @@
val rightNullCheck = rightIsUnboxed && right.type.isNullable() // equals-impl has a nullable second argument
return if (leftNullCheck || rightNullCheck) {
irBlock {
- val leftVal = if (left is IrGetValue) left.symbol.owner else irTemporary(left)
- val rightVal = if (right is IrGetValue) right.symbol.owner else irTemporary(right)
+ val leftVal = if (left is IrGetValue) left.target else irTemporary(left)
+ val rightVal = if (right is IrGetValue) right.target else irTemporary(right)
val equalsCall = equals(
if (leftNullCheck) irImplicitCast(irGet(leftVal), left.type.makeNotNull()) else irGet(leftVal),
@@ -319,14 +317,14 @@
when {
// Getting the underlying field of an inline class merely changes the IR type,
// since the underlying representations are the same.
- expression.symbol.owner.isInlineClassFieldGetter -> {
+ expression.target.isInlineClassFieldGetter -> {
val arg = expression.dispatchReceiver!!.transform(this, null)
- coerceInlineClasses(arg, expression.symbol.owner.dispatchReceiverParameter!!.type, expression.type)
+ coerceInlineClasses(arg, expression.target.dispatchReceiverParameter!!.type, expression.type)
}
// Specialize calls to equals when the left argument is a value of inline class type.
expression.isSpecializedInlineClassEqEq -> {
expression.transformChildrenVoid()
- context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset)
+ context.createIrBuilder(currentScope!!.scope.irScopeOwner, expression.startOffset, expression.endOffset)
.specializeEqualsCall(expression.getValueArgument(0)!!, expression.getValueArgument(1)!!)
?: expression
}
@@ -338,7 +336,7 @@
get() {
// Note that reference equality (x === y) is not allowed on values of inline class type,
// so it is enough to check for eqeq.
- if (symbol != context.irBuiltIns.eqeqSymbol)
+ if (target != context.irBuiltIns.eqeqSymbol.owner)
return false
val leftClass = getValueArgument(0)?.type?.classOrNull?.owner?.takeIf { it.isInline }
@@ -350,7 +348,7 @@
}
override fun visitGetField(expression: IrGetField): IrExpression {
- val field = expression.symbol.owner
+ val field = expression.target
val parent = field.parent
if (parent is IrClass && parent.isInline && field.name == parent.inlineClassFieldName) {
val receiver = expression.receiver!!.transform(this, null)
@@ -360,9 +358,9 @@
}
override fun visitReturn(expression: IrReturn): IrExpression {
- expression.returnTargetSymbol.owner.safeAs<IrFunction>()?.let { target ->
+ expression.irReturnTarget.safeAs<IrFunction>()?.let { target ->
manager.getReplacementFunction(target)?.let {
- return context.createIrBuilder(it.function.symbol, expression.startOffset, expression.endOffset).irReturn(
+ return context.createIrBuilder(it.function, expression.startOffset, expression.endOffset).irReturn(
expression.value.transform(this, null)
)
}
@@ -390,20 +388,20 @@
}
override fun visitGetValue(expression: IrGetValue): IrExpression {
- valueMap[expression.symbol]?.let {
+ valueMap[expression.target]?.let {
return IrGetValueImpl(
expression.startOffset, expression.endOffset,
- it.type, it.symbol, expression.origin
+ it.type, it, expression.origin
)
}
return super.visitGetValue(expression)
}
override fun visitSetVariable(expression: IrSetVariable): IrExpression {
- valueMap[expression.symbol]?.let {
+ valueMap[expression.target]?.let {
return IrSetVariableImpl(
expression.startOffset, expression.endOffset,
- it.type, it.symbol as IrVariableSymbol, expression.origin
+ it.type, it as IrVariable, expression.origin
).apply {
value = expression.value.transform(this@JvmInlineClassLowering, null)
}
@@ -420,7 +418,7 @@
returnType = irConstructor.returnType
}.apply {
copyParameterDeclarationsFrom(irConstructor)
- body = context.createIrBuilder(this.symbol).irBlockBody(this) {
+ body = context.createIrBuilder(this).irBlockBody(this) {
+irDelegatingConstructorCall(context.irBuiltIns.anyClass.owner.constructors.single())
+irSetField(
irGet(irClass.thisReceiver!!),
@@ -433,7 +431,7 @@
// Add a static bridge method to the primary constructor.
// This is a placeholder for null-checks and default arguments.
val function = manager.getReplacementFunction(irConstructor)!!.function
- with(context.createIrBuilder(function.symbol)) {
+ with(context.createIrBuilder(function)) {
val argument = function.valueParameters[0]
function.body = irExprBody(
coerceInlineClasses(irGet(argument), argument.type, function.returnType)
@@ -444,9 +442,9 @@
private fun buildBoxFunction(irClass: IrClass) {
val function = manager.getBoxFunction(irClass)
- with(context.createIrBuilder(function.symbol)) {
+ with(context.createIrBuilder(function)) {
function.body = irExprBody(
- irCall(irClass.primaryConstructor!!.symbol).apply {
+ irCall(irClass.primaryConstructor!!).apply {
passTypeArgumentsFrom(function)
putValueArgument(0, irGet(function.valueParameters[0]))
}
@@ -457,7 +455,7 @@
private fun buildUnboxFunction(irClass: IrClass) {
val function = manager.getUnboxFunction(irClass)
- val builder = context.createIrBuilder(function.symbol)
+ val builder = context.createIrBuilder(function)
val field = getInlineClassBackingField(irClass)
function.body = builder.irBlockBody {
@@ -474,7 +472,7 @@
val right = function.valueParameters[1]
val type = left.type.unboxInlineClass()
- function.body = context.createIrBuilder(irClass.symbol).run {
+ function.body = context.createIrBuilder(irClass).run {
irExprBody(
irEquals(
coerceInlineClasses(irGet(left), left.type, type),
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt
index 3df3854..874b044 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt
@@ -56,19 +56,19 @@
val wrapperIrFunction = generateWrapperHeader(target, numDefaultParametersToExpect)
val call = if (target is IrConstructor)
- IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol, target.descriptor)
+ IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target, target.descriptor)
else
- IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol)
+ IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target)
call.dispatchReceiver = wrapperIrFunction.dispatchReceiverParameter?.let { dispatchReceiver ->
IrGetValueImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- dispatchReceiver.symbol
+ dispatchReceiver
)
}
call.extensionReceiver = wrapperIrFunction.extensionReceiverParameter?.let { extensionReceiver ->
IrGetValueImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- extensionReceiver.symbol
+ extensionReceiver
)
}
@@ -82,7 +82,7 @@
i,
IrGetValueImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- wrapperIrFunction.valueParameters[parametersCopied++].symbol
+ wrapperIrFunction.valueParameters[parametersCopied++]
)
)
} else {
@@ -93,7 +93,7 @@
i,
IrGetValueImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- wrapperIrFunction.valueParameters[parametersCopied++].symbol
+ wrapperIrFunction.valueParameters[parametersCopied++]
)
)
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt
index 9c4ab89..d2ba1f7 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt
@@ -126,8 +126,7 @@
private fun createProxyBody(target: IrFunction, proxy: IrFunction, companion: IrClass): IrBody {
val companionInstanceField = context.declarationFactory.getFieldForObjectInstance(companion)
- val companionInstanceFieldSymbol = companionInstanceField.symbol
- val call = IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol)
+ val call = IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target)
call.passTypeArgumentsFrom(proxy)
@@ -135,7 +134,7 @@
call.dispatchReceiver = IrGetFieldImpl(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
- companionInstanceFieldSymbol,
+ companionInstanceField,
companion.defaultType
)
}
@@ -143,7 +142,7 @@
call.extensionReceiver = IrGetValueImpl(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
- extensionReceiver.symbol
+ extensionReceiver
)
}
proxy.valueParameters.mapIndexed { i, valueParameter ->
@@ -152,7 +151,7 @@
IrGetValueImpl(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
- valueParameter.symbol
+ valueParameter
)
)
}
@@ -191,8 +190,8 @@
val context: JvmBackendContext
) : IrElementTransformerVoid() {
override fun visitCall(expression: IrCall): IrExpression {
- if (expression.symbol.owner.isJvmStaticInSingleton() && expression.dispatchReceiver != null) {
- return context.createIrBuilder(expression.symbol, expression.startOffset, expression.endOffset).irBlock(expression) {
+ if (expression.target.isJvmStaticInSingleton() && expression.dispatchReceiver != null) {
+ return context.createIrBuilder(expression.target, expression.startOffset, expression.endOffset).irBlock(expression) {
// OldReceiver has to be evaluated for its side effects.
val oldReceiver = super.visitExpression(expression.dispatchReceiver!!)
// `coerceToUnit()` is private in InsertImplicitCasts, have to reproduce it here
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MappedEnumWhenLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MappedEnumWhenLowering.kt
index 57eac2a..d1d49c1 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MappedEnumWhenLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MappedEnumWhenLowering.kt
@@ -23,7 +23,6 @@
import org.jetbrains.kotlin.ir.expressions.impl.IrGetEnumValueImpl
import org.jetbrains.kotlin.ir.types.getClass
import org.jetbrains.kotlin.ir.util.*
-import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.util.OperatorNameConventions
@@ -60,9 +59,9 @@
//
private class MappedEnumWhenLowering(context: CommonBackendContext) : EnumWhenLowering(context) {
private val intArray = context.irBuiltIns.primitiveArrayForType.getValue(context.irBuiltIns.intType)
- private val intArrayConstructor = intArray.constructors.single { it.owner.valueParameters.size == 1 }
- private val intArrayGet = intArray.functions.single { it.owner.name == OperatorNameConventions.GET }
- private val intArraySet = intArray.functions.single { it.owner.name == OperatorNameConventions.SET }
+ private val intArrayConstructor = intArray.constructors.single { it.valueParameters.size == 1 }
+ private val intArrayGet = intArray.functions.single { it.name == OperatorNameConventions.GET }
+ private val intArraySet = intArray.functions.single { it.name == OperatorNameConventions.SET }
private val refArraySize = context.irBuiltIns.arrayClass.owner.properties.single { it.name.toString() == "size" }.getter!!
// To avoid visibility-related issues, classes containing the mappings are direct children
@@ -110,13 +109,13 @@
for ((enum, mappingAndField) in state!!.mappings) {
val (mapping, field) = mappingAndField
- val builder = context.createIrBuilder(state!!.mappingsClass.symbol)
+ val builder = context.createIrBuilder(state!!.mappingsClass)
val enumValues = enum.functions.single { it.name.toString() == "values" }
field.initializer = builder.irExprBody(builder.irBlock {
val enumSize = irCall(refArraySize).apply { dispatchReceiver = irCall(enumValues) }
val result = irTemporary(irCall(intArrayConstructor).apply { putValueArgument(0, enumSize) })
for ((entry, index) in mapping) {
- val runtimeEntry = IrGetEnumValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, enum.defaultType, entry.symbol)
+ val runtimeEntry = IrGetEnumValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, enum.defaultType, entry)
+irCall(intArraySet).apply {
dispatchReceiver = irGet(result)
putValueArgument(0, super.mapRuntimeEnumEntry(builder, runtimeEntry)) // <entry>.ordinal()
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt
index 98b2751..a58adde 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MoveCompanionObjectFieldsLowering.kt
@@ -23,7 +23,6 @@
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
@@ -42,7 +41,7 @@
private class MoveOrCopyCompanionObjectFieldsLowering(val context: CommonBackendContext) : ClassLoweringPass {
override fun lower(irClass: IrClass) {
- val fieldReplacementMap = mutableMapOf<IrFieldSymbol, IrFieldSymbol>()
+ val fieldReplacementMap = mutableMapOf<IrField, IrField>()
if (irClass.isObject && !irClass.isCompanion && irClass.visibility != Visibilities.LOCAL) {
handleObject(irClass, fieldReplacementMap)
} else {
@@ -53,7 +52,7 @@
irClass.replaceFieldReferences(fieldReplacementMap)
}
- private fun handleObject(irObject: IrClass, fieldReplacementMap: MutableMap<IrFieldSymbol, IrFieldSymbol>) {
+ private fun handleObject(irObject: IrClass, fieldReplacementMap: MutableMap<IrField, IrField>) {
irObject.declarations.replaceAll {
when (it) {
is IrProperty -> {
@@ -67,7 +66,7 @@
}
}
- private fun handleClass(irClass: IrClass, fieldReplacementMap: MutableMap<IrFieldSymbol, IrFieldSymbol>) {
+ private fun handleClass(irClass: IrClass, fieldReplacementMap: MutableMap<IrField, IrField>) {
val companion = irClass.declarations.find {
it is IrClass && it.isCompanion
} as IrClass? ?: return
@@ -114,7 +113,7 @@
irProperty: IrProperty,
propertyParent: IrClass,
fieldParent: IrClass,
- fieldReplacementMap: MutableMap<IrFieldSymbol, IrFieldSymbol>? = null
+ fieldReplacementMap: MutableMap<IrField, IrField>? = null
): IrField? {
if (irProperty.origin == IrDeclarationOrigin.FAKE_OVERRIDE) return null
val oldField = irProperty.backingField ?: return null
@@ -123,7 +122,7 @@
fieldReplacementMap?.run {
irProperty.backingField = newField
newField.correspondingPropertySymbol = irProperty.symbol
- put(oldField.symbol, newField.symbol)
+ put(oldField, newField)
}
return newField
@@ -133,7 +132,7 @@
irProperty: IrProperty,
propertyParent: IrClass,
fieldParent: IrClass,
- fieldReplacementMap: MutableMap<IrFieldSymbol, IrFieldSymbol>? = null
+ fieldReplacementMap: MutableMap<IrField, IrField>? = null
): IrField? = moveOrCopyPropertyFieldToStaticParent(irProperty, propertyParent, fieldParent, fieldReplacementMap)
private fun copyPropertyFieldToStaticParent(
@@ -149,7 +148,7 @@
): IrAnonymousInitializer =
with(oldInitializer) {
IrAnonymousInitializerImpl(
- startOffset, endOffset, origin, IrAnonymousInitializerSymbolImpl(newParent.symbol),
+ startOffset, endOffset, origin, IrAnonymousInitializerSymbolImpl(newParent),
isStatic = true
).apply {
parent = newParent
@@ -184,18 +183,18 @@
}
override fun visitGetValue(expression: IrGetValue): IrExpression {
- if (expression.symbol.owner == oldParent.thisReceiver) {
+ if (expression.target == oldParent.thisReceiver) {
return IrGetFieldImpl(
expression.startOffset, expression.endOffset,
- objectInstanceField.symbol,
+ objectInstanceField,
expression.type
)
}
- variableMap[expression.symbol.owner]?.let { newVariable ->
+ variableMap[expression.target]?.let { newVariable ->
return IrGetValueImpl(
expression.startOffset, expression.endOffset,
expression.type,
- newVariable.symbol,
+ newVariable,
expression.origin
)
}
@@ -231,33 +230,33 @@
}
}
-private fun IrElement.replaceFieldReferences(replacementMap: Map<IrFieldSymbol, IrFieldSymbol>) {
+private fun IrElement.replaceFieldReferences(replacementMap: Map<IrField, IrField>) {
transformChildrenVoid(FieldReplacer(replacementMap))
}
-private class FieldReplacer(val replacementMap: Map<IrFieldSymbol, IrFieldSymbol>) : IrElementTransformerVoid() {
+private class FieldReplacer(val replacementMap: Map<IrField, IrField>) : IrElementTransformerVoid() {
override fun visitGetField(expression: IrGetField): IrExpression =
- replacementMap[expression.symbol]?.let { newSymbol ->
+ replacementMap[expression.target]?.let { newSymbol ->
IrGetFieldImpl(
expression.startOffset, expression.endOffset,
newSymbol,
expression.type,
/* receiver = */ null,
expression.origin,
- expression.superQualifierSymbol
+ expression.irSuperQualifier
)
} ?: super.visitGetField(expression)
override fun visitSetField(expression: IrSetField): IrExpression =
- replacementMap[expression.symbol]?.let { _ ->
+ replacementMap[expression.target]?.let { _ ->
IrSetFieldImpl(
expression.startOffset, expression.endOffset,
- replacementMap.getValue(expression.symbol),
+ replacementMap.getValue(expression.target),
/* receiver = */ null,
visitExpression(expression.value),
expression.type,
expression.origin,
- expression.superQualifierSymbol
+ expression.irSuperQualifier
)
} ?: super.visitSetField(expression)
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ObjectClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ObjectClassLowering.kt
index 5ab87c4..f5d3d52 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ObjectClassLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ObjectClassLowering.kt
@@ -71,7 +71,7 @@
).apply {
privateFieldDescriptor.bind(this)
parent = irClass
- with(context.createIrBuilder(symbol)) {
+ with(context.createIrBuilder(this)) {
initializer = irExprBody(
irCall(constructor)
)
@@ -79,12 +79,12 @@
pendingTransformations.add { parentAsClass.declarations.add(this) }
}
- with(context.createIrBuilder(publicInstanceField.symbol)) {
+ with(context.createIrBuilder(publicInstanceField)) {
publicInstanceField.initializer = irExprBody(irGetField(null, privateField))
}
} else {
- with(context.createIrBuilder(publicInstanceField.symbol)) {
- publicInstanceField.initializer = irExprBody(irCall(constructor.symbol))
+ with(context.createIrBuilder(publicInstanceField)) {
+ publicInstanceField.initializer = irExprBody(irCall(constructor))
}
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertiesToFieldsLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertiesToFieldsLowering.kt
index 71ae531..40b5df9 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertiesToFieldsLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertiesToFieldsLowering.kt
@@ -46,7 +46,7 @@
}
override fun visitCall(expression: IrCall): IrExpression {
- val simpleFunction = (expression.symbol.owner as? IrSimpleFunction) ?: return super.visitCall(expression)
+ val simpleFunction = (expression.target as? IrSimpleFunction) ?: return super.visitCall(expression)
val property = simpleFunction.correspondingPropertySymbol?.owner ?: return super.visitCall(expression)
if (shouldSubstituteAccessorWithField(property, simpleFunction)) {
@@ -79,12 +79,12 @@
val setExpr = IrSetFieldImpl(
expression.startOffset,
expression.endOffset,
- backingField.symbol,
+ backingField,
receiver,
expression.getValueArgument(expression.valueArgumentsCount - 1)!!.transform(this, null),
expression.type,
expression.origin,
- expression.superQualifierSymbol
+ expression.irSuperQualifier
)
return buildSubstitution(backingField.isStatic, setExpr, receiver)
}
@@ -95,11 +95,11 @@
val getExpr = IrGetFieldImpl(
expression.startOffset,
expression.endOffset,
- backingField.symbol,
+ backingField,
expression.type,
receiver,
expression.origin,
- expression.superQualifierSymbol
+ expression.irSuperQualifier
)
return buildSubstitution(backingField.isStatic, getExpr, receiver)
}
@@ -107,7 +107,7 @@
private fun buildSubstitution(needBlock: Boolean, setOrGetExpr: IrFieldAccessExpression, receiver: IrExpression?): IrExpression {
if (receiver != null && needBlock) {
// Evaluate `dispatchReceiver` for the sake of its side effects, then return `setOrGetExpr`.
- return context.createIrBuilder(setOrGetExpr.symbol, setOrGetExpr.startOffset, setOrGetExpr.endOffset).irBlock(setOrGetExpr) {
+ return context.createIrBuilder(setOrGetExpr.target, setOrGetExpr.startOffset, setOrGetExpr.endOffset).irBlock(setOrGetExpr) {
// `coerceToUnit()` is private in InsertImplicitCasts, have to reproduce it here
val receiverVoid = IrTypeOperatorCallImpl(
receiver.startOffset, receiver.endOffset,
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt
index 6942a6e..b1cd920 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt
@@ -24,7 +24,6 @@
import org.jetbrains.kotlin.ir.builders.declarations.buildField
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
-import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.types.createType
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
@@ -44,16 +43,16 @@
internal class PropertyReferenceLowering(val context: JvmBackendContext) : ClassLoweringPass {
// Reflection metadata for local properties is serialized under the signature "<v#$N>" attached to the containing class.
// This maps properties to values of N.
- private val localPropertyIndices = mutableMapOf<IrSymbol, Int>()
+ private val localPropertyIndices = mutableMapOf<IrSymbolOwner, Int>()
// TODO: join IrLocalDelegatedPropertyReference and IrPropertyReference via the class hierarchy?
- private val IrMemberAccessExpression.getter: IrSimpleFunctionSymbol?
+ private val IrMemberAccessExpression.getter: IrSimpleFunction?
get() = (this as? IrPropertyReference)?.getter ?: (this as? IrLocalDelegatedPropertyReference)?.getter
- private val IrMemberAccessExpression.setter: IrSimpleFunctionSymbol?
+ private val IrMemberAccessExpression.setter: IrSimpleFunction?
get() = (this as? IrPropertyReference)?.setter ?: (this as? IrLocalDelegatedPropertyReference)?.setter
- private val IrMemberAccessExpression.field: IrFieldSymbol?
+ private val IrMemberAccessExpression.field: IrField?
get() = (this as? IrPropertyReference)?.field
private val IrSimpleFunction.signature: String
@@ -67,7 +66,7 @@
private val IrMemberAccessExpression.signature: String
get() = getter?.let { getter ->
localPropertyIndices[getter]?.let { "<v#$it>" }
- } ?: getter?.owner?.signature ?: field!!.owner.signature
+ } ?: getter?.signature ?: field!!.signature
private val arrayItemGetter =
context.ir.symbols.array.owner.functions.single { it.name.asString() == "get" }
@@ -84,7 +83,7 @@
private val IrMemberAccessExpression.propertyContainer: IrDeclarationParent
get() {
- var current: IrDeclaration = getter?.owner ?: field?.owner ?: error("Property without getter or field: ${dump()}")
+ var current: IrDeclaration = getter ?: field ?: error("Property without getter or field: ${dump()}")
while (current.parent is IrFunction)
current = current.parent as IrFunction // Local delegated property.
return current.parent
@@ -103,7 +102,7 @@
visibility = method.visibility
origin = this@addOverride.origin
}.apply {
- overriddenSymbols.add(method.symbol)
+ overridden.add(method)
dispatchReceiverParameter = thisReceiver!!.copyTo(this)
for (parameter in method.valueParameters)
valueParameters.add(parameter.copyTo(this))
@@ -113,19 +112,19 @@
}
private class PropertyReferenceKind(
- val interfaceSymbol: IrClassSymbol,
- val reflectedSymbol: IrClassSymbol,
+ val interfaceClass: IrClass,
+ val reflected: IrClass,
val wrapper: IrFunction
)
private fun propertyReferenceKind(mutable: Boolean, i: Int) = PropertyReferenceKind(
context.ir.symbols.getPropertyReferenceClass(mutable, i, false),
context.ir.symbols.getPropertyReferenceClass(mutable, i, true),
- context.ir.symbols.reflection.owner.functions.single { it.name.asString() == (if (mutable) "mutableProperty$i" else "property$i") }
+ context.ir.symbols.reflection.functions.single { it.name.asString() == (if (mutable) "mutableProperty$i" else "property$i") }
)
private fun propertyReferenceKindFor(expression: IrMemberAccessExpression): PropertyReferenceKind =
- expression.getter?.owner?.let {
+ expression.getter?.let {
val boundReceivers = listOfNotNull(expression.dispatchReceiver, expression.extensionReceiver).size
val needReceivers = listOfNotNull(it.dispatchReceiverParameter, it.extensionReceiverParameter).size
// PropertyReference1 will swap the receivers if bound with the extension one, and PropertyReference0
@@ -133,14 +132,14 @@
if (boundReceivers == 2 || (expression.extensionReceiver != null && needReceivers == 2))
TODO("property reference with 2 receivers")
propertyReferenceKind(expression.setter != null, needReceivers - boundReceivers)
- } ?: expression.field?.owner?.let {
+ } ?: expression.field?.let {
propertyReferenceKind(!it.isFinal, if (it.isStatic || expression.dispatchReceiver != null) 0 else 1)
} ?: throw AssertionError("property has no getter and no field: ${expression.dump()}")
private data class PropertyInstance(val initializer: IrExpression, val index: Int)
override fun lower(irClass: IrClass) {
- val kProperties = mutableMapOf<IrSymbol, PropertyInstance>()
+ val kProperties = mutableMapOf<IrSymbolOwner, PropertyInstance>()
val kPropertiesField = buildField {
name = Name.identifier(JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME)
type = kPropertiesFieldType
@@ -153,7 +152,7 @@
irClass.transformChildrenVoid(object : IrElementTransformerVoidWithContext() {
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrStatement {
- localPropertyIndices[declaration.getter.symbol] = localPropertiesInClass++
+ localPropertyIndices[declaration.getter] = localPropertiesInClass++
return super.visitLocalDelegatedProperty(declaration)
}
@@ -169,8 +168,8 @@
// For delegated properties, the getter and setter contain a reference each as the second argument to getValue
// and setValue. Since it's highly unlikely that anyone will call get/set on these, optimize for space.
- return context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset).run {
- val (_, index) = kProperties.getOrPut(expression.symbol) {
+ return context.createIrBuilder(currentScope!!.scope.irScopeOwner, expression.startOffset, expression.endOffset).run {
+ val (_, index) = kProperties.getOrPut(expression.target) {
PropertyInstance(createReflectedKProperty(expression), kProperties.size)
}
irCall(arrayItemGetter).apply {
@@ -185,9 +184,9 @@
// Example: `C::property` -> `Reflection.property1(PropertyReference1Impl(C::class, "property", "getProperty()LType;"))`.
private fun createReflectedKProperty(expression: IrCallableReference): IrExpression {
val referenceKind = propertyReferenceKindFor(expression)
- return context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset).run {
+ return context.createIrBuilder(currentScope!!.scope.irScopeOwner, expression.startOffset, expression.endOffset).run {
irCall(referenceKind.wrapper).apply {
- putValueArgument(0, irCall(referenceKind.reflectedSymbol.constructors.single()).apply {
+ putValueArgument(0, irCall(referenceKind.reflected.constructors.single()).apply {
putValueArgument(0, buildReflectedContainerReference(expression))
putValueArgument(1, irString(expression.descriptor.name.asString()))
putValueArgument(2, irString(expression.signature))
@@ -212,7 +211,7 @@
//
private fun createSpecializedKProperty(expression: IrCallableReference): IrExpression {
val referenceClass = createKPropertySubclass(expression)
- return context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset)
+ return context.createIrBuilder(currentScope!!.scope.irScopeOwner, expression.startOffset, expression.endOffset)
.irBlock {
+referenceClass
+irCall(referenceClass.constructors.single()).apply {
@@ -224,10 +223,10 @@
}
private fun createKPropertySubclass(expression: IrCallableReference): IrClass {
- val superClass = propertyReferenceKindFor(expression).interfaceSymbol.owner
+ val superClass = propertyReferenceKindFor(expression).interfaceClass
val referenceClass = buildClass {
setSourceRange(expression)
- name = Name.special("<property reference to ${(expression.symbol.owner as IrDeclarationWithName).fqNameWhenAvailable}>")
+ name = Name.special("<property reference to ${(expression.target as IrDeclarationWithName).fqNameWhenAvailable}>")
origin = JvmLoweredDeclarationOrigin.GENERATED_PROPERTY_REFERENCE
visibility = Visibilities.LOCAL
}.apply {
@@ -251,18 +250,18 @@
referenceClass.addOverride(getOwner) { buildReflectedContainerReference(expression) }
referenceClass.addOverride(getSignature) { irString(expression.signature) }
- val field = expression.field?.owner
+ val field = expression.field
if (field == null) {
fun IrBuilderWithScope.setCallArguments(call: IrCall, arguments: List<IrValueParameter>) {
var index = 1
call.copyTypeArgumentsFrom(expression)
- call.dispatchReceiver = call.symbol.owner.dispatchReceiverParameter?.let {
+ call.dispatchReceiver = call.target.dispatchReceiverParameter?.let {
if (expression.dispatchReceiver != null)
irImplicitCast(irGetField(irGet(arguments[0]), receiverField), it.type)
else
irImplicitCast(irGet(arguments[index++]), it.type)
}
- call.extensionReceiver = call.symbol.owner.extensionReceiverParameter?.let {
+ call.extensionReceiver = call.target.extensionReceiverParameter?.let {
if (expression.extensionReceiver != null)
irImplicitCast(irGetField(irGet(arguments[0]), receiverField), it.type)
else
@@ -270,17 +269,17 @@
}
}
- expression.getter?.owner?.let { getter ->
+ expression.getter?.let { getter ->
referenceClass.addOverride(get!!) { arguments ->
- irGet(getter.returnType, null, getter.symbol).apply {
+ irGet(getter.returnType, null, getter).apply {
setCallArguments(this, arguments)
}
}
}
- expression.setter?.owner?.let { setter ->
+ expression.setter?.let { setter ->
referenceClass.addOverride(set!!) { arguments ->
- irSet(setter.returnType, null, setter.symbol, irGet(arguments.last())).apply {
+ irSet(setter.returnType, null, setter, irGet(arguments.last())).apply {
setCallArguments(this, arguments)
}
}
@@ -314,14 +313,14 @@
if (kProperties.isNotEmpty()) {
irClass.declarations.add(0, kPropertiesField.apply {
parent = irClass
- initializer = context.createJvmIrBuilder(irClass.symbol).run {
+ initializer = context.createJvmIrBuilder(irClass).run {
val initializers = kProperties.values.sortedBy { it.index }.map { it.initializer }
irExprBody(irArrayOf(kPropertiesFieldType, initializers))
}
})
context.localDelegatedProperties[irClass.attributeOwnerId as IrClass] =
- kProperties.keys.filterIsInstance<IrLocalDelegatedPropertySymbol>()
+ kProperties.keys.filterIsInstance<IrLocalDelegatedProperty>()
}
}
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDeclarationsThatWouldBeInlinedLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDeclarationsThatWouldBeInlinedLowering.kt
index e5fc95b..bb554c4 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDeclarationsThatWouldBeInlinedLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDeclarationsThatWouldBeInlinedLowering.kt
@@ -37,7 +37,7 @@
override fun visitFunctionReference(expression: IrFunctionReference) {
assert(expression.origin == IrStatementOrigin.LAMBDA || expression.origin == IrStatementOrigin.ANONYMOUS_FUNCTION)
- loweredLambdasToDelete.add(expression.symbol.owner)
+ loweredLambdasToDelete.add(expression.target)
expression.acceptChildrenVoid(this)
}
})
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RenameFieldsLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RenameFieldsLowering.kt
index 58bef2c..8e05e8e 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RenameFieldsLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/RenameFieldsLowering.kt
@@ -20,7 +20,6 @@
import org.jetbrains.kotlin.ir.expressions.IrSetField
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
@@ -74,7 +73,7 @@
val renamer = FieldRenamer(newNames)
irFile.transform(renamer, null)
- irFile.transform(FieldAccessTransformer(renamer.newSymbols), null)
+ irFile.transform(FieldAccessTransformer(renamer.newFields), null)
}
private val IrField.isJvmField: Boolean
@@ -94,7 +93,7 @@
}
private class FieldRenamer(private val newNames: Map<IrField, Name>) : IrElementTransformerVoid() {
- val newSymbols = mutableMapOf<IrField, IrFieldSymbol>()
+ val newFields = mutableMapOf<IrField, IrField>()
override fun visitField(declaration: IrField): IrStatement {
val newName = newNames[declaration] ?: return super.visitField(declaration)
@@ -112,31 +111,31 @@
?.patchDeclarationParents(it)
it.metadata = declaration.metadata
- newSymbols[declaration] = symbol
+ newFields[declaration] = it
}
}
}
-private class FieldAccessTransformer(private val oldToNew: Map<IrField, IrFieldSymbol>) : IrElementTransformerVoid() {
+private class FieldAccessTransformer(private val oldToNew: Map<IrField, IrField>) : IrElementTransformerVoid() {
override fun visitGetField(expression: IrGetField): IrExpression {
- val newSymbol = oldToNew[expression.symbol.owner] ?: return super.visitGetField(expression)
+ val newField = oldToNew[expression.target] ?: return super.visitGetField(expression)
return IrGetFieldImpl(
- expression.startOffset, expression.endOffset, newSymbol, expression.type,
+ expression.startOffset, expression.endOffset, newField, expression.type,
expression.receiver?.transform(this, null),
- expression.origin, expression.superQualifierSymbol
+ expression.origin, expression.irSuperQualifier
)
}
override fun visitSetField(expression: IrSetField): IrExpression {
- val newSymbol = oldToNew[expression.symbol.owner] ?: return super.visitSetField(expression)
+ val newField = oldToNew[expression.target] ?: return super.visitSetField(expression)
return IrSetFieldImpl(
- expression.startOffset, expression.endOffset, newSymbol,
+ expression.startOffset, expression.endOffset, newField,
expression.receiver?.transform(this, null),
expression.value.transform(this, null),
expression.type,
- expression.origin, expression.superQualifierSymbol
+ expression.origin, expression.irSuperQualifier
)
}
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt
index 8752e67..806a93c 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt
@@ -39,14 +39,14 @@
}
override fun visitCall(expression: IrCall): IrExpression {
- val callee = expression.symbol.owner
+ val callee = expression.target
if (callee !is IrSimpleFunction || callee.name != OperatorNameConventions.INVOKE) return super.visitCall(expression)
val parentClass = callee.parent as? IrClass ?: return super.visitCall(expression)
if (!parentClass.defaultType.isKFunction() && !parentClass.defaultType.isKSuspendFunction()) return super.visitCall(expression)
// The single overridden function of KFunction{n}.invoke must be Function{n}.invoke.
- val newCallee = callee.overriddenSymbols.single()
+ val newCallee = callee.overridden.single()
return expression.run {
IrCallImpl(startOffset, endOffset, type, newCallee).apply {
copyTypeArgumentsFrom(expression)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt
index 9c0da7b..7e167a7 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt
@@ -74,7 +74,7 @@
return super.visitTypeOperator(expression)
val superType = expression.typeOperand
val invokable = expression.argument.transform(this, null)
- context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol).apply {
+ context.createIrBuilder(currentScope!!.scope.irScopeOwner).apply {
// Do not generate a wrapper class for null, it has no invoke() anyway.
if (invokable.isNullConst())
return invokable
@@ -142,7 +142,7 @@
body = context.createIrBuilder(symbol).irBlockBody(startOffset, endOffset) {
+irDelegatingConstructorCall(context.irBuiltIns.anyClass.owner.constructors.single())
+irSetField(irGet(subclass.thisReceiver!!), field, irGet(parameter))
- +IrInstanceInitializerCallImpl(startOffset, endOffset, subclass.symbol, context.irBuiltIns.unitType)
+ +IrInstanceInitializerCallImpl(startOffset, endOffset, subclass, context.irBuiltIns.unitType)
}
}
@@ -153,7 +153,7 @@
visibility = superMethod.visibility
origin = subclass.origin
}.apply {
- overriddenSymbols += superMethod.symbol
+ overridden += superMethod
dispatchReceiverParameter = subclass.thisReceiver!!.copyTo(this)
superMethod.valueParameters.mapTo(valueParameters) { it.copyTo(this) }
val invokableClass = invokableType.classifierOrFail.owner as IrClass
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonReferencesLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonReferencesLowering.kt
index 0924e66..34d4112 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonReferencesLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingletonReferencesLowering.kt
@@ -36,14 +36,14 @@
}
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrExpression {
- constructingEnums.push(expression.symbol.owner.parent)
+ constructingEnums.push(expression.target.parent)
val call = super.visitEnumConstructorCall(expression)
constructingEnums.pop()
return call
}
override fun visitGetEnumValue(expression: IrGetEnumValue): IrExpression {
- val candidate = expression.symbol.owner.correspondingClass
+ val candidate = expression.target.correspondingClass
return if (candidate != null && isInScope(candidate) && !isVisitingSuperConstructor(candidate)) {
// Replace `SomeEnumClass.SomeEnumEntry` with `this`, if possible.
@@ -51,16 +51,16 @@
// SomeEnumEntry is a singleton, which is assigned (SETFIELD) to SomeEnumClass after the construction of the singleton is done.
// Therefore, during the construction of SomeEnumEntry, SomeEnumClass.SomeEnumEntry isn't available yet. All references to it
// must be replaced with `SomeEnumEntry.this`.
- IrGetValueImpl(expression.startOffset, expression.endOffset, expression.type, candidate.thisReceiver!!.symbol)
+ IrGetValueImpl(expression.startOffset, expression.endOffset, expression.type, candidate.thisReceiver!!)
} else {
- val entrySymbol = context.declarationFactory.getFieldForEnumEntry(expression.symbol.owner, expression.type)
- IrGetFieldImpl(expression.startOffset, expression.endOffset, entrySymbol.symbol, expression.type)
+ val entry = context.declarationFactory.getFieldForEnumEntry(expression.target, expression.type)
+ IrGetFieldImpl(expression.startOffset, expression.endOffset, entry, expression.type)
}
}
override fun visitGetObjectValue(expression: IrGetObjectValue): IrExpression {
- val instanceField = context.declarationFactory.getFieldForObjectInstance(expression.symbol.owner)
- return IrGetFieldImpl(expression.startOffset, expression.endOffset, instanceField.symbol, expression.type)
+ val instanceField = context.declarationFactory.getFieldForObjectInstance(expression.target)
+ return IrGetFieldImpl(expression.startOffset, expression.endOffset, instanceField, expression.type)
}
// `this` is generally available while the reference is within the lexical scope of the containing enum entry.
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/StaticDefaultFunctionLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/StaticDefaultFunctionLowering.kt
index 7ae0572..850b26b 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/StaticDefaultFunctionLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/StaticDefaultFunctionLowering.kt
@@ -73,10 +73,10 @@
override fun visitReturn(expression: IrReturn): IrExpression {
return super.visitReturn(
- if (context.staticDefaultStubs.containsKey(expression.returnTargetSymbol)) {
+ if (context.staticDefaultStubs.containsKey(expression.irReturnTarget)) {
with(expression) {
- val irFunction = context.staticDefaultStubs[expression.returnTargetSymbol]!!
- IrReturnImpl(startOffset, endOffset, expression.type, irFunction.symbol, expression.value)
+ val irFunction = context.staticDefaultStubs[expression.irReturnTarget]!!
+ IrReturnImpl(startOffset, endOffset, expression.type, irFunction, expression.value)
}
} else {
expression
@@ -93,7 +93,7 @@
}
override fun visitCall(expression: IrCall): IrExpression {
- val callee = expression.symbol.owner
+ val callee = expression.target
if (callee.origin !== IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER || callee.dispatchReceiverParameter == null) {
return super.visitCall(expression)
}
@@ -106,7 +106,7 @@
}
private fun JvmBackendContext.getStaticFunctionWithReceivers(function: IrFunction) =
- staticDefaultStubs.getOrPut(function.symbol) {
+ staticDefaultStubs.getOrPut(function) {
createStaticFunctionWithReceivers(function.parent, function.name, function, copyBody = false)
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt
index 9493390..2220e4f 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt
@@ -35,6 +35,7 @@
import org.jetbrains.kotlin.load.java.JavaVisibilities
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.Name
+import org.jetbrains.kotlin.utils.addToStdlib.safeAs
internal val syntheticAccessorPhase = makeIrFilePhase(
::SyntheticAccessorLowering,
@@ -51,55 +52,55 @@
pendingTransformations.forEach { it() }
}
- private val functionMap = mutableMapOf<IrFunctionSymbol, IrFunctionSymbol>()
- private val getterMap = mutableMapOf<IrFieldSymbol, IrSimpleFunctionSymbol>()
- private val setterMap = mutableMapOf<IrFieldSymbol, IrSimpleFunctionSymbol>()
+ private val functionMap = mutableMapOf<IrFunction, IrFunction>()
+ private val getterMap = mutableMapOf<IrField, IrSimpleFunction>()
+ private val setterMap = mutableMapOf<IrField, IrSimpleFunction>()
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
if (expression.usesDefaultArguments()) {
return super.visitFunctionAccess(expression)
}
- fun makeFunctionAccessorSymbolWithSuper(functionSymbol: IrFunctionSymbol): IrFunctionSymbol =
- when (functionSymbol) {
- is IrConstructorSymbol -> functionSymbol.owner.makeConstructorAccessor().symbol
- is IrSimpleFunctionSymbol -> functionSymbol.owner.makeSimpleFunctionAccessor(expression as IrCall).symbol
- else -> error("Unknown subclass of IrFunctionSymbol")
+ fun makeFunctionAccessorWithSuper(function: IrFunction): IrFunction =
+ when (function) {
+ is IrConstructor -> function.makeConstructorAccessor()
+ is IrSimpleFunction -> function.makeSimpleFunctionAccessor(expression as IrCall)
+ else -> error("Unknown subclass of IrFunction")
}
return super.visitExpression(
handleAccess(
expression,
- expression.symbol,
+ expression.target,
functionMap,
- ::makeFunctionAccessorSymbolWithSuper,
+ ::makeFunctionAccessorWithSuper,
::modifyFunctionAccessExpression,
- (expression as? IrCall)?.superQualifierSymbol,
- (expression as? IrCall)?.dispatchReceiver?.type?.classifierOrNull as? IrClassSymbol
+ (expression as? IrCall)?.irSuperQualifier,
+ (expression as? IrCall)?.dispatchReceiver?.type?.classifierOrNull.safeAs<IrClassSymbol>()?.owner
)
)
}
override fun visitGetField(expression: IrGetField) = super.visitExpression(
- handleAccess(expression, expression.symbol, getterMap, ::makeGetterAccessorSymbol, ::modifyGetterExpression)
+ handleAccess(expression, expression.target, getterMap, ::makeGetterAccessor, ::modifyGetterExpression)
)
override fun visitSetField(expression: IrSetField) = super.visitExpression(
- handleAccess(expression, expression.symbol, setterMap, ::makeSetterAccessorSymbol, ::modifySetterExpression)
+ handleAccess(expression, expression.target, setterMap, ::makeSetterAccessor, ::modifySetterExpression)
)
- private inline fun <ExprT : IrDeclarationReference, reified FromSyT : IrSymbol, ToSyT : IrSymbol> handleAccess(
+ private inline fun <ExprT : IrDeclarationReference, reified FromSyT : IrDeclarationWithVisibility, ToSyT : IrDeclarationWithVisibility> handleAccess(
expression: ExprT,
- symbol: FromSyT,
+ declaration: FromSyT,
accumMap: MutableMap<FromSyT, ToSyT>,
- symbolConverter: (FromSyT) -> ToSyT,
+ declarationConverter: (FromSyT) -> ToSyT,
exprConverter: (ExprT, ToSyT) -> IrDeclarationReference,
- superQualifierSymbol: IrClassSymbol? = null,
- thisSymbol: IrClassSymbol? = null
+ superQualifier: IrClass? = null,
+ thisObjReference: IrClass? = null
): IrExpression =
- if (!symbol.isAccessible(superQualifierSymbol != null, thisSymbol)) {
- val accessorSymbol = accumMap.getOrPut(symbol) { symbolConverter(symbol) }
- exprConverter(expression, accessorSymbol)
+ if (!declaration.isAccessible(superQualifier != null, thisObjReference)) {
+ val accessor = accumMap.getOrPut(declaration) { declarationConverter(declaration) }
+ exprConverter(expression, accessor)
} else {
expression
}
@@ -129,22 +130,22 @@
accessor.returnType = source.returnType.remapTypeParameters(source, accessor)
accessor.addValueParameter(
- "marker", context.ir.symbols.defaultConstructorMarker.owner.defaultType, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
+ "marker", context.ir.symbols.defaultConstructorMarker.defaultType, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
)
accessor.body = IrExpressionBodyImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- createConstructorCall(accessor, source.symbol)
+ createConstructorCall(accessor, source)
)
}
}
- private fun createConstructorCall(accessor: IrConstructor, targetSymbol: IrConstructorSymbol) =
+ private fun createConstructorCall(accessor: IrConstructor, target: IrConstructor) =
IrDelegatingConstructorCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
context.irBuiltIns.unitType,
- targetSymbol, targetSymbol.descriptor,
- targetSymbol.owner.parentAsClass.typeParameters.size + targetSymbol.owner.typeParameters.size
+ target, target.descriptor,
+ target.parentAsClass.typeParameters.size + target.typeParameters.size
).also {
copyAllParamsToArgs(it, accessor)
}
@@ -201,94 +202,94 @@
accessor.body = IrExpressionBodyImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- createSimpleFunctionCall(accessor, source.symbol, expression.superQualifierSymbol)
+ createSimpleFunctionCall(accessor, source, expression.irSuperQualifier)
)
}
}
- private fun createSimpleFunctionCall(accessor: IrFunction, targetSymbol: IrFunctionSymbol, superQualifierSymbol: IrClassSymbol?) =
+ private fun createSimpleFunctionCall(accessor: IrFunction, target: IrFunction, superQualifier: IrClass?) =
IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
accessor.returnType,
- targetSymbol, targetSymbol.descriptor,
- targetSymbol.owner.typeParameters.size,
- superQualifierSymbol = superQualifierSymbol
+ target, target.descriptor,
+ target.typeParameters.size,
+ irSuperQualifier = superQualifier
).also {
copyAllParamsToArgs(it, accessor)
}
- private fun makeGetterAccessorSymbol(fieldSymbol: IrFieldSymbol): IrSimpleFunctionSymbol =
+ private fun makeGetterAccessor(field: IrField): IrSimpleFunction =
buildFun {
origin = JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
- name = fieldSymbol.owner.accessorNameForGetter()
+ name = field.accessorNameForGetter()
visibility = Visibilities.PUBLIC
modality = Modality.FINAL
- returnType = fieldSymbol.owner.type
+ returnType = field.type
}.also { accessor ->
- accessor.parent = fieldSymbol.owner.accessorParent()
+ accessor.parent = field.accessorParent()
pendingTransformations.add { (accessor.parent as IrDeclarationContainer).declarations.add(accessor) }
- if (!fieldSymbol.owner.isStatic) {
+ if (!field.isStatic) {
accessor.addValueParameter(
- "\$this", fieldSymbol.owner.parentAsClass.defaultType, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
+ "\$this", field.parentAsClass.defaultType, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
)
}
- accessor.body = createAccessorBodyForGetter(fieldSymbol.owner, accessor)
- }.symbol
+ accessor.body = createAccessorBodyForGetter(field, accessor)
+ }
private fun createAccessorBodyForGetter(targetField: IrField, accessor: IrSimpleFunction): IrBody {
val resolvedTargetField = targetField.resolveFakeOverride()!!
val maybeDispatchReceiver =
if (resolvedTargetField.isStatic) null
- else IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, accessor.valueParameters[0].symbol)
+ else IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, accessor.valueParameters[0])
return IrExpressionBodyImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
IrGetFieldImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- resolvedTargetField.symbol,
+ resolvedTargetField,
resolvedTargetField.type,
maybeDispatchReceiver
)
)
}
- private fun makeSetterAccessorSymbol(fieldSymbol: IrFieldSymbol): IrSimpleFunctionSymbol =
+ private fun makeSetterAccessor(field: IrField): IrSimpleFunction =
buildFun {
origin = JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
- name = fieldSymbol.owner.accessorNameForSetter()
+ name = field.accessorNameForSetter()
visibility = Visibilities.PUBLIC
modality = Modality.FINAL
returnType = context.irBuiltIns.unitType
}.also { accessor ->
- accessor.parent = fieldSymbol.owner.accessorParent()
+ accessor.parent = field.accessorParent()
pendingTransformations.add { (accessor.parent as IrDeclarationContainer).declarations.add(accessor) }
- if (!fieldSymbol.owner.isStatic) {
+ if (!field.isStatic) {
accessor.addValueParameter(
- "\$this", fieldSymbol.owner.parentAsClass.defaultType, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
+ "\$this", field.parentAsClass.defaultType, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR
)
}
- accessor.addValueParameter("value", fieldSymbol.owner.type, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR)
+ accessor.addValueParameter("value", field.type, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR)
- accessor.body = createAccessorBodyForSetter(fieldSymbol.owner, accessor)
- }.symbol
+ accessor.body = createAccessorBodyForSetter(field, accessor)
+ }
private fun createAccessorBodyForSetter(targetField: IrField, accessor: IrSimpleFunction): IrBody {
val resolvedTargetField = targetField.resolveFakeOverride()!!
val maybeDispatchReceiver =
if (resolvedTargetField.isStatic) null
- else IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, accessor.valueParameters[0].symbol)
+ else IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, accessor.valueParameters[0])
val value = IrGetValueImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- accessor.valueParameters[if (resolvedTargetField.isStatic) 0 else 1].symbol
+ accessor.valueParameters[if (resolvedTargetField.isStatic) 0 else 1]
)
return IrExpressionBodyImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
IrSetFieldImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
- resolvedTargetField.symbol,
+ resolvedTargetField,
maybeDispatchReceiver,
value,
context.irBuiltIns.unitType
@@ -298,27 +299,27 @@
private fun modifyFunctionAccessExpression(
oldExpression: IrFunctionAccessExpression,
- accessorSymbol: IrFunctionSymbol
+ accessor: IrFunction
): IrFunctionAccessExpression {
val newExpression = when (oldExpression) {
is IrCall -> IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset,
oldExpression.type,
- accessorSymbol, accessorSymbol.descriptor,
+ accessor, accessor.descriptor,
oldExpression.typeArgumentsCount,
oldExpression.origin
)
is IrDelegatingConstructorCall -> IrDelegatingConstructorCallImpl(
oldExpression.startOffset, oldExpression.endOffset,
context.irBuiltIns.unitType,
- accessorSymbol as IrConstructorSymbol, accessorSymbol.descriptor,
+ accessor as IrConstructor, accessor.descriptor,
oldExpression.typeArgumentsCount
)
is IrConstructorCall ->
IrConstructorCallImpl.fromSymbolDescriptor(
oldExpression.startOffset, oldExpression.endOffset,
oldExpression.type,
- accessorSymbol as IrConstructorSymbol
+ accessor as IrConstructor
)
else ->
error("Unexpected IrFunctionAccessExpression: $oldExpression")
@@ -328,13 +329,13 @@
receiverAndArgs.forEachIndexed { i, irExpression ->
newExpression.putValueArgument(i, irExpression)
}
- if (accessorSymbol is IrConstructorSymbol) {
+ if (accessor is IrConstructor) {
newExpression.putValueArgument(
receiverAndArgs.size,
IrConstImpl.constNull(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
- context.ir.symbols.defaultConstructorMarker.owner.defaultType
+ context.ir.symbols.defaultConstructorMarker.defaultType
)
)
}
@@ -343,12 +344,12 @@
private fun modifyGetterExpression(
oldExpression: IrGetField,
- accessorSymbol: IrFunctionSymbol
+ accessor: IrSimpleFunction
): IrCall {
val call = IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset,
oldExpression.type,
- accessorSymbol, accessorSymbol.descriptor,
+ accessor, accessor.descriptor,
0,
oldExpression.origin
)
@@ -360,12 +361,12 @@
private fun modifySetterExpression(
oldExpression: IrSetField,
- accessorSymbol: IrFunctionSymbol
+ accessor: IrSimpleFunction
): IrCall {
val call = IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset,
oldExpression.type,
- accessorSymbol, accessorSymbol.descriptor,
+ accessor, accessor.descriptor,
0,
oldExpression.origin
)
@@ -388,15 +389,15 @@
call.passTypeArgumentsFrom(syntheticFunction, offset = typeArgumentOffset)
var offset = 0
- val delegateTo = call.symbol.owner
+ val delegateTo = call.target
delegateTo.dispatchReceiverParameter?.let {
call.dispatchReceiver =
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, syntheticFunction.valueParameters[offset++].symbol)
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, syntheticFunction.valueParameters[offset++])
}
delegateTo.extensionReceiverParameter?.let {
call.extensionReceiver =
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, syntheticFunction.valueParameters[offset++].symbol)
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, syntheticFunction.valueParameters[offset++])
}
delegateTo.valueParameters.forEachIndexed { i, _ ->
@@ -405,7 +406,7 @@
IrGetValueImpl(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
- syntheticFunction.valueParameters[i + offset].symbol
+ syntheticFunction.valueParameters[i + offset]
)
)
}
@@ -437,14 +438,13 @@
this == JavaVisibilities.PROTECTED_AND_PACKAGE ||
this == JavaVisibilities.PROTECTED_STATIC_VISIBILITY
- private fun IrSymbol.isAccessible(withSuper: Boolean, thisObjReference: IrClassSymbol?): Boolean {
+ private fun IrDeclarationWithVisibility.isAccessible(withSuper: Boolean, thisObjReference: IrClass?): Boolean {
/// We assume that IR code that reaches us has been checked for correctness at the frontend.
/// This function needs to single out those cases where Java accessibility rules differ from Kotlin's.
- val declarationRaw = owner as IrDeclarationWithVisibility
val declaration =
- (declarationRaw as? IrSimpleFunction)?.resolveFakeOverride()
- ?: (declarationRaw as? IrField)?.resolveFakeOverride() ?: declarationRaw
+ (this as? IrSimpleFunction)?.resolveFakeOverride()
+ ?: (this as? IrField)?.resolveFakeOverride() ?: this
// There is never a problem with visibility of inline functions, as those don't end up as Java entities
if (declaration is IrFunction && declaration.isInline) return true
@@ -472,7 +472,7 @@
// 1. `this` to be assign compatible with current class.
// 2. the method is a member of a superclass of current class.
(withSuper && contextDeclarationContainer is IrClass && symbolDeclarationContainer is IrClass &&
- ((thisObjReference != null && !contextDeclarationContainer.symbol.isSubtypeOfClass(thisObjReference)) ||
+ ((thisObjReference != null && !contextDeclarationContainer.isSubtypeOfClass(thisObjReference)) ||
!(contextDeclarationContainer.isSubclassOf(symbolDeclarationContainer)))) -> false
else -> true
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt
index 2c71982..19b451a 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt
@@ -123,14 +123,14 @@
}
)
- irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
+ irFunction.body = context.createIrBuilder(irFunction).irBlockBody {
+irReturn(
- irCall(symbols.genericToArray, symbols.genericToArray.owner.returnType).apply {
+ irCall(symbols.genericToArray, symbols.genericToArray.returnType).apply {
putValueArgument(
0,
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!)
)
- putValueArgument(1, IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.valueParameters[0].symbol))
+ putValueArgument(1, IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.valueParameters[0]))
})
}
@@ -172,12 +172,12 @@
parent = irFunction
}
- irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
+ irFunction.body = context.createIrBuilder(irFunction).irBlockBody {
+irReturn(
- irCall(symbols.nonGenericToArray, symbols.nonGenericToArray.owner.returnType).apply {
+ irCall(symbols.nonGenericToArray, symbols.nonGenericToArray.returnType).apply {
putValueArgument(
0,
- IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
+ IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!)
)
})
}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt
index 17d774d..2fe4873 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt
@@ -20,12 +20,12 @@
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrFile
+import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.IrTypeOperator
import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.render
@@ -64,8 +64,8 @@
argument.type.isNullable() && type.isNullable() -> {
irLetS(argument) { valueSymbol ->
context.oror(
- irEqualsNull(irGet(valueSymbol.owner)),
- irIs(irGet(valueSymbol.owner), type.makeNotNull())
+ irEqualsNull(irGet(valueSymbol)),
+ irIs(irGet(valueSymbol), type.makeNotNull())
)
}
}
@@ -81,15 +81,15 @@
irLetS(argument) { valueSymbol ->
irIfNull(
type,
- irGet(valueSymbol.owner),
+ irGet(valueSymbol),
irThrow(irCall(typeCastException).apply {
putValueArgument(0, irString("null cannot be cast to non-null type ${type.render()}"))
}),
- lowerCast(irGet(valueSymbol.owner), type.makeNullable())
+ lowerCast(irGet(valueSymbol), type.makeNullable())
)
}
}
- argument.type.isSubtypeOfClass(type.erasedUpperBound.symbol) ->
+ argument.type.isSubtypeOfClass(type.erasedUpperBound) ->
argument
else ->
builder.irAs(argument, type)
@@ -123,8 +123,8 @@
irLetS(expression.argument.transformVoid(), IrStatementOrigin.SAFE_CALL) { valueSymbol ->
irIfThenElse(
expression.type,
- lowerInstanceOf(irGet(valueSymbol.owner), expression.typeOperand.makeNotNull()),
- irGet(valueSymbol.owner),
+ lowerInstanceOf(irGet(valueSymbol), expression.typeOperand.makeNotNull()),
+ irGet(valueSymbol),
irNull(expression.type)
)
}
@@ -143,10 +143,10 @@
irLetS(expression.argument.transformVoid()) { valueSymbol ->
irComposite(resultType = expression.type) {
+irCall(checkExpressionValueIsNotNull).apply {
- putValueArgument(0, irGet(valueSymbol.owner))
+ putValueArgument(0, irGet(valueSymbol))
putValueArgument(1, irString(source))
}
- +irGet(valueSymbol.owner)
+ +irGet(valueSymbol)
}
}
}
@@ -180,13 +180,13 @@
private val useNullPointerExceptions: Boolean
get() = context.state.languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4
- private val typeCastException: IrFunctionSymbol =
+ private val typeCastException: IrFunction =
if (useNullPointerExceptions)
context.ir.symbols.ThrowNullPointerException
else
context.ir.symbols.ThrowTypeCastException
- private val checkExpressionValueIsNotNull: IrFunctionSymbol =
+ private val checkExpressionValueIsNotNull: IrFunction =
if (useNullPointerExceptions)
context.ir.symbols.checkNotNullExpressionValue
else
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/VarargLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/VarargLowering.kt
index eb9650b..fff4ad4 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/VarargLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/VarargLowering.kt
@@ -22,7 +22,6 @@
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
import org.jetbrains.kotlin.ir.expressions.*
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.util.*
val varargPhase = makeIrFilePhase(
@@ -36,7 +35,7 @@
// Ignore annotations
override fun visitConstructorCall(expression: IrConstructorCall): IrExpression {
- val constructor = expression.symbol.owner
+ val constructor = expression.target
if (constructor.constructedClass.isAnnotationClass)
return expression
return super.visitConstructorCall(expression)
@@ -44,14 +43,14 @@
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
expression.transformChildrenVoid()
- val function = expression.symbol
+ val function = expression.target
// Replace empty varargs with empty arrays
for (i in 0 until expression.valueArgumentsCount) {
if (expression.getValueArgument(i) != null)
continue
- val parameter = function.owner.valueParameters[i]
+ val parameter = function.valueParameters[i]
if (parameter.varargElementType != null && !parameter.hasDefaultValue()) {
// Compute the correct type for the array argument.
val arrayType = parameter.type.substitute(expression.typeSubstitutionMap)
@@ -73,7 +72,7 @@
is IrExpression -> +element.transform(this@VarargLowering, null)
is IrSpreadElement -> {
val spread = element.expression
- if (spread is IrFunctionAccessExpression && spread.symbol.isArrayOf) {
+ if (spread is IrFunctionAccessExpression && spread.target.isArrayOf) {
// Skip empty arrays and don't copy immediately created arrays
val argument = spread.getValueArgument(0) ?: continue@loop
if (argument is IrVararg) {
@@ -89,10 +88,10 @@
}
private fun createBuilder(startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET) =
- context.createJvmIrBuilder(currentScope!!.scope.scopeOwnerSymbol, startOffset, endOffset)
+ context.createJvmIrBuilder(currentScope!!.scope.irScopeOwner, startOffset, endOffset)
- private val IrFunctionSymbol.isArrayOf
- get() = this == context.ir.symbols.arrayOf || owner.isPrimitiveArrayOf
+ private val IrFunction.isArrayOf
+ get() = this == context.ir.symbols.arrayOf || isPrimitiveArrayOf
companion object {
private val PRIMITIVE_ARRAY_OF_NAMES: Set<String> =
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt
index 5515a41..f2eb073 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt
@@ -18,8 +18,6 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
import org.jetbrains.kotlin.ir.types.getClass
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl
@@ -32,7 +30,7 @@
class IrReplacementFunction(
val function: IrFunction,
- val valueParameterMap: Map<IrValueParameterSymbol, IrValueParameter>
+ val valueParameterMap: Map<IrValueParameter, IrValueParameter>
)
/**
@@ -136,17 +134,17 @@
private fun createMethodReplacement(function: IrFunction): IrReplacementFunction? {
require(function.dispatchReceiverParameter != null && function is IrSimpleFunction)
- val overrides = function.overriddenSymbols.mapNotNull {
- getReplacementFunction(it.owner)?.function?.symbol as? IrSimpleFunctionSymbol
+ val overrides = function.overridden.mapNotNull {
+ getReplacementFunction(it)?.function as? IrSimpleFunction
}
if (function.origin == IrDeclarationOrigin.FAKE_OVERRIDE && overrides.isEmpty())
return null
- val parameterMap = mutableMapOf<IrValueParameterSymbol, IrValueParameter>()
+ val parameterMap = mutableMapOf<IrValueParameter, IrValueParameter>()
val replacement = buildReplacement(function) {
annotations += function.annotations
metadata = function.metadata
- overriddenSymbols.addAll(overrides)
+ overridden.addAll(overrides)
for ((index, parameter) in function.explicitParameters.withIndex()) {
val name = if (parameter == function.extensionReceiverParameter) Name.identifier("\$receiver") else parameter.name
@@ -158,16 +156,16 @@
newParameter = parameter.copyTo(this, index = index - 1, name = name)
valueParameters.add(newParameter)
}
- parameterMap[parameter.symbol] = newParameter
+ parameterMap[parameter] = newParameter
}
}
return IrReplacementFunction(replacement, parameterMap)
}
private fun createStaticReplacement(function: IrFunction): IrReplacementFunction {
- val parameterMap = mutableMapOf<IrValueParameterSymbol, IrValueParameter>()
+ val parameterMap = mutableMapOf<IrValueParameter, IrValueParameter>()
val replacement = buildReplacement(function) {
- if (function !is IrSimpleFunction || function.overriddenSymbols.isEmpty())
+ if (function !is IrSimpleFunction || function.overridden.isEmpty())
metadata = function.metadata
for ((index, parameter) in function.explicitParameters.withIndex()) {
@@ -179,7 +177,7 @@
val newParameter = parameter.copyTo(this, index = index, name = name)
valueParameters.add(newParameter)
- parameterMap[parameter.symbol] = newParameter
+ parameterMap[parameter] = newParameter
}
}
return IrReplacementFunction(replacement, parameterMap)
diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt
index cd82dc7..9326e1c 100644
--- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt
+++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt
@@ -323,7 +323,8 @@
val wasmPhases = namedIrModulePhase<WasmBackendContext>(
name = "IrModuleLowering",
description = "IR module lowering",
- lower = validateIrBeforeLowering then
+ lower = desymbolizePhase then
+ validateIrBeforeLowering then
excludeDeclarationsFromCodegenPhase then
expectDeclarationsRemovingPhase then
provisionalFunctionExpressionPhase then
diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/codegen/ExpressionTransformer.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/codegen/ExpressionTransformer.kt
index 54ba690..97b7c52 100644
--- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/codegen/ExpressionTransformer.kt
+++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/codegen/ExpressionTransformer.kt
@@ -54,7 +54,7 @@
}
override fun visitGetField(expression: IrGetField, data: WasmCodegenContext): WasmInstruction {
- val fieldName = data.getGlobalName(expression.symbol.owner)
+ val fieldName = data.getGlobalName(expression.target)
if (expression.receiver != null)
TODO("Support member fields")
@@ -62,14 +62,14 @@
}
override fun visitGetValue(expression: IrGetValue, data: WasmCodegenContext): WasmInstruction =
- WasmGetLocal(data.getLocalName(expression.symbol.owner))
+ WasmGetLocal(data.getLocalName(expression.target))
override fun visitGetObjectValue(expression: IrGetObjectValue, data: WasmCodegenContext): WasmInstruction {
TODO("IrGetObjectValue")
}
override fun visitSetField(expression: IrSetField, data: WasmCodegenContext): WasmInstruction {
- val fieldName = data.getGlobalName(expression.symbol.owner)
+ val fieldName = data.getGlobalName(expression.target)
if (expression.receiver != null)
TODO("Support member fields")
@@ -78,7 +78,7 @@
}
override fun visitSetVariable(expression: IrSetVariable, data: WasmCodegenContext): WasmInstruction {
- val fieldName = data.getLocalName(expression.symbol.owner)
+ val fieldName = data.getLocalName(expression.target)
val value = expression.value.accept(this, data)
return WasmSetLocal(fieldName, value)
}
@@ -88,7 +88,7 @@
}
override fun visitCall(expression: IrCall, data: WasmCodegenContext): WasmInstruction {
- val function = expression.symbol.owner.realOverrideTarget
+ val function = expression.target.realOverrideTarget
require(function is IrSimpleFunction) { "Only IrSimpleFunction could be called via IrCall" }
val valueArgs = (0 until expression.valueArgumentsCount).mapNotNull { expression.getValueArgument(it) }
val irArguments = listOfNotNull(expression.dispatchReceiver, expression.extensionReceiver) + valueArgs
diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/BuiltInsLowering.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/BuiltInsLowering.kt
index b688091..256aaca 100644
--- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/BuiltInsLowering.kt
+++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/BuiltInsLowering.kt
@@ -9,7 +9,6 @@
import org.jetbrains.kotlin.backend.wasm.WasmBackendContext
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.expressions.IrCall
-import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.util.irCall
import org.jetbrains.kotlin.ir.util.render
@@ -21,7 +20,7 @@
private val symbols = context.wasmSymbols
fun transformCall(call: IrCall): IrExpression {
- when (val symbol = call.symbol) {
+ when (val symbol = call.target) {
irBuiltins.eqeqSymbol, irBuiltins.eqeqeqSymbol, in irBuiltins.ieee754equalsFunByOperandType.values -> {
val type = call.getValueArgument(0)!!.type
val newSymbol = symbols.equalityFunctions[type]
diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt
index 6901294..798053c 100644
--- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt
+++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt
@@ -420,7 +420,7 @@
context.symbolTable.referenceFunction(functionDescriptor.original),
functionDescriptor,
origin = null, // TODO origin for widening conversions?
- superQualifierSymbol = null
+ irSuperQualifier = null
).apply {
dispatchReceiver = receiver
}
diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt
index 46ca1bd..5704174 100644
--- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt
+++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt
@@ -17,6 +17,8 @@
package org.jetbrains.kotlin.psi2ir.generators
import org.jetbrains.kotlin.descriptors.*
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrClassifier
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt
index 43ffa8c..915ae74 100644
--- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt
+++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt
@@ -105,7 +105,7 @@
override fun visitReturn(expression: IrReturn): IrExpression =
expression.transformPostfix {
- value = if (expression.returnTargetSymbol is IrConstructorSymbol) {
+ value = if (expression.irReturnTarget is IrConstructorSymbol) {
value.coerceToUnit()
} else {
value.cast(expression.returnTarget.returnType)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt
index 597c6fa..01ef93d 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt
@@ -11,7 +11,6 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.types.KotlinType
@@ -23,10 +22,10 @@
value: IrExpression,
origin: IrStatementOrigin? = null,
nameHint: String? = null,
- body: (IrValueSymbol) -> IrExpression
+ body: (IrValueDeclaration) -> IrExpression
): IrExpression {
val irTemporary = scope.createTemporaryVariable(value, nameHint)
- val irResult = body(irTemporary.symbol)
+ val irResult = body(irTemporary)
val irBlock = IrBlockImpl(startOffset, endOffset, irResult.type, origin)
irBlock.statements.add(irTemporary)
irBlock.statements.add(irResult)
@@ -88,7 +87,7 @@
IrReturnImpl(
startOffset, endOffset,
context.irBuiltIns.nothingType,
- scope.scopeOwnerSymbol.assertedCast<IrReturnTargetSymbol> {
+ scope.irScopeOwner.assertedCast<IrReturnTarget> {
"Function scope expected: ${scope.scopeOwner}"
},
value
@@ -150,22 +149,22 @@
fun IrBuilderWithScope.irIfThenReturnFalse(condition: IrExpression) =
irIfThen(context.irBuiltIns.unitType, condition, irReturnFalse())
-fun IrBuilderWithScope.irGet(type: IrType, variable: IrValueSymbol) =
+fun IrBuilderWithScope.irGet(type: IrType, variable: IrValueDeclaration) =
IrGetValueImpl(startOffset, endOffset, type, variable)
-fun IrBuilderWithScope.irGet(variable: IrValueDeclaration) = irGet(variable.type, variable.symbol)
+fun IrBuilderWithScope.irGet(variable: IrValueDeclaration) = irGet(variable.type, variable)
-fun IrBuilderWithScope.irSetVar(variable: IrVariableSymbol, value: IrExpression) =
+fun IrBuilderWithScope.irSetVar(variable: IrVariable, value: IrExpression) =
IrSetVariableImpl(startOffset, endOffset, context.irBuiltIns.unitType, variable, value, IrStatementOrigin.EQ)
fun IrBuilderWithScope.irGetField(receiver: IrExpression?, field: IrField) =
- IrGetFieldImpl(startOffset, endOffset, field.symbol, field.type, receiver)
+ IrGetFieldImpl(startOffset, endOffset, field, field.type, receiver)
fun IrBuilderWithScope.irSetField(receiver: IrExpression?, field: IrField, value: IrExpression) =
- IrSetFieldImpl(startOffset, endOffset, field.symbol, receiver, value, context.irBuiltIns.unitType)
+ IrSetFieldImpl(startOffset, endOffset, field, receiver, value, context.irBuiltIns.unitType)
-fun IrBuilderWithScope.irGetObjectValue(type: IrType, classSymbol: IrClassSymbol) =
- IrGetObjectValueImpl(startOffset, endOffset, type, classSymbol)
+fun IrBuilderWithScope.irGetObjectValue(type: IrType, klass: IrClass) =
+ IrGetObjectValueImpl(startOffset, endOffset, type, klass)
fun IrBuilderWithScope.irEqeqeq(arg1: IrExpression, arg2: IrExpression) =
context.eqeqeq(startOffset, endOffset, arg1, arg2)
@@ -191,26 +190,26 @@
irEquals(arg1, arg2, origin = IrStatementOrigin.EXCLEQ)
)
-fun IrBuilderWithScope.irGet(type: IrType, receiver: IrExpression?, getterSymbol: IrFunctionSymbol): IrCall =
+fun IrBuilderWithScope.irGet(type: IrType, receiver: IrExpression?, getter: IrFunction): IrCall =
IrCallImpl(
startOffset, endOffset,
type,
- getterSymbol as IrSimpleFunctionSymbol,
- getterSymbol.descriptor,
- typeArgumentsCount = getterSymbol.owner.typeParameters.size,
+ getter as IrSimpleFunction,
+ getter.descriptor,
+ typeArgumentsCount = getter.typeParameters.size,
valueArgumentsCount = 0,
origin = IrStatementOrigin.GET_PROPERTY
).apply {
dispatchReceiver = receiver
}
-fun IrBuilderWithScope.irSet(type: IrType, receiver: IrExpression?, setterSymbol: IrFunctionSymbol, value: IrExpression): IrCall =
+fun IrBuilderWithScope.irSet(type: IrType, receiver: IrExpression?, setter: IrFunction, value: IrExpression): IrCall =
IrCallImpl(
startOffset, endOffset,
type,
- setterSymbol as IrSimpleFunctionSymbol,
- setterSymbol.descriptor,
- typeArgumentsCount = setterSymbol.owner.typeParameters.size,
+ setter as IrSimpleFunction,
+ setter.descriptor,
+ typeArgumentsCount = setter.typeParameters.size,
valueArgumentsCount = 1,
origin = IrStatementOrigin.EQ
).apply {
@@ -219,7 +218,7 @@
}
fun IrBuilderWithScope.irCall(
- callee: IrFunctionSymbol,
+ callee: IrFunction,
type: IrType,
typeArguments: List<IrType>
): IrMemberAccessExpression =
@@ -229,11 +228,11 @@
}
}
-fun IrBuilderWithScope.irCallConstructor(callee: IrConstructorSymbol, typeArguments: List<IrType>): IrConstructorCall =
+fun IrBuilderWithScope.irCallConstructor(callee: IrConstructor, typeArguments: List<IrType>): IrConstructorCall =
IrConstructorCallImpl.fromSymbolOwner(
startOffset,
endOffset,
- callee.owner.returnType,
+ callee.returnType,
callee
).apply {
typeArguments.forEachIndexed { index, irType ->
@@ -241,49 +240,46 @@
}
}
-fun IrBuilderWithScope.irCall(callee: IrSimpleFunctionSymbol, type: IrType): IrCall =
+fun IrBuilderWithScope.irCall(callee: IrSimpleFunction, type: IrType): IrCall =
IrCallImpl(startOffset, endOffset, type, callee, callee.descriptor)
-fun IrBuilderWithScope.irCall(callee: IrConstructorSymbol, type: IrType): IrConstructorCall =
+fun IrBuilderWithScope.irCall(callee: IrConstructor, type: IrType): IrConstructorCall =
IrConstructorCallImpl.fromSymbolDescriptor(startOffset, endOffset, type, callee)
-fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol, type: IrType): IrFunctionAccessExpression =
+fun IrBuilderWithScope.irCall(callee: IrFunction, type: IrType): IrFunctionAccessExpression =
when (callee) {
- is IrConstructorSymbol -> irCall(callee, type)
- is IrSimpleFunctionSymbol -> irCall(callee, type)
+ is IrConstructor -> irCall(callee, type)
+ is IrSimpleFunction -> irCall(callee, type)
else -> throw AssertionError("Unexpected callee: $callee")
}
-fun IrBuilderWithScope.irCall(callee: IrSimpleFunctionSymbol): IrCall =
- irCall(callee, callee.owner.returnType)
+fun IrBuilderWithScope.irCall(callee: IrSimpleFunction): IrCall =
+ irCall(callee, callee.returnType)
-fun IrBuilderWithScope.irCall(callee: IrConstructorSymbol): IrConstructorCall =
- irCall(callee, callee.owner.returnType)
-
-fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol): IrFunctionAccessExpression =
- irCall(callee, callee.owner.returnType)
-
-fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol, descriptor: FunctionDescriptor, type: IrType): IrCall =
- IrCallImpl(startOffset, endOffset, type, callee as IrSimpleFunctionSymbol, descriptor)
+fun IrBuilderWithScope.irCall(callee: IrConstructor): IrConstructorCall =
+ irCall(callee, callee.returnType)
fun IrBuilderWithScope.irCall(callee: IrFunction): IrFunctionAccessExpression =
- irCall(callee.symbol)
+ irCall(callee, callee.returnType)
+
+fun IrBuilderWithScope.irCall(callee: IrFunction, descriptor: FunctionDescriptor, type: IrType): IrCall =
+ IrCallImpl(startOffset, endOffset, type, callee as IrSimpleFunction, descriptor)
fun IrBuilderWithScope.irCall(callee: IrFunction, origin: IrStatementOrigin): IrCall =
IrCallImpl(
startOffset, endOffset, callee.returnType,
- callee.symbol as IrSimpleFunctionSymbol,
+ callee as IrSimpleFunction,
callee.descriptor, origin
)
fun IrBuilderWithScope.irDelegatingConstructorCall(callee: IrConstructor): IrDelegatingConstructorCall =
IrDelegatingConstructorCallImpl(
- startOffset, endOffset, context.irBuiltIns.unitType, callee.symbol, callee.descriptor,
+ startOffset, endOffset, context.irBuiltIns.unitType, callee, callee.descriptor,
callee.parentAsClass.typeParameters.size, callee.valueParameters.size
)
fun IrBuilderWithScope.irCallOp(
- callee: IrFunctionSymbol,
+ callee: IrFunction,
type: IrType,
dispatchReceiver: IrExpression,
argument: IrExpression? = null
@@ -334,7 +330,7 @@
IrSetFieldImpl(
startOffset,
endOffset,
- irField.symbol,
+ irField,
receiver = receiver,
value = value,
type = context.irBuiltIns.unitType
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Scope.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Scope.kt
index 01cf3cc..e377feb 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Scope.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Scope.kt
@@ -18,10 +18,7 @@
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
-import org.jetbrains.kotlin.ir.declarations.IrDeclaration
-import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
-import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
-import org.jetbrains.kotlin.ir.declarations.IrVariable
+import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
import org.jetbrains.kotlin.ir.descriptors.IrTemporaryVariableDescriptor
import org.jetbrains.kotlin.ir.descriptors.IrTemporaryVariableDescriptorImpl
@@ -34,16 +31,15 @@
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.KotlinType
-class Scope(val scopeOwnerSymbol: IrSymbol) {
- val scopeOwner: DeclarationDescriptor get() = scopeOwnerSymbol.descriptor
+class Scope(val irScopeOwner: IrSymbolOwner) {
+ val scopeOwner: DeclarationDescriptor get() = irScopeOwner.symbol.descriptor
fun getLocalDeclarationParent(): IrDeclarationParent {
- if (!scopeOwnerSymbol.isBound) throw AssertionError("Unbound symbol: $scopeOwner")
- val scopeOwnerElement = scopeOwnerSymbol.owner
- return when (scopeOwnerElement) {
- is IrDeclarationParent -> scopeOwnerElement
- !is IrDeclaration -> throw AssertionError("Not a declaration: $scopeOwnerElement")
- else -> scopeOwnerElement.parent
+ if (!irScopeOwner.symbol.isBound) throw AssertionError("Unbound symbol: $scopeOwner")
+ return when (irScopeOwner) {
+ is IrDeclarationParent -> irScopeOwner
+ !is IrDeclaration -> throw AssertionError("Not a declaration: $irScopeOwner")
+ else -> irScopeOwner.parent
}
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt
index 285ccae..c1ee57e 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt
@@ -24,7 +24,7 @@
import org.jetbrains.kotlin.ir.types.IrType
interface IrClass :
- IrSymbolDeclaration<IrClassSymbol>, IrDeclarationWithName, IrDeclarationWithVisibility,
+ IrSymbolDeclaration<IrClassSymbol>, IrDeclarationWithName, IrDeclarationWithVisibility, IrClassifier,
IrDeclarationContainer, IrTypeParametersContainer, IrAttributeContainer {
override val descriptor: ClassDescriptor
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClassifier.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClassifier.kt
new file mode 100644
index 0000000..d01bbbb
--- /dev/null
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClassifier.kt
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.ir.declarations
+
+import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
+import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
+import org.jetbrains.kotlin.types.model.TypeConstructorMarker
+
+interface IrClassifier : IrDeclaration, IrSymbolOwner, TypeConstructorMarker {
+ override val symbol: IrClassifierSymbol
+ override val descriptor: ClassifierDescriptor
+}
\ No newline at end of file
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt
index d308113..332e5fd 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt
@@ -46,8 +46,8 @@
override val symbol: S
}
-interface IrOverridableDeclaration<S : IrSymbol> : IrDeclaration {
- val overriddenSymbols: MutableList<S>
+interface IrOverridableDeclaration<S : IrDeclaration> : IrDeclaration {
+ val overridden: MutableList<S>
}
interface IrDeclarationWithVisibility : IrDeclaration {
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrField.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrField.kt
index 4232a87..af29556 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrField.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrField.kt
@@ -12,7 +12,7 @@
import org.jetbrains.kotlin.ir.types.IrType
interface IrField :
- IrSymbolDeclaration<IrFieldSymbol>, IrOverridableDeclaration<IrFieldSymbol>,
+ IrSymbolDeclaration<IrFieldSymbol>, IrOverridableDeclaration<IrField>,
IrDeclarationWithName, IrDeclarationWithVisibility, IrDeclarationParent {
override val descriptor: PropertyDescriptor
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrSimpleFunction.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrSimpleFunction.kt
index 31bf00f..bd8985a 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrSimpleFunction.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrSimpleFunction.kt
@@ -23,7 +23,7 @@
interface IrSimpleFunction :
IrFunction,
IrSymbolDeclaration<IrSimpleFunctionSymbol>,
- IrOverridableDeclaration<IrSimpleFunctionSymbol> {
+ IrOverridableDeclaration<IrSimpleFunction> {
val modality: Modality
val isTailrec: Boolean
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeParameter.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeParameter.kt
index f13063b..d2f4b26 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeParameter.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrTypeParameter.kt
@@ -21,8 +21,11 @@
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.types.Variance
+import org.jetbrains.kotlin.types.model.TypeConstructorMarker
+import org.jetbrains.kotlin.types.model.TypeParameterMarker
-interface IrTypeParameter : IrSymbolDeclaration<IrTypeParameterSymbol>, IrDeclarationWithName {
+interface IrTypeParameter : IrSymbolDeclaration<IrTypeParameterSymbol>, IrDeclarationWithName, IrClassifier,
+ TypeParameterMarker {
override val descriptor: TypeParameterDescriptor
val variance: Variance
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt
index f5ff028..3462eef 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt
@@ -89,7 +89,7 @@
correspondingProperty = value?.owner
}
- override val overriddenSymbols: MutableList<IrFieldSymbol> = mutableListOf()
+ override val overridden: MutableList<IrField> = mutableListOf()
override var metadata: MetadataSource.Property? = null
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt
index 2515e51..9bac52c 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt
@@ -58,7 +58,7 @@
override val descriptor: FunctionDescriptor = symbol.descriptor
- override val overriddenSymbols: MutableList<IrSimpleFunctionSymbol> = SmartList()
+ override val overridden: MutableList<IrSimpleFunction> = SmartList()
override var correspondingProperty: IrProperty? = null
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyField.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyField.kt
index 49ab59e..8828bd7 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyField.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyField.kt
@@ -65,9 +65,9 @@
override val descriptor: PropertyDescriptor = symbol.descriptor
- override val overriddenSymbols: MutableList<IrFieldSymbol> by lazy {
+ override val overridden: MutableList<IrField> by lazy {
symbol.descriptor.overriddenDescriptors.map {
- stubGenerator.generateFieldStub(it.original).symbol
+ stubGenerator.generateFieldStub(it.original)
}.toMutableList()
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt
index 816a6d2..b8693ec 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt
@@ -79,9 +79,9 @@
}
- override val overriddenSymbols: MutableList<IrSimpleFunctionSymbol> by lazy {
+ override val overridden: MutableList<IrSimpleFunction> by lazy {
descriptor.overriddenDescriptors.mapTo(arrayListOf()) {
- stubGenerator.generateFunctionStub(it.original).symbol
+ stubGenerator.generateFunctionStub(it.original)
}
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt
index a2640e6..0a55847 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt
@@ -16,11 +16,11 @@
package org.jetbrains.kotlin.ir.expressions
+import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrReturnTarget
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.declarations.name
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
import org.jetbrains.kotlin.ir.util.file
@@ -41,11 +41,11 @@
interface IrReturnableBlock : IrBlock, IrSymbolOwner, IrReturnTarget {
override val symbol: IrReturnableBlockSymbol
- val inlineFunctionSymbol: IrFunctionSymbol?
+ val inlineFunction: IrFunction?
}
val IrReturnableBlock.sourceFileSymbol: IrFileSymbol?
- get() = inlineFunctionSymbol?.owner?.file?.symbol
+ get() = inlineFunction?.file?.symbol
@Deprecated("Please avoid using it")
val IrReturnableBlock.sourceFileName: String
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt
index a042b3d..6f6b378 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt
@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.ClassDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
+import org.jetbrains.kotlin.ir.declarations.IrClass
interface IrCall : IrFunctionAccessExpression {
val superQualifier: ClassDescriptor?
- val superQualifierSymbol: IrClassSymbol?
+ val irSuperQualifier: IrClass?
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt
index 221406d..5de2375 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt
@@ -20,7 +20,7 @@
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
-import org.jetbrains.kotlin.ir.symbols.*
+import org.jetbrains.kotlin.ir.declarations.*
interface IrCallableReference : IrMemberAccessExpression, IrDeclarationReference {
override val descriptor: CallableDescriptor
@@ -28,21 +28,21 @@
interface IrFunctionReference : IrCallableReference {
override val descriptor: FunctionDescriptor
- override val symbol: IrFunctionSymbol
+ override val target: IrFunction
}
interface IrPropertyReference : IrCallableReference {
override val descriptor: PropertyDescriptor
- override val symbol: IrPropertySymbol
- val field: IrFieldSymbol?
- val getter: IrSimpleFunctionSymbol?
- val setter: IrSimpleFunctionSymbol?
+ override val target: IrProperty
+ val field: IrField?
+ val getter: IrSimpleFunction?
+ val setter: IrSimpleFunction?
}
interface IrLocalDelegatedPropertyReference : IrCallableReference {
override val descriptor: VariableDescriptorWithAccessors
- override val symbol: IrLocalDelegatedPropertySymbol
- val delegate: IrVariableSymbol
- val getter: IrSimpleFunctionSymbol
- val setter: IrSimpleFunctionSymbol?
+ override val target: IrLocalDelegatedProperty
+ val delegate: IrVariable
+ val getter: IrSimpleFunction
+ val setter: IrSimpleFunction?
}
\ No newline at end of file
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt
index 3ea1ba7..c73027a 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrClassReference.kt
@@ -17,13 +17,13 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
+import org.jetbrains.kotlin.ir.declarations.IrClassifier
import org.jetbrains.kotlin.ir.types.IrType
interface IrClassReference : IrDeclarationReference {
override val descriptor: ClassifierDescriptor
- override val symbol: IrClassifierSymbol
+ override val target: IrClassifier
val classType: IrType
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConstructorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConstructorCall.kt
index 646b97f..30ff176 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConstructorCall.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrConstructorCall.kt
@@ -6,12 +6,12 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
+import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.types.IrType
interface IrConstructorCall : IrFunctionAccessExpression {
override val descriptor: ClassConstructorDescriptor
- override val symbol: IrConstructorSymbol
+ override val target: IrConstructor
val constructorTypeArgumentsCount: Int
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt
index e483d10..0ed3128 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDeclarationReference.kt
@@ -18,14 +18,13 @@
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
-
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
+import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
interface IrDeclarationReference : IrExpression {
val descriptor: DeclarationDescriptor
- val symbol: IrSymbol
+ val target: IrSymbolOwner
}
interface IrGetSingletonValue : IrDeclarationReference {
@@ -33,10 +32,10 @@
}
interface IrGetObjectValue : IrGetSingletonValue {
- override val symbol: IrClassSymbol
+ override val target: IrClass
}
interface IrGetEnumValue : IrGetSingletonValue {
- override val symbol: IrEnumEntrySymbol
+ override val target: IrEnumEntry
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt
index 66dacc6..3c50356 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrDelegatingConstructorCall.kt
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
+import org.jetbrains.kotlin.ir.declarations.IrConstructor
interface IrDelegatingConstructorCall : IrFunctionAccessExpression {
override val descriptor: ClassConstructorDescriptor
- override val symbol: IrConstructorSymbol
+ override val target: IrConstructor
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt
index b9a7d3d..6e7c427 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrEnumConstructorCall.kt
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
+import org.jetbrains.kotlin.ir.declarations.IrConstructor
interface IrEnumConstructorCall : IrFunctionAccessExpression {
override val descriptor: ClassConstructorDescriptor
- override val symbol: IrConstructorSymbol
+ override val target: IrConstructor
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrFieldAccessExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrFieldAccessExpression.kt
index d5c85e0..72715aa 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrFieldAccessExpression.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrFieldAccessExpression.kt
@@ -18,15 +18,15 @@
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrField
interface IrFieldAccessExpression : IrDeclarationReference {
override val descriptor: PropertyDescriptor
- override val symbol: IrFieldSymbol
+ override val target: IrField
val superQualifier: ClassDescriptor?
- val superQualifierSymbol: IrClassSymbol?
+ val irSuperQualifier: IrClass?
var receiver: IrExpression?
val origin: IrStatementOrigin?
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt
index 02c1d4b..ecd8bf1 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.ClassDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
+import org.jetbrains.kotlin.ir.declarations.IrClass
interface IrInstanceInitializerCall : IrExpression {
val classDescriptor: ClassDescriptor
- val classSymbol: IrClassSymbol
+ val irClass: IrClass
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt
index 0c0d6fe..c56f33cb 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrMemberAccessExpression.kt
@@ -9,12 +9,8 @@
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.defaultType
-import org.jetbrains.kotlin.ir.types.toKotlinType
-import org.jetbrains.kotlin.ir.util.dump
-import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.types.KotlinType
interface IrMemberAccessExpression : IrExpression {
@@ -44,6 +40,14 @@
for (i in 0 until typeArgumentsCount) {
putTypeArgument(i, other.getTypeArgument(i))
}
+ if (this is IrConstructorCall && other is IrConstructorCall) {
+ assert(constructorTypeArgumentsCount == other.constructorTypeArgumentsCount) {
+ "Mismatching constructor type arguments: $constructorTypeArgumentsCount vs ${other.constructorTypeArgumentsCount} "
+ }
+ for (i in 0 until constructorTypeArgumentsCount) {
+ putConstructorTypeArgument(i, other.getConstructorTypeArgument(i))
+ }
+ }
}
inline fun IrMemberAccessExpression.putTypeArguments(
@@ -68,7 +72,7 @@
interface IrFunctionAccessExpression : IrMemberAccessExpression, IrDeclarationReference {
override val descriptor: FunctionDescriptor
- override val symbol: IrFunctionSymbol
+ override val target: IrFunction
}
fun IrMemberAccessExpression.getValueArgument(valueParameterDescriptor: ValueParameterDescriptor) =
@@ -111,4 +115,4 @@
}
fun IrFunctionAccessExpression.putArgument(parameter: IrValueParameter, argument: IrExpression) =
- putArgument(symbol.owner, parameter, argument)
+ putArgument(target, parameter, argument)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt
index adae088..de079e0 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrReturn.kt
@@ -17,12 +17,11 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
-
+import org.jetbrains.kotlin.ir.declarations.IrReturnTarget
interface IrReturn : IrExpression {
var value: IrExpression
val returnTarget: FunctionDescriptor
- val returnTargetSymbol: IrReturnTargetSymbol
+ val irReturnTarget: IrReturnTarget
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrValueAccessExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrValueAccessExpression.kt
index 6cc37c7..58cb1fb 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrValueAccessExpression.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrValueAccessExpression.kt
@@ -18,12 +18,12 @@
import org.jetbrains.kotlin.descriptors.ValueDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
+import org.jetbrains.kotlin.ir.declarations.IrValueDeclaration
+import org.jetbrains.kotlin.ir.declarations.IrVariable
interface IrValueAccessExpression : IrDeclarationReference {
override val descriptor: ValueDescriptor
- override val symbol: IrValueSymbol
+ override val target: IrValueDeclaration
val origin: IrStatementOrigin?
}
@@ -33,7 +33,7 @@
interface IrSetVariable : IrValueAccessExpression {
override val descriptor: VariableDescriptor
- override val symbol: IrVariableSymbol
+ override val target: IrVariable
var value: IrExpression
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt
index b11f476..2b924b3 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockImpl.kt
@@ -16,14 +16,12 @@
package org.jetbrains.kotlin.ir.expressions.impl
-import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.ir.IrStatement
+import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrBlock
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
-import org.jetbrains.kotlin.ir.symbols.impl.IrReturnableBlockSymbolImpl
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -70,7 +68,7 @@
type: IrType,
override val symbol: IrReturnableBlockSymbol,
origin: IrStatementOrigin? = null,
- override val inlineFunctionSymbol: IrFunctionSymbol? = null
+ override val inlineFunction: IrFunction? = null
) :
IrContainerExpressionBase(startOffset, endOffset, type, origin),
IrReturnableBlock {
@@ -84,8 +82,8 @@
symbol: IrReturnableBlockSymbol,
origin: IrStatementOrigin?,
statements: List<IrStatement>,
- inlineFunctionSymbol: IrFunctionSymbol? = null
- ) : this(startOffset, endOffset, type, symbol, origin, inlineFunctionSymbol) {
+ inlineFunction: IrFunction? = null
+ ) : this(startOffset, endOffset, type, symbol, origin, inlineFunction) {
this.statements.addAll(statements)
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt
index 98b94c1..5788699 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt
@@ -19,11 +19,11 @@
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -31,12 +31,12 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrFunctionSymbol,
+ override val target: IrFunction,
override val descriptor: FunctionDescriptor,
typeArgumentsCount: Int,
valueArgumentsCount: Int,
origin: IrStatementOrigin? = null,
- override val superQualifierSymbol: IrClassSymbol? = null
+ override val irSuperQualifier: IrClass? = null
) :
IrCallWithIndexedArgumentsBase(
startOffset, endOffset, type,
@@ -56,34 +56,34 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrFunctionSymbol,
+ target: IrFunction,
descriptor: FunctionDescriptor,
origin: IrStatementOrigin? = null,
- superQualifierSymbol: IrClassSymbol? = null
+ irSuperQualifier: IrClass? = null
) : this(
- startOffset, endOffset, type, symbol, descriptor, descriptor.typeParametersCount,
- descriptor.valueParameters.size, origin, superQualifierSymbol
+ startOffset, endOffset, type, target, descriptor, descriptor.typeParametersCount,
+ descriptor.valueParameters.size, origin, irSuperQualifier
)
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrFunctionSymbol,
+ target: IrFunction,
descriptor: FunctionDescriptor,
typeArgumentsCount: Int,
origin: IrStatementOrigin? = null,
- superQualifierSymbol: IrClassSymbol? = null
+ irSuperQualifier: IrClass? = null
) : this(
- startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount,
- descriptor.valueParameters.size, origin, superQualifierSymbol
+ startOffset, endOffset, type, target, descriptor, typeArgumentsCount,
+ descriptor.valueParameters.size, origin, irSuperQualifier
)
- constructor(startOffset: Int, endOffset: Int, type: IrType, symbol: IrFunctionSymbol) :
- this(startOffset, endOffset, type, symbol, symbol.descriptor)
+ constructor(startOffset: Int, endOffset: Int, type: IrType, target: IrFunction) :
+ this(startOffset, endOffset, type, target, target.descriptor)
- override val superQualifier: ClassDescriptor? = superQualifierSymbol?.descriptor
+ override val superQualifier: ClassDescriptor? = irSuperQualifier?.descriptor
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitCall(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt
index cf126d7..65917cc 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrClassReferenceImpl.kt
@@ -17,8 +17,9 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrClassifier
import org.jetbrains.kotlin.ir.expressions.IrClassReference
-import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -26,16 +27,16 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrClassifierSymbol,
+ target: IrClassifier,
override val classType: IrType
) :
- IrTerminalDeclarationReferenceBase<IrClassifierSymbol, ClassifierDescriptor>(
+ IrTerminalDeclarationReferenceBase<IrClassifier, ClassifierDescriptor>(
startOffset, endOffset, type,
- symbol, symbol.descriptor
+ target, target.descriptor
),
IrClassReference {
- override val descriptor: ClassifierDescriptor get() = symbol.descriptor
+ override val descriptor: ClassifierDescriptor get() = target.descriptor
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitClassReference(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt
index 8145db6..549576b 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt
@@ -7,9 +7,9 @@
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
+import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -18,7 +18,7 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrConstructorSymbol,
+ override val target: IrConstructor,
override val descriptor: ClassConstructorDescriptor,
typeArgumentsCount: Int,
override val constructorTypeArgumentsCount: Int,
@@ -36,7 +36,7 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- constructorSymbol: IrConstructorSymbol,
+ target: IrConstructor,
constructorDescriptor: ClassConstructorDescriptor,
origin: IrStatementOrigin? = null
): IrConstructorCallImpl {
@@ -47,7 +47,7 @@
return IrConstructorCallImpl(
startOffset, endOffset,
type,
- constructorSymbol,
+ target,
constructorDescriptor,
totalTypeParametersCount,
totalTypeParametersCount - classTypeParametersCount,
@@ -60,30 +60,29 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- constructorSymbol: IrConstructorSymbol,
+ target: IrConstructor,
origin: IrStatementOrigin? = null
): IrConstructorCallImpl =
- fromSubstitutedDescriptor(startOffset, endOffset, type, constructorSymbol, constructorSymbol.descriptor, origin)
+ fromSubstitutedDescriptor(startOffset, endOffset, type, target, target.descriptor, origin)
fun fromSymbolOwner(
startOffset: Int,
endOffset: Int,
type: IrType,
- constructorSymbol: IrConstructorSymbol,
+ target: IrConstructor,
origin: IrStatementOrigin? = null
): IrConstructorCallImpl {
- val constructor = constructorSymbol.owner
- val constructedClass = constructor.parentAsClass
+ val constructedClass = target.parentAsClass
val classTypeParametersCount = constructedClass.typeParameters.size
- val constructorTypeParametersCount = constructor.typeParameters.size
+ val constructorTypeParametersCount = target.typeParameters.size
val totalTypeParametersCount = classTypeParametersCount + constructorTypeParametersCount
- val valueParametersCount = constructor.valueParameters.size
+ val valueParametersCount = target.valueParameters.size
return IrConstructorCallImpl(
startOffset, endOffset,
type,
- constructorSymbol,
- constructorSymbol.descriptor,
+ target,
+ target.descriptor,
totalTypeParametersCount,
constructorTypeParametersCount,
valueParametersCount,
@@ -93,10 +92,10 @@
fun fromSymbolOwner(
type: IrType,
- constructorSymbol: IrConstructorSymbol,
+ target: IrConstructor,
origin: IrStatementOrigin? = null
) =
- fromSymbolOwner(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, constructorSymbol, origin)
+ fromSymbolOwner(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, target, origin)
}
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt
index c4de372..bcd9a1e 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDeclarationReferenceBase.kt
@@ -17,15 +17,15 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrType
-abstract class IrDeclarationReferenceBase<out S : IrSymbol, out D : DeclarationDescriptor>(
+abstract class IrDeclarationReferenceBase<out S : IrSymbolOwner, out D : DeclarationDescriptor>(
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: S,
+ override val target: S,
override val descriptor: D
) :
IrExpressionBase(startOffset, endOffset, type),
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt
index 001548b..dae93f1 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt
@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.expressions.IrDelegatingConstructorCall
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -27,7 +27,7 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrConstructorSymbol,
+ override val target: IrConstructor,
override val descriptor: ClassConstructorDescriptor,
typeArgumentsCount: Int,
valueArgumentsCount: Int
@@ -45,25 +45,25 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrConstructorSymbol,
+ target: IrConstructor,
descriptor: ClassConstructorDescriptor
- ) : this(startOffset, endOffset, type, symbol, descriptor, descriptor.typeParametersCount, descriptor.valueParameters.size)
+ ) : this(startOffset, endOffset, type, target, descriptor, descriptor.typeParametersCount, descriptor.valueParameters.size)
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrConstructorSymbol
- ) : this(startOffset, endOffset, type, symbol, symbol.descriptor)
+ target: IrConstructor
+ ) : this(startOffset, endOffset, type, target, target.descriptor)
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrConstructorSymbol,
+ target: IrConstructor,
descriptor: ClassConstructorDescriptor,
typeArgumentsCount: Int
- ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, descriptor.valueParameters.size)
+ ) : this(startOffset, endOffset, type, target, descriptor, typeArgumentsCount, descriptor.valueParameters.size)
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitDelegatingConstructorCall(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt
index ba7c70d..439c60e 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrEnumConstructorCallImpl.kt
@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -27,7 +27,7 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrConstructorSymbol,
+ override val target: IrConstructor,
typeArgumentsCount: Int,
valueArgumentsCount: Int
) :
@@ -44,18 +44,18 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrConstructorSymbol
- ) : this(startOffset, endOffset, type, symbol, symbol.descriptor.typeParametersCount, symbol.descriptor.valueParameters.size)
+ target: IrConstructor
+ ) : this(startOffset, endOffset, type, target, target.descriptor.typeParametersCount, target.descriptor.valueParameters.size)
constructor(
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrConstructorSymbol,
+ target: IrConstructor,
typeArgumentsCount: Int
- ) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size)
+ ) : this(startOffset, endOffset, type, target, typeArgumentsCount, target.descriptor.valueParameters.size)
- override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor
+ override val descriptor: ClassConstructorDescriptor get() = target.descriptor
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitEnumConstructorCall(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFieldExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFieldExpressionBase.kt
index 7800d7a..70d91fa 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFieldExpressionBase.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFieldExpressionBase.kt
@@ -18,25 +18,25 @@
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrField
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFieldAccessExpression
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.types.IrType
abstract class IrFieldExpressionBase(
startOffset: Int, endOffset: Int,
- override val symbol: IrFieldSymbol,
+ override val target: IrField,
type: IrType,
override val origin: IrStatementOrigin? = null,
- override val superQualifierSymbol: IrClassSymbol?
+ override val irSuperQualifier: IrClass?
) :
IrExpressionBase(startOffset, endOffset, type),
IrFieldAccessExpression {
- override val descriptor: PropertyDescriptor get() = symbol.descriptor
- override val superQualifier: ClassDescriptor? get() = superQualifierSymbol?.descriptor
+ override val descriptor: PropertyDescriptor get() = target.descriptor
+ override val superQualifier: ClassDescriptor? get() = irSuperQualifier?.descriptor
final override var receiver: IrExpression? = null
}
\ No newline at end of file
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt
index 9af008f..797c469 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt
@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -27,7 +27,7 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrFunctionSymbol,
+ override val target: IrFunction,
override val descriptor: FunctionDescriptor,
typeArgumentsCount: Int,
valueArgumentsCount: Int,
@@ -47,11 +47,11 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrFunctionSymbol,
+ target: IrFunction,
descriptor: FunctionDescriptor,
typeArgumentsCount: Int,
origin: IrStatementOrigin? = null
- ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, descriptor.valueParameters.size, origin)
+ ) : this(startOffset, endOffset, type, target, descriptor, typeArgumentsCount, descriptor.valueParameters.size, origin)
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitFunctionReference(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt
index 359e3ed..2535abc 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt
@@ -17,8 +17,8 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.ClassDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
-import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -26,9 +26,9 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrEnumEntrySymbol
+ target: IrEnumEntry
) :
- IrTerminalDeclarationReferenceBase<IrEnumEntrySymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor),
+ IrTerminalDeclarationReferenceBase<IrEnumEntry, ClassDescriptor>(startOffset, endOffset, type, target, target.descriptor),
IrGetEnumValue {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetFieldImpl.kt
index 7a4edd9..05d437d 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetFieldImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetFieldImpl.kt
@@ -16,11 +16,11 @@
package org.jetbrains.kotlin.ir.expressions.impl
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrField
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrGetField
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -28,22 +28,22 @@
class IrGetFieldImpl(
startOffset: Int,
endOffset: Int,
- symbol: IrFieldSymbol,
+ target: IrField,
type: IrType,
origin: IrStatementOrigin? = null,
- superQualifierSymbol: IrClassSymbol? = null
+ irSuperQualifier: IrClass? = null
) :
- IrFieldExpressionBase(startOffset, endOffset, symbol, type, origin, superQualifierSymbol),
+ IrFieldExpressionBase(startOffset, endOffset, target, type, origin, irSuperQualifier),
IrGetField {
constructor(
startOffset: Int, endOffset: Int,
- symbol: IrFieldSymbol,
+ target: IrField,
type: IrType,
receiver: IrExpression?,
origin: IrStatementOrigin? = null,
- superQualifierSymbol: IrClassSymbol? = null
- ) : this(startOffset, endOffset, symbol, type, origin, superQualifierSymbol) {
+ irSuperQualifier: IrClass? = null
+ ) : this(startOffset, endOffset, target, type, origin, irSuperQualifier) {
this.receiver = receiver
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt
index 24f715a..d0b3f4c 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetObjectValueImpl.kt
@@ -17,8 +17,8 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.ClassDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.expressions.IrGetObjectValue
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -26,9 +26,9 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrClassSymbol
+ target: IrClass
) :
- IrTerminalDeclarationReferenceBase<IrClassSymbol, ClassDescriptor>(startOffset, endOffset, type, symbol, symbol.descriptor),
+ IrTerminalDeclarationReferenceBase<IrClass, ClassDescriptor>(startOffset, endOffset, type, target, target.descriptor),
IrGetObjectValue {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetValueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetValueImpl.kt
index 458c4ab..2ef1114 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetValueImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetValueImpl.kt
@@ -6,9 +6,9 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.ValueDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrValueDeclaration
import org.jetbrains.kotlin.ir.expressions.IrGetValue
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -16,28 +16,28 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrValueSymbol,
+ target: IrValueDeclaration,
override val origin: IrStatementOrigin? = null
) :
- IrTerminalDeclarationReferenceBase<IrValueSymbol, ValueDescriptor>(
+ IrTerminalDeclarationReferenceBase<IrValueDeclaration, ValueDescriptor>(
startOffset,
endOffset,
type,
- symbol,
- symbol.descriptor
+ target,
+ target.descriptor
),
IrGetValue {
constructor(
startOffset: Int,
endOffset: Int,
- symbol: IrValueSymbol,
+ target: IrValueDeclaration,
origin: IrStatementOrigin? = null
- ) : this(startOffset, endOffset, symbol.owner.type, symbol, origin)
+ ) : this(startOffset, endOffset, target.type, target, origin)
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitGetValue(this, data)
override fun copy(): IrGetValue =
- IrGetValueImpl(startOffset, endOffset, type, symbol, origin)
+ IrGetValueImpl(startOffset, endOffset, type, target, origin)
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt
index f25f014..09091b8 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrInstanceInitializerCallImpl.kt
@@ -17,21 +17,21 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.ClassDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.expressions.IrInstanceInitializerCall
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
class IrInstanceInitializerCallImpl(
startOffset: Int,
endOffset: Int,
- override val classSymbol: IrClassSymbol,
+ override val irClass: IrClass,
type: IrType
) :
IrTerminalExpressionBase(startOffset, endOffset, type),
IrInstanceInitializerCall {
- override val classDescriptor: ClassDescriptor get() = classSymbol.descriptor
+ override val classDescriptor: ClassDescriptor get() = irClass.descriptor
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitInstanceInitializerCall(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLocalDelegatedPropertyReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLocalDelegatedPropertyReferenceImpl.kt
index b3fd9e1..c82dbc5 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLocalDelegatedPropertyReferenceImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLocalDelegatedPropertyReferenceImpl.kt
@@ -17,11 +17,11 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
+import org.jetbrains.kotlin.ir.declarations.IrLocalDelegatedProperty
+import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
+import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrLocalDelegatedPropertyReference
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -29,17 +29,17 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrLocalDelegatedPropertySymbol,
- override val delegate: IrVariableSymbol,
- override val getter: IrSimpleFunctionSymbol,
- override val setter: IrSimpleFunctionSymbol?,
+ override val target: IrLocalDelegatedProperty,
+ override val delegate: IrVariable,
+ override val getter: IrSimpleFunction,
+ override val setter: IrSimpleFunction?,
origin: IrStatementOrigin? = null
) :
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, 0, origin),
IrLocalDelegatedPropertyReference {
override val descriptor: VariableDescriptorWithAccessors
- get() = symbol.descriptor
+ get() = target.descriptor
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitLocalDelegatedPropertyReference(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt
index 17cb397..cfd2b9e 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt
@@ -17,11 +17,11 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrField
+import org.jetbrains.kotlin.ir.declarations.IrProperty
+import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
-import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
-import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrPropertySymbolImpl
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -30,12 +30,12 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrPropertySymbol,
+ override val target: IrProperty,
override val descriptor: PropertyDescriptor,
typeArgumentsCount: Int,
- override val field: IrFieldSymbol?,
- override val getter: IrSimpleFunctionSymbol?,
- override val setter: IrSimpleFunctionSymbol?,
+ override val field: IrField?,
+ override val getter: IrSimpleFunction?,
+ override val setter: IrSimpleFunction?,
origin: IrStatementOrigin? = null
) :
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, typeArgumentsCount, origin),
@@ -45,15 +45,15 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrPropertySymbol,
+ target: IrProperty,
typeArgumentsCount: Int,
- field: IrFieldSymbol?,
- getter: IrSimpleFunctionSymbol?,
- setter: IrSimpleFunctionSymbol?,
+ field: IrField?,
+ getter: IrSimpleFunction?,
+ setter: IrSimpleFunction?,
origin: IrStatementOrigin? = null
) : this(
startOffset, endOffset, type,
- symbol, symbol.descriptor,
+ target, target.descriptor,
typeArgumentsCount, field, getter, setter, origin
)
@@ -64,9 +64,9 @@
type: IrType,
descriptor: PropertyDescriptor,
typeArgumentsCount: Int,
- field: IrFieldSymbol?,
- getter: IrSimpleFunctionSymbol?,
- setter: IrSimpleFunctionSymbol?,
+ field: IrField?,
+ getter: IrSimpleFunction?,
+ setter: IrSimpleFunction?,
origin: IrStatementOrigin? = null
) : this(
startOffset, endOffset, type,
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt
index 04e669f..7214ae5 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt
@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrReturnTarget
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrReturn
-import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -28,13 +28,13 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val returnTargetSymbol: IrReturnTargetSymbol,
+ override val irReturnTarget: IrReturnTarget,
override var value: IrExpression
) :
IrExpressionBase(startOffset, endOffset, type),
IrReturn {
- override val returnTarget: FunctionDescriptor get() = returnTargetSymbol.descriptor
+ override val returnTarget: FunctionDescriptor get() = irReturnTarget.descriptor
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitReturn(this, data)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetFieldImpl.kt
index b3fe569..ec1fba5 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetFieldImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetFieldImpl.kt
@@ -16,11 +16,11 @@
package org.jetbrains.kotlin.ir.expressions.impl
+import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrField
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSetField
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -28,29 +28,29 @@
class IrSetFieldImpl(
startOffset: Int,
endOffset: Int,
- symbol: IrFieldSymbol,
+ target: IrField,
type: IrType,
origin: IrStatementOrigin? = null,
- superQualifierSymbol: IrClassSymbol? = null
+ irSuperQualifier: IrClass? = null
) :
IrFieldExpressionBase(
startOffset, endOffset,
- symbol,
+ target,
type,
origin,
- superQualifierSymbol
+ irSuperQualifier
),
IrSetField {
constructor(
startOffset: Int, endOffset: Int,
- symbol: IrFieldSymbol,
+ target: IrField,
receiver: IrExpression?,
value: IrExpression,
type: IrType,
origin: IrStatementOrigin? = null,
- superQualifierSymbol: IrClassSymbol? = null
- ) : this(startOffset, endOffset, symbol, type, origin, superQualifierSymbol) {
+ irSuperQualifier: IrClass? = null
+ ) : this(startOffset, endOffset, target, type, origin, irSuperQualifier) {
this.receiver = receiver
this.value = value
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt
index ec1ae7f..f0ef2cf3 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.VariableDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
-import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -29,7 +29,7 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- override val symbol: IrVariableSymbol,
+ override val target: IrVariable,
override val origin: IrStatementOrigin?
) :
IrExpressionBase(startOffset, endOffset, type),
@@ -39,14 +39,14 @@
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: IrVariableSymbol,
+ target: IrVariable,
value: IrExpression,
origin: IrStatementOrigin?
- ) : this(startOffset, endOffset, type, symbol, origin) {
+ ) : this(startOffset, endOffset, type, target, origin) {
this.value = value
}
- override val descriptor: VariableDescriptor get() = symbol.descriptor
+ override val descriptor: VariableDescriptor get() = target.descriptor
override lateinit var value: IrExpression
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt
index cded755..5b05185 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalDeclarationReferenceBase.kt
@@ -17,20 +17,20 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
-import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
-abstract class IrTerminalDeclarationReferenceBase<out S : IrSymbol, out D : DeclarationDescriptor>(
+abstract class IrTerminalDeclarationReferenceBase<out S : IrSymbolOwner, out D : DeclarationDescriptor>(
startOffset: Int,
endOffset: Int,
type: IrType,
- symbol: S,
+ target: S,
descriptor: D
) :
- IrDeclarationReferenceBase<S, D>(startOffset, endOffset, type, symbol, descriptor),
+ IrDeclarationReferenceBase<S, D>(startOffset, endOffset, type, target, descriptor),
IrDeclarationReference {
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/IrSymbol.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/IrSymbol.kt
index db4ca1c..13cedf4 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/IrSymbol.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/IrSymbol.kt
@@ -21,7 +21,6 @@
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
import org.jetbrains.kotlin.ir.util.IrSymbolVisitor
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
-import org.jetbrains.kotlin.types.model.TypeParameterMarker
interface IrSymbol : IrSymbolOwner {
val owner: IrSymbolOwner
@@ -86,9 +85,11 @@
}
interface IrClassifierSymbol :
- IrSymbol, TypeConstructorMarker {
+ IrSymbol, TypeConstructorMarker,
+ IrClassifier {
override val descriptor: ClassifierDescriptor
+ override val owner: IrClassifier
override fun <D, R> accept(visitor: IrSymbolVisitor<R, D>, data: D): R =
visitor.visitClassifierSymbol(this, data)
@@ -103,7 +104,7 @@
}
interface IrTypeParameterSymbol :
- IrClassifierSymbol, IrBindableSymbol<TypeParameterDescriptor, IrTypeParameter>, TypeParameterMarker,
+ IrClassifierSymbol, IrBindableSymbol<TypeParameterDescriptor, IrTypeParameter>,
IrTypeParameter {
override fun <D, R> accept(visitor: IrSymbolVisitor<R, D>, data: D): R =
@@ -111,7 +112,7 @@
}
interface IrValueSymbol :
- IrSymbol {
+ IrSymbol, IrValueDeclaration {
override val descriptor: ValueDescriptor
override val owner: IrValueDeclaration
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt
index a38f3cb..3a26e37 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt
@@ -97,7 +97,7 @@
class IrAnonymousInitializerSymbolImpl(descriptor: ClassDescriptor) :
IrBindableSymbolBase<ClassDescriptor, IrAnonymousInitializer>(descriptor),
IrAnonymousInitializerSymbol, IrAnonymousInitializer {
- constructor(irClassSymbol: IrClassSymbol) : this(irClassSymbol.descriptor) {}
+ constructor(irClass: IrClass) : this(irClass.descriptor) {}
override val symbol get() = this
override val startOffset get() = owner.startOffset
override val endOffset get() = owner.endOffset
@@ -181,7 +181,7 @@
override val isFinal get() = owner.isFinal
override val isExternal get() = owner.isExternal
override val isStatic get() = owner.isStatic
- override val overriddenSymbols get() = owner.overriddenSymbols
+ override val overridden get() = owner.overridden
override val visibility get() = owner.visibility
override var parent get() = owner.parent; set(value) { owner.parent = value }
@@ -281,7 +281,7 @@
override val visibility get() = owner.visibility
override val typeParameters get() = owner.typeParameters
override val valueParameters get() = owner.valueParameters
- override val overriddenSymbols get() = owner.overriddenSymbols
+ override val overridden get() = owner.overridden
override val isTailrec get() = owner.isTailrec
override val isSuspend get() = owner.isSuspend
override val isInline get() = owner.isInline
@@ -338,7 +338,7 @@
override val startOffset get() = owner.startOffset
override val endOffset get() = owner.endOffset
override val type get() = owner.type
- override val inlineFunctionSymbol get() = owner.inlineFunctionSymbol
+ override val inlineFunction get() = owner.inlineFunction
override val statements get() = owner.statements
override val origin get() = owner.origin
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt
index 0e8db66..9cd6d77 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt
@@ -7,7 +7,6 @@
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.PrimitiveType
-import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
@@ -97,37 +96,37 @@
private fun getTypeParameters(typeConstructor: TypeConstructorMarker): List<IrTypeParameter> {
return when (typeConstructor) {
- is IrTypeParameterSymbol -> emptyList()
- is IrClassSymbol -> typeConstructor.owner.typeParameters
+ is IrTypeParameter -> emptyList()
+ is IrClass -> typeConstructor.typeParameters
else -> error("unsupported type constructor")
}
}
override fun TypeConstructorMarker.parametersCount() = getTypeParameters(this).size
- override fun TypeConstructorMarker.getParameter(index: Int) = getTypeParameters(this)[index].symbol
+ override fun TypeConstructorMarker.getParameter(index: Int) = getTypeParameters(this)[index]
override fun TypeConstructorMarker.supertypes(): Collection<KotlinTypeMarker> {
return when (this) {
- is IrClassSymbol -> owner.superTypes
- is IrTypeParameterSymbol -> owner.superTypes
+ is IrClass -> superTypes
+ is IrTypeParameter -> superTypes
else -> error("unsupported type constructor")
}
}
override fun TypeConstructorMarker.isIntersection() = false
- override fun TypeConstructorMarker.isClassTypeConstructor() = this is IrClassSymbol
+ override fun TypeConstructorMarker.isClassTypeConstructor() = this is IrClass
- override fun TypeParameterMarker.getVariance() = (this as IrTypeParameterSymbol).owner.variance.convertVariance()
+ override fun TypeParameterMarker.getVariance() = (this as IrTypeParameter).variance.convertVariance()
- private fun getSuperTypes(typeParameterMarker: TypeParameterMarker) = (typeParameterMarker as IrTypeParameterSymbol).owner.superTypes
+ private fun getSuperTypes(typeParameterMarker: TypeParameterMarker) = (typeParameterMarker as IrTypeParameter).superTypes
override fun TypeParameterMarker.upperBoundCount() = getSuperTypes(this).size
override fun TypeParameterMarker.getUpperBound(index: Int) = getSuperTypes(this)[index] as KotlinTypeMarker
- override fun TypeParameterMarker.getTypeConstructor() = this as IrTypeParameterSymbol
+ override fun TypeParameterMarker.getTypeConstructor() = this as IrTypeParameter
override fun isEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker) = FqNameEqualityChecker.areEqual(
c1 as IrClassifierSymbol, c2 as IrClassifierSymbol
@@ -136,8 +135,7 @@
override fun TypeConstructorMarker.isDenotable() = true
override fun TypeConstructorMarker.isCommonFinalClassConstructor(): Boolean {
- val classSymbol = this as? IrClassSymbol ?: return false
- return classSymbol.owner.run { modality == Modality.FINAL && kind != ClassKind.ENUM_CLASS && kind != ClassKind.ANNOTATION_CLASS }
+ return this is IrClass && modality == Modality.FINAL && kind != ClassKind.ENUM_CLASS && kind != ClassKind.ANNOTATION_CLASS
}
/*
@@ -191,10 +189,10 @@
override fun SimpleTypeMarker.asArgumentList() = this as IrSimpleType
override fun TypeConstructorMarker.isAnyConstructor(): Boolean =
- this is IrClassSymbol && isClassWithFqName(KotlinBuiltIns.FQ_NAMES.any)
+ this is IrClass && isClassWithFqName(KotlinBuiltIns.FQ_NAMES.any)
override fun TypeConstructorMarker.isNothingConstructor(): Boolean =
- this is IrClassSymbol && isClassWithFqName(KotlinBuiltIns.FQ_NAMES.nothing)
+ this is IrClass && isClassWithFqName(KotlinBuiltIns.FQ_NAMES.nothing)
override fun SimpleTypeMarker.isSingleClassifierType() = true
@@ -214,7 +212,7 @@
constructor: TypeConstructorMarker,
arguments: List<TypeArgumentMarker>,
nullable: Boolean
- ): SimpleTypeMarker = IrSimpleTypeImpl(constructor as IrClassifierSymbol, nullable, arguments.map { it as IrTypeArgument }, emptyList())
+ ): SimpleTypeMarker = IrSimpleTypeImpl((constructor as IrClassifier).symbol, nullable, arguments.map { it as IrTypeArgument }, emptyList())
private fun TypeVariance.convertVariance(): Variance {
return when (this) {
@@ -277,10 +275,7 @@
(this as IrType).isArray() || isNullableArray()
override fun TypeConstructorMarker.isFinalClassOrEnumEntryOrAnnotationClassConstructor(): Boolean {
- val symbol = this as IrClassifierSymbol
- return symbol is IrClassSymbol && symbol.owner.let {
- it.modality == Modality.FINAL && !it.isEnumClass
- }
+ return this is IrClass && modality == Modality.FINAL && !isEnumClass
}
override fun KotlinTypeMarker.hasAnnotation(fqName: FqName): Boolean =
@@ -290,22 +285,22 @@
override fun KotlinTypeMarker.getAnnotationFirstArgumentValue(fqName: FqName): Any? =
(this as? IrType)?.annotations?.firstOrNull { annotation ->
- annotation.symbol.owner.parentAsClass.descriptor.fqNameSafe == fqName
+ annotation.target.parentAsClass.descriptor.fqNameSafe == fqName
}?.run {
if (valueArgumentsCount > 0) (getValueArgument(0) as? IrConst<*>)?.value else null
}
override fun TypeConstructorMarker.getTypeParameterClassifier(): TypeParameterMarker? =
- this as? IrTypeParameterSymbol
+ this as? IrTypeParameter
override fun TypeConstructorMarker.isInlineClass(): Boolean =
- (this as? IrClassSymbol)?.owner?.isInline == true
+ (this as? IrClass)?.isInline == true
override fun TypeParameterMarker.getRepresentativeUpperBound(): KotlinTypeMarker =
- (this as IrTypeParameterSymbol).owner.superTypes.firstOrNull {
+ (this as IrTypeParameter).superTypes.firstOrNull {
val irClass = it.classOrNull?.owner ?: return@firstOrNull false
irClass.kind != ClassKind.INTERFACE && irClass.kind != ClassKind.ANNOTATION_CLASS
- } ?: owner.superTypes.first()
+ } ?: superTypes.first()
override fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker? {
// Code in inlineClassesUtils.kt loads the property with the same name from the scope of the substituted type and takes its type.
@@ -324,16 +319,16 @@
override fun TypeConstructorMarker.getPrimitiveType(): PrimitiveType? {
// TODO: get rid of descriptor
- return KotlinBuiltIns.getPrimitiveType((this as IrClassifierSymbol).descriptor as ClassDescriptor)
+ return KotlinBuiltIns.getPrimitiveType((this as IrClass).descriptor)
}
override fun TypeConstructorMarker.getPrimitiveArrayType(): PrimitiveType? {
// TODO: get rid of descriptor
- return KotlinBuiltIns.getPrimitiveArrayType((this as IrClassifierSymbol).descriptor as ClassDescriptor)
+ return KotlinBuiltIns.getPrimitiveArrayType((this as IrClass).descriptor)
}
override fun TypeConstructorMarker.isUnderKotlinPackage(): Boolean {
- var declaration: IrDeclaration = (this as? IrClassifierSymbol)?.owner as? IrClass ?: return false
+ var declaration: IrDeclaration = this as? IrClass ?: return false
while (true) {
val parent = declaration.parent
if (parent is IrPackageFragment) {
@@ -344,13 +339,13 @@
}
override fun TypeConstructorMarker.getClassFqNameUnsafe(): FqNameUnsafe? =
- (this as IrClassSymbol).owner.fqNameWhenAvailable?.toUnsafe()
+ (this as IrClass).fqNameWhenAvailable?.toUnsafe()
override fun TypeParameterMarker.getName(): Name =
- (this as IrTypeParameterSymbol).owner.name
+ (this as IrTypeParameter).name
override fun TypeParameterMarker.isReified(): Boolean =
- (this as IrTypeParameterSymbol).owner.isReified
+ (this as IrTypeParameter).isReified
override fun KotlinTypeMarker.isInterfaceOrAnnotationClass(): Boolean {
val irClass = (this as IrType).classOrNull?.owner
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt
index 6259f8e..6a2112a 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.ir.types
+import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.symbols.FqNameEqualityChecker
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
@@ -22,12 +23,14 @@
else -> emptyList<IrType>()
}
-fun IrClassifierSymbol.isSubtypeOfClass(superClass: IrClassSymbol): Boolean {
- if (FqNameEqualityChecker.areEqual(this, superClass)) return true
+fun IrClass.isSubtypeOfClass(superClass: IrClass): Boolean = (symbol as IrClassifierSymbol).isSubtypeOfClass(superClass)
+
+fun IrClassifierSymbol.isSubtypeOfClass(superClass: IrClass): Boolean {
+ if (FqNameEqualityChecker.areEqual(this, superClass.symbol)) return true
return superTypes().any { it.isSubtypeOfClass(superClass) }
}
-fun IrType.isSubtypeOfClass(superClass: IrClassSymbol): Boolean {
+fun IrType.isSubtypeOfClass(superClass: IrClass): Boolean {
if (this !is IrSimpleType) return false
return classifier.isSubtypeOfClass(superClass)
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt
index 230342b..834ffe4 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt
@@ -8,8 +8,8 @@
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.ir.declarations.IrClass
+import org.jetbrains.kotlin.ir.declarations.IrClassifier
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
-import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.resolve.DescriptorUtils
@@ -21,11 +21,12 @@
private fun IrType.isClassType(fqName: FqNameUnsafe, hasQuestionMark: Boolean? = null): Boolean {
if (this !is IrSimpleType) return false
if (hasQuestionMark != null && this.hasQuestionMark != hasQuestionMark) return false
- return classifier.isClassWithFqName(fqName)
+ return classifier.owner.isClassWithFqName(fqName)
}
-fun IrClassifierSymbol.isClassWithFqName(fqName: FqNameUnsafe): Boolean =
- this is IrClassSymbol && classFqNameEquals(this, fqName)
+fun IrClassifier.isClassWithFqName(fqName: FqNameUnsafe): Boolean =
+ this is IrClass && isClassWithFqName(fqName)
+fun IrClass.isClassWithFqName(fqName: FqNameUnsafe): Boolean = classFqNameEquals(this, fqName)
private fun classFqNameEquals(symbol: IrClassSymbol, fqName: FqNameUnsafe): Boolean =
if (symbol.isBound) classFqNameEquals(symbol.owner, fqName) else classFqNameEquals(symbol.descriptor, fqName)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt
index c618d76..f583b7d 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt
@@ -73,9 +73,9 @@
fun IrType.getClass(): IrClass? =
classOrNull?.owner
-fun IrClassSymbol.createType(hasQuestionMark: Boolean, arguments: List<IrTypeArgument>): IrSimpleType =
+fun IrClass.createType(hasQuestionMark: Boolean, arguments: List<IrTypeArgument>): IrSimpleType =
IrSimpleTypeImpl(
- this,
+ this.symbol,
hasQuestionMark,
arguments,
emptyList()
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/AdditionalIrUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/AdditionalIrUtils.kt
index c0ca56a..d58fb6d 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/AdditionalIrUtils.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/AdditionalIrUtils.kt
@@ -68,8 +68,8 @@
fun IrSimpleFunction.overrides(other: IrSimpleFunction): Boolean {
if (this == other) return true
- this.overriddenSymbols.forEach {
- if (it.owner.overrides(other)) {
+ this.overridden.forEach {
+ if (it.overrides(other)) {
return true
}
}
@@ -78,7 +78,7 @@
}
private val IrConstructorCall.annotationClass
- get() = this.symbol.owner.constructedClass
+ get() = this.target.constructedClass
fun List<IrConstructorCall>.hasAnnotation(fqName: FqName): Boolean =
any { it.annotationClass.fqNameWhenAvailable == fqName }
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt
index 02810dc..f45f1b2 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt
@@ -11,6 +11,7 @@
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
+import org.jetbrains.kotlin.ir.declarations.IrClassifier
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.impl.*
@@ -109,7 +110,7 @@
IrClassReferenceImpl(
startOffset, endOffset,
constantValue.getType(moduleDescriptor).toIrType(),
- classifierDescriptor.defaultType.toIrType().classifierOrFail,
+ classifierDescriptor.defaultType.toIrType().classifierOrFail as IrClassifier,
classifierKtType.toIrType()
)
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt
index f6c9946..a005b36 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt
@@ -38,7 +38,9 @@
val symbolRemapper = DeepCopySymbolRemapper(descriptorRemapper)
acceptVoid(symbolRemapper)
val typeRemapper = DeepCopyTypeRemapper(symbolRemapper)
- return transform(DeepCopyIrTreeWithSymbols(symbolRemapper, typeRemapper), null).patchDeclarationParents(initialParent) as T
+ return transform(DeepCopyIrTreeWithSymbols(symbolRemapper, typeRemapper), null)
+ .desymbolize()
+ .patchDeclarationParents(initialParent) as T
}
interface SymbolRenamer {
@@ -155,8 +157,8 @@
declaration.isTailrec,
declaration.isSuspend
).apply {
- declaration.overriddenSymbols.mapTo(overriddenSymbols) {
- symbolRemapper.getReferencedFunction(it) as IrSimpleFunctionSymbol
+ declaration.overridden.mapTo(overridden) {
+ (symbolRemapper.getReferencedFunction(it.symbol) as IrSimpleFunctionSymbol)
}
transformFunctionChildren(declaration)
}
@@ -229,8 +231,8 @@
declaration.isStatic
).apply {
transformAnnotations(declaration)
- declaration.overriddenSymbols.mapTo(overriddenSymbols) {
- symbolRemapper.getReferencedField(it)
+ declaration.overridden.mapTo(overridden) {
+ symbolRemapper.getReferencedField(it.symbol)
}
initializer = declaration.initializer?.transform()
}
@@ -389,7 +391,7 @@
symbolRemapper.getReferencedReturnableBlock(expression.symbol),
mapStatementOrigin(expression.origin),
expression.statements.map { it.transform() },
- expression.inlineFunctionSymbol
+ expression.inlineFunction
).copyAttributes(expression)
else
IrBlockImpl(
@@ -418,21 +420,21 @@
IrGetObjectValueImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedClass(expression.symbol)
+ symbolRemapper.getReferencedClass(expression.target.symbol)
).copyAttributes(expression)
override fun visitGetEnumValue(expression: IrGetEnumValue): IrGetEnumValue =
IrGetEnumValueImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedEnumEntry(expression.symbol)
+ symbolRemapper.getReferencedEnumEntry(expression.target.symbol)
).copyAttributes(expression)
override fun visitGetValue(expression: IrGetValue): IrGetValue =
IrGetValueImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedValue(expression.symbol),
+ symbolRemapper.getReferencedValue(expression.target.symbol),
mapStatementOrigin(expression.origin)
).copyAttributes(expression)
@@ -440,7 +442,7 @@
IrSetVariableImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedVariable(expression.symbol),
+ symbolRemapper.getReferencedVariable(expression.target.symbol),
expression.value.transform(),
mapStatementOrigin(expression.origin)
).copyAttributes(expression)
@@ -448,22 +450,22 @@
override fun visitGetField(expression: IrGetField): IrGetField =
IrGetFieldImpl(
expression.startOffset, expression.endOffset,
- symbolRemapper.getReferencedField(expression.symbol),
+ symbolRemapper.getReferencedField(expression.target.symbol),
expression.type.remapType(),
expression.receiver?.transform(),
mapStatementOrigin(expression.origin),
- symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
+ symbolRemapper.getReferencedClassOrNull(expression.irSuperQualifier?.symbol)
).copyAttributes(expression)
override fun visitSetField(expression: IrSetField): IrSetField =
IrSetFieldImpl(
expression.startOffset, expression.endOffset,
- symbolRemapper.getReferencedField(expression.symbol),
+ symbolRemapper.getReferencedField(expression.target.symbol),
expression.receiver?.transform(),
expression.value.transform(),
expression.type.remapType(),
mapStatementOrigin(expression.origin),
- symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
+ symbolRemapper.getReferencedClassOrNull(expression.irSuperQualifier?.symbol)
).copyAttributes(expression)
override fun visitCall(expression: IrCall): IrCall =
@@ -473,12 +475,12 @@
}
override fun visitConstructorCall(expression: IrConstructorCall): IrConstructorCall {
- val constructorSymbol = symbolRemapper.getReferencedConstructor(expression.symbol)
+ val constructor = symbolRemapper.getReferencedConstructor(expression.target.symbol)
return IrConstructorCallImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- constructorSymbol,
- constructorSymbol.descriptor,
+ constructor,
+ constructor.descriptor,
expression.typeArgumentsCount,
expression.constructorTypeArgumentsCount,
expression.valueArgumentsCount,
@@ -499,7 +501,7 @@
}
private fun shallowCopyCall(expression: IrCall): IrCall {
- val newCallee = symbolRemapper.getReferencedFunction(expression.symbol)
+ val newCallee = symbolRemapper.getReferencedFunction(expression.target.symbol)
return IrCallImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
@@ -508,7 +510,7 @@
expression.typeArgumentsCount,
expression.valueArgumentsCount,
mapStatementOrigin(expression.origin),
- symbolRemapper.getReferencedClassOrNull(expression.superQualifierSymbol)
+ symbolRemapper.getReferencedClassOrNull(expression.irSuperQualifier?.symbol)
).apply {
copyRemappedTypeArgumentsFrom(expression)
}.copyAttributes(expression)
@@ -528,7 +530,7 @@
}
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrDelegatingConstructorCall {
- val newConstructor = symbolRemapper.getReferencedConstructor(expression.symbol)
+ val newConstructor = symbolRemapper.getReferencedConstructor(expression.target.symbol)
return IrDelegatingConstructorCallImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
@@ -542,7 +544,7 @@
}
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrEnumConstructorCall {
- val newConstructor = symbolRemapper.getReferencedConstructor(expression.symbol)
+ val newConstructor = symbolRemapper.getReferencedConstructor(expression.target.symbol)
return IrEnumConstructorCallImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
@@ -562,12 +564,12 @@
).copyAttributes(expression)
override fun visitFunctionReference(expression: IrFunctionReference): IrFunctionReference {
- val symbol = symbolRemapper.getReferencedFunction(expression.symbol)
+ val target = symbolRemapper.getReferencedFunction(expression.target.symbol)
return IrFunctionReferenceImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbol,
- symbol.descriptor,
+ target,
+ target.descriptor,
expression.typeArgumentsCount,
expression.valueArgumentsCount,
mapStatementOrigin(expression.origin)
@@ -581,11 +583,11 @@
IrPropertyReferenceImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedProperty(expression.symbol),
+ symbolRemapper.getReferencedProperty(expression.target.symbol),
expression.typeArgumentsCount,
- expression.field?.let { symbolRemapper.getReferencedField(it) },
- expression.getter?.let { symbolRemapper.getReferencedSimpleFunction(it) },
- expression.setter?.let { symbolRemapper.getReferencedSimpleFunction(it) },
+ expression.field?.let { symbolRemapper.getReferencedField(it.symbol) },
+ expression.getter?.let { symbolRemapper.getReferencedSimpleFunction(it.symbol) },
+ expression.setter?.let { symbolRemapper.getReferencedSimpleFunction(it.symbol) },
mapStatementOrigin(expression.origin)
).apply {
copyRemappedTypeArgumentsFrom(expression)
@@ -596,10 +598,10 @@
IrLocalDelegatedPropertyReferenceImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedLocalDelegatedProperty(expression.symbol),
- symbolRemapper.getReferencedVariable(expression.delegate),
- symbolRemapper.getReferencedSimpleFunction(expression.getter),
- expression.setter?.let { symbolRemapper.getReferencedSimpleFunction(it) },
+ symbolRemapper.getReferencedLocalDelegatedProperty(expression.target.symbol),
+ symbolRemapper.getReferencedVariable(expression.delegate.symbol),
+ symbolRemapper.getReferencedSimpleFunction(expression.getter.symbol),
+ expression.setter?.let { symbolRemapper.getReferencedSimpleFunction(it.symbol) },
mapStatementOrigin(expression.origin)
).copyAttributes(expression)
@@ -615,14 +617,14 @@
IrClassReferenceImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedClassifier(expression.symbol),
+ symbolRemapper.getReferencedClassifier(expression.target.symbol),
expression.classType.remapType()
).copyAttributes(expression)
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall): IrInstanceInitializerCall =
IrInstanceInitializerCallImpl(
expression.startOffset, expression.endOffset,
- symbolRemapper.getReferencedClass(expression.classSymbol),
+ symbolRemapper.getReferencedClass(expression.irClass.symbol),
expression.type.remapType()
).copyAttributes(expression)
@@ -715,7 +717,7 @@
IrReturnImpl(
expression.startOffset, expression.endOffset,
expression.type.remapType(),
- symbolRemapper.getReferencedReturnTarget(expression.returnTargetSymbol),
+ symbolRemapper.getReferencedReturnTarget(expression.irReturnTarget.symbol),
expression.value.transform()
).copyAttributes(expression)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/Desymbolize.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/Desymbolize.kt
new file mode 100644
index 0000000..7c6b12a
--- /dev/null
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/Desymbolize.kt
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.ir.util
+
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.ir.IrElement
+import org.jetbrains.kotlin.ir.IrStatement
+import org.jetbrains.kotlin.ir.declarations.IrField
+import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
+import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
+import org.jetbrains.kotlin.ir.declarations.copyAttributes
+import org.jetbrains.kotlin.ir.expressions.*
+import org.jetbrains.kotlin.ir.expressions.impl.*
+import org.jetbrains.kotlin.ir.symbols.*
+import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
+
+fun IrElement.desymbolize(): IrElement = transform(DesymbolizeTransformer, null)
+
+object DesymbolizeTransformer : IrElementTransformerVoid() {
+ override fun visitField(declaration: IrField): IrStatement {
+ declaration.overridden.replaceAll {
+ if (it is IrFieldSymbol) it.owner else it
+ }
+ return super.visitField(declaration)
+ }
+
+ override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement {
+ declaration.overridden.replaceAll {
+ if (it is IrSimpleFunctionSymbol) it.owner else it
+ }
+ return super.visitSimpleFunction(declaration)
+ }
+
+ override fun visitClassReference(expression: IrClassReference): IrExpression {
+ val target = expression.target
+ val newExpression = if (target is IrClassifierSymbol)
+ IrClassReferenceImpl(
+ expression.startOffset, expression.endOffset,
+ expression.type,
+ target.owner,
+ expression.classType
+ )
+ else expression
+ return super.visitClassReference(newExpression)
+ }
+
+ override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
+ val target = expression.target
+ val newExpression = if (target is IrFunctionSymbol)
+ IrFunctionReferenceImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ target.owner,
+ expression.descriptor, expression.typeArgumentsCount, expression.valueArgumentsCount, expression.origin
+ ).apply {
+ copyTypeAndValueArgumentsFrom(expression)
+ copyAttributes(expression)
+ }
+ else expression
+ return super.visitFunctionReference(newExpression)
+ }
+
+ override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
+ val newExpression = IrPropertyReferenceImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ expression.target.desymbolizeLink(),
+ expression.descriptor, expression.typeArgumentsCount,
+ expression.field?.desymbolizeLink(),
+ expression.getter?.desymbolizeLink(),
+ expression.setter?.desymbolizeLink(),
+ expression.origin
+ ).apply {
+ copyTypeArgumentsFrom(expression)
+ dispatchReceiver = expression.dispatchReceiver
+ extensionReceiver = expression.extensionReceiver
+ copyAttributes(expression)
+ }
+ return super.visitPropertyReference(newExpression)
+ }
+
+ override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression {
+ val newExpression = IrLocalDelegatedPropertyReferenceImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ expression.target.desymbolizeLink(),
+ expression.delegate.desymbolizeLink(),
+ expression.getter.desymbolizeLink(),
+ expression.setter?.desymbolizeLink(),
+ expression.origin
+ ).apply {
+ copyAttributes(expression)
+ }
+ return super.visitLocalDelegatedPropertyReference(newExpression)
+ }
+
+ override fun visitGetField(expression: IrGetField): IrExpression {
+ val target = expression.target.desymbolizeLink()
+ val irSuperQualifier = expression.irSuperQualifier?.desymbolizeLink()
+ val newExpression = IrGetFieldImpl(
+ expression.startOffset, expression.endOffset,
+ target,
+ expression.type, expression.receiver, expression.origin,
+ irSuperQualifier
+ )
+ return super.visitGetField(newExpression)
+ }
+
+ override fun visitSetField(expression: IrSetField): IrExpression {
+ val newExpression = IrSetFieldImpl(
+ expression.startOffset, expression.endOffset,
+ expression.target.desymbolizeLink(),
+ expression.receiver, expression.value, expression.type, expression.origin,
+ expression.irSuperQualifier?.desymbolizeLink()
+ )
+ return super.visitSetField(newExpression)
+ }
+
+ override fun visitGetValue(expression: IrGetValue): IrExpression {
+ val target = expression.target
+ val newExpression = if (target is IrValueSymbol)
+ IrGetValueImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ target.owner,
+ expression.origin
+ )
+ else expression
+ return super.visitGetValue(newExpression)
+ }
+
+ override fun visitSetVariable(expression: IrSetVariable): IrExpression {
+ val target = expression.target
+ val newExpression = if (target is IrVariableSymbol)
+ IrSetVariableImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ target.owner,
+ expression.value, expression.origin
+ )
+ else expression
+ return super.visitSetVariable(newExpression)
+ }
+
+ override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
+ val target = expression.target
+ val newExpression = if (target is IrConstructorSymbol)
+ IrDelegatingConstructorCallImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ target.owner,
+ expression.descriptor, expression.typeArgumentsCount, expression.valueArgumentsCount
+ ).apply {
+ copyTypeAndValueArgumentsFrom(expression)
+ }
+ else expression
+ return super.visitDelegatingConstructorCall(newExpression)
+ }
+
+ override fun visitConstructorCall(expression: IrConstructorCall): IrExpression {
+ val target = expression.target
+ val newExpression = if (target is IrConstructorSymbol)
+ IrConstructorCallImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ target.owner,
+ expression.descriptor,
+ expression.typeArgumentsCount, expression.constructorTypeArgumentsCount, expression.valueArgumentsCount,
+ expression.origin
+ ).apply {
+ copyTypeAndValueArgumentsFrom(expression)
+ }
+ else expression
+ return super.visitConstructorCall(newExpression)
+ }
+
+ override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrExpression {
+ val target = expression.target
+ val newExpression = if (target is IrConstructorSymbol)
+ IrEnumConstructorCallImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ target.owner,
+ expression.typeArgumentsCount, expression.valueArgumentsCount
+ ).apply {
+ copyTypeAndValueArgumentsFrom(expression)
+ }
+ else expression
+ return super.visitEnumConstructorCall(newExpression)
+ }
+
+ override fun visitCall(expression: IrCall): IrExpression {
+ val newExpression = IrCallImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ expression.target.desymbolizeLink(),
+ expression.descriptor,
+ expression.typeArgumentsCount, expression.valueArgumentsCount, expression.origin,
+ expression.irSuperQualifier?.desymbolizeLink()
+ ).apply {
+ copyTypeAndValueArgumentsFrom(expression)
+ }
+ return super.visitCall(newExpression)
+ }
+
+ override fun visitReturn(expression: IrReturn): IrExpression {
+ val target = expression.irReturnTarget
+ val newExpression = if (target is IrReturnTargetSymbol)
+ IrReturnImpl(
+ expression.startOffset, expression.endOffset, expression.type,
+ target.owner,
+ expression.value
+ )
+ else expression
+ return super.visitReturn(newExpression)
+ }
+
+ private inline fun <reified Ir : IrSymbolOwner, D : DeclarationDescriptor, reified S : IrBindableSymbol<D, Ir>> Ir.desymbolizeLink() =
+ if (this is S) owner else this
+}
\ No newline at end of file
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt
index 258b1ab..6e02c82 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt
@@ -94,8 +94,8 @@
declaration.dumpLabeledElementWith(data) {
dumpAnnotations(declaration)
declaration.correspondingPropertySymbol?.dumpInternal("correspondingProperty")
- declaration.overriddenSymbols.dumpItems<IrSymbol>("overridden") {
- it.dump()
+ declaration.overridden.dumpItems("overridden") {
+ it.symbol.dump()
}
declaration.typeParameters.dumpElements()
declaration.dispatchReceiverParameter?.accept(this, "\$this")
@@ -140,8 +140,8 @@
override fun visitField(declaration: IrField, data: String) {
declaration.dumpLabeledElementWith(data) {
dumpAnnotations(declaration)
- declaration.overriddenSymbols.dumpItems("overridden") {
- it.dump()
+ declaration.overridden.dumpItems("overridden") {
+ it.symbol.dump()
}
declaration.initializer?.accept(this, "")
}
@@ -214,8 +214,8 @@
}
private fun IrMemberAccessExpression.getTypeParameterNames(expectedCount: Int): List<String> =
- if (this is IrDeclarationReference && symbol.isBound)
- symbol.owner.getTypeParameterNames(expectedCount)
+ if (this is IrDeclarationReference && target.symbol.isBound)
+ target.getTypeParameterNames(expectedCount)
else
getPlaceholderParameterNames(expectedCount)
@@ -371,8 +371,8 @@
internal fun IrMemberAccessExpression.getValueParameterNamesForDebug(): List<String> {
val expectedCount = valueArgumentsCount
- return if (this is IrDeclarationReference && symbol.isBound) {
- val owner = symbol.owner
+ return if (this is IrDeclarationReference && target.symbol.isBound) {
+ val owner = target
if (owner is IrFunction) {
(0 until expectedCount).map {
if (it < owner.valueParameters.size)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExpectDeclarationRemover.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExpectDeclarationRemover.kt
index 1c05b63..8cbbad8 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExpectDeclarationRemover.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExpectDeclarationRemover.kt
@@ -11,8 +11,6 @@
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrGetValue
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
-import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
-import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
@@ -98,42 +96,41 @@
override fun visitGetValue(expression: IrGetValue): IrExpression {
expression.transformChildrenVoid()
- val newValue = remapExpectValue(expression.symbol)
+ val newValue = remapExpectValue(expression.target)
?: return expression
return IrGetValueImpl(
expression.startOffset,
expression.endOffset,
newValue.type,
- newValue.symbol,
+ newValue,
expression.origin
)
}
}, data = null)
}
- private fun remapExpectValue(symbol: IrValueSymbol): IrValueParameter? {
- if (symbol !is IrValueParameterSymbol) {
+ private fun remapExpectValue(declaration: IrValueDeclaration): IrValueParameter? {
+ if (declaration !is IrValueParameter) {
return null
}
- val parameter = symbol.owner
- val parent = parameter.parent
+ val parent = declaration.parent
return when (parent) {
is IrClass -> {
- assert(parameter == parent.thisReceiver)
+ assert(declaration == parent.thisReceiver)
parent.findActualForExpected().thisReceiver!!
}
- is IrFunction -> when (parameter) {
+ is IrFunction -> when (declaration) {
parent.dispatchReceiverParameter ->
parent.findActualForExpected().dispatchReceiverParameter!!
parent.extensionReceiverParameter ->
parent.findActualForExpected().extensionReceiverParameter!!
else -> {
- assert(parent.valueParameters[parameter.index] == parameter)
- parent.findActualForExpected().valueParameters[parameter.index]
+ assert(parent.valueParameters[declaration.index] == declaration)
+ parent.findActualForExpected().valueParameters[declaration.index]
}
}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt
index ec27fba..a628381 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt
@@ -59,22 +59,21 @@
* Binds the arguments explicitly represented in the IR to the parameters of the accessed function.
* The arguments are to be evaluated in the same order as they appear in the resulting list.
*/
-fun IrFunctionAccessExpression.getArgumentsWithSymbols(): List<Pair<IrValueParameterSymbol, IrExpression>> {
- val res = mutableListOf<Pair<IrValueParameterSymbol, IrExpression>>()
- val irFunction = symbol.owner
+fun IrFunctionAccessExpression.getArgumentsWithParameters(): List<Pair<IrValueParameter, IrExpression>> {
+ val res = mutableListOf<Pair<IrValueParameter, IrExpression>>()
dispatchReceiver?.let {
- res += (irFunction.dispatchReceiverParameter!!.symbol to it)
+ res += (target.dispatchReceiverParameter!! to it)
}
extensionReceiver?.let {
- res += (irFunction.extensionReceiverParameter!!.symbol to it)
+ res += (target.extensionReceiverParameter!! to it)
}
- irFunction.valueParameters.forEach {
+ target.valueParameters.forEach {
val arg = getValueArgument(it.descriptor as ValueParameterDescriptor)
if (arg != null) {
- res += (it.symbol to arg)
+ res += (it to arg)
}
}
@@ -88,8 +87,8 @@
fun IrMemberAccessExpression.getArgumentsWithIr(): List<Pair<IrValueParameter, IrExpression>> {
val res = mutableListOf<Pair<IrValueParameter, IrExpression>>()
val irFunction = when (this) {
- is IrFunctionAccessExpression -> this.symbol.owner
- is IrFunctionReference -> this.symbol.owner
+ is IrFunctionAccessExpression -> this.target
+ is IrFunctionReference -> this.target
else -> error(this)
}
@@ -181,21 +180,12 @@
val IrClass.functions: Sequence<IrSimpleFunction>
get() = declarations.asSequence().filterIsInstance<IrSimpleFunction>()
-val IrClassSymbol.functions: Sequence<IrSimpleFunctionSymbol>
- get() = owner.functions.map { it.symbol }
-
val IrClass.constructors: Sequence<IrConstructor>
get() = declarations.asSequence().filterIsInstance<IrConstructor>()
-val IrClassSymbol.constructors: Sequence<IrConstructorSymbol>
- get() = owner.constructors.map { it.symbol }
-
val IrClass.fields: Sequence<IrField>
get() = declarations.asSequence().filterIsInstance<IrField>()
-val IrClassSymbol.fields: Sequence<IrFieldSymbol>
- get() = owner.fields.map { it.symbol }
-
val IrClass.primaryConstructor: IrConstructor?
get() = this.declarations.singleOrNull { it is IrConstructor && it.isPrimary } as IrConstructor?
@@ -223,9 +213,9 @@
val IrDeclaration.isFakeOverride: Boolean get() = origin == IrDeclarationOrigin.FAKE_OVERRIDE
fun IrClass.isSubclassOf(ancestor: IrClass): Boolean {
-
val alreadyVisited = mutableSetOf<IrClass>()
+
fun IrClass.hasAncestorInSuperTypes(): Boolean = when {
this === ancestor -> true
this in alreadyVisited -> false
@@ -250,18 +240,18 @@
if (func.isReal) {
realOverrides += func
} else {
- func.overriddenSymbols.forEach { collectRealOverrides(it.owner) }
+ func.overridden.forEach { collectRealOverrides(it) }
}
}
- overriddenSymbols.forEach { collectRealOverrides(it.owner) }
+ overridden.forEach { collectRealOverrides(it) }
fun excludeRepeated(func: IrSimpleFunction) {
if (!visited.add(func)) return
- func.overriddenSymbols.forEach {
- realOverrides.remove(it.owner)
- excludeRepeated(it.owner)
+ func.overridden.forEach {
+ realOverrides.remove(it)
+ excludeRepeated(it)
}
}
@@ -280,7 +270,7 @@
fun IrSimpleFunction.isOrOverridesSynthesized(): Boolean {
if (isSynthesized) return true
- if (isFakeOverride) return overriddenSymbols.all { it.owner.isOrOverridesSynthesized() }
+ if (isFakeOverride) return overridden.all { it.isOrOverridesSynthesized() }
return false
}
@@ -297,8 +287,8 @@
var toVisit = setOf(this)
val nonOverridden = mutableSetOf<IrField>()
while (toVisit.isNotEmpty()) {
- nonOverridden += toVisit.filter { it.overriddenSymbols.isEmpty() }
- toVisit = toVisit.flatMap { it.overriddenSymbols }.map { it.owner }.toSet()
+ nonOverridden += toVisit.filter { it.overridden.isEmpty() }
+ toVisit = toVisit.flatMap { it.overridden }.toSet()
}
return nonOverridden.singleOrNull()
}
@@ -343,17 +333,17 @@
fun IrAnnotationContainer.getAnnotation(name: FqName): IrConstructorCall? =
annotations.find {
- it.symbol.owner.parentAsClass.descriptor.fqNameSafe == name
+ it.target.parentAsClass.descriptor.fqNameSafe == name
}
fun IrAnnotationContainer.hasAnnotation(name: FqName) =
annotations.any {
- it.symbol.owner.parentAsClass.descriptor.fqNameSafe == name
+ it.target.parentAsClass.descriptor.fqNameSafe == name
}
-fun IrAnnotationContainer.hasAnnotation(symbol: IrClassSymbol) =
+fun IrAnnotationContainer.hasAnnotation(clazz: IrClass) =
annotations.any {
- it.symbol.owner.parentAsClass.symbol == symbol
+ it.target.parentAsClass == clazz
}
@@ -364,10 +354,10 @@
return (parent as? IrClass)?.thisReceiver?.type?.isAny() ?: false
}
- return (this as IrSimpleFunction).overriddenSymbols.all { it.owner.isFakeOverriddenFromAny() }
+ return (this as IrSimpleFunction).overridden.all { it.isFakeOverriddenFromAny() }
}
-fun IrCall.isSuperToAny() = superQualifier?.let { this.symbol.owner.isFakeOverriddenFromAny() } ?: false
+fun IrCall.isSuperToAny() = superQualifier?.let { this.target.isFakeOverriddenFromAny() } ?: false
fun IrDeclaration.isEffectivelyExternal(): Boolean {
@@ -389,7 +379,7 @@
fun IrFunction.isExternalOrInheritedFromExternal(): Boolean {
fun isExternalOrInheritedFromExternalImpl(f: IrSimpleFunction): Boolean =
- f.isEffectivelyExternal() || f.overriddenSymbols.any { isExternalOrInheritedFromExternalImpl(it.owner) }
+ f.isEffectivelyExternal() || f.overridden.any { isExternalOrInheritedFromExternalImpl(it) }
return isEffectivelyExternal() || (this is IrSimpleFunction && isExternalOrInheritedFromExternalImpl(this))
}
@@ -403,7 +393,7 @@
fun IrValueParameter.hasDefaultValue(): Boolean = DFS.ifAny(
listOf(this),
- { current -> (current.parent as? IrSimpleFunction)?.overriddenSymbols?.map { it.owner.valueParameters[current.index] } ?: listOf() },
+ { current -> (current.parent as? IrSimpleFunction)?.overridden?.map { it.valueParameters[current.index] } ?: listOf() },
{ current -> current.defaultValue != null }
)
@@ -454,15 +444,7 @@
fun irConstructorCall(
call: IrFunctionAccessExpression,
- newFunction: IrConstructor,
- receiversAsArguments: Boolean = false,
- argumentsAsReceivers: Boolean = false
-): IrConstructorCall =
- irConstructorCall(call, newFunction.symbol, receiversAsArguments, argumentsAsReceivers)
-
-fun irConstructorCall(
- call: IrFunctionAccessExpression,
- newSymbol: IrConstructorSymbol,
+ newCallee: IrConstructor,
receiversAsArguments: Boolean = false,
argumentsAsDispatchers: Boolean = false
): IrConstructorCall =
@@ -471,8 +453,8 @@
startOffset,
endOffset,
type,
- newSymbol,
- newSymbol.descriptor,
+ newCallee,
+ newCallee.descriptor,
typeArgumentsCount,
0,
call.valueArgumentsCount,
@@ -492,26 +474,13 @@
receiversAsArguments: Boolean = false,
argumentsAsReceivers: Boolean = false
): IrCall =
- irCall(
- call,
- newFunction.symbol,
- receiversAsArguments,
- argumentsAsReceivers
- )
-
-fun irCall(
- call: IrFunctionAccessExpression,
- newSymbol: IrFunctionSymbol,
- receiversAsArguments: Boolean = false,
- argumentsAsReceivers: Boolean = false
-): IrCall =
call.run {
IrCallImpl(
startOffset,
endOffset,
type,
- newSymbol,
- newSymbol.descriptor,
+ newFunction,
+ newFunction.descriptor,
typeArgumentsCount,
origin
).apply {
@@ -529,8 +498,8 @@
argumentsAsReceivers: Boolean = false
) = copyTypeAndValueArgumentsFrom(
src,
- src.symbol.owner,
- symbol.owner,
+ src.target,
+ target,
receiversAsArguments,
argumentsAsReceivers
)
@@ -541,8 +510,8 @@
argumentsAsReceivers: Boolean = false
) = copyTypeAndValueArgumentsFrom(
src,
- src.symbol.owner,
- symbol.owner,
+ src.target,
+ target,
receiversAsArguments,
argumentsAsReceivers
)
@@ -604,13 +573,13 @@
else
typeParameters
-fun IrMemberAccessExpression.getTypeSubstitutionMap(irFunction: IrFunction): Map<IrTypeParameterSymbol, IrType> =
+fun IrMemberAccessExpression.getTypeSubstitutionMap(irFunction: IrFunction): Map<IrTypeParameter, IrType> =
irFunction.allTypeParameters.withIndex().associate {
- it.value.symbol to getTypeArgument(it.index)!!
+ it.value to getTypeArgument(it.index)!!
}
-val IrFunctionReference.typeSubstitutionMap: Map<IrTypeParameterSymbol, IrType>
- get() = getTypeSubstitutionMap(symbol.owner)
+val IrFunctionReference.typeSubstitutionMap: Map<IrTypeParameter, IrType>
+ get() = getTypeSubstitutionMap(target)
-val IrFunctionAccessExpression.typeSubstitutionMap: Map<IrTypeParameterSymbol, IrType>
- get() = getTypeSubstitutionMap(symbol.owner)
+val IrFunctionAccessExpression.typeSubstitutionMap: Map<IrTypeParameter, IrType>
+ get() = getTypeSubstitutionMap(target)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt
index bad56ef..5917bc9 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt
@@ -45,7 +45,7 @@
private fun StringBuilder.renderAsAnnotation(irAnnotation: IrConstructorCall) {
val annotationClassName = try {
- irAnnotation.symbol.owner.parentAsClass.name.asString()
+ irAnnotation.target.parentAsClass.name.asString()
} catch (e: Exception) {
"<unbound>"
}
@@ -545,44 +545,44 @@
"COMPOSITE type=${expression.type.render()} origin=${expression.origin}"
override fun visitReturn(expression: IrReturn, data: Nothing?): String =
- "RETURN type=${expression.type.render()} from='${expression.returnTargetSymbol.renderReference()}'"
+ "RETURN type=${expression.type.render()} from='${expression.irReturnTarget.symbol.renderReference()}'"
override fun visitCall(expression: IrCall, data: Nothing?): String =
- "CALL '${expression.symbol.renderReference()}' ${expression.renderSuperQualifier()}" +
+ "CALL '${expression.target.symbol.renderReference()}' ${expression.renderSuperQualifier()}" +
"type=${expression.type.render()} origin=${expression.origin}"
private fun IrCall.renderSuperQualifier(): String =
- superQualifierSymbol?.let { "superQualifier='${it.renderReference()}' " } ?: ""
+ irSuperQualifier?.let { "superQualifier='${it.symbol.renderReference()}' " } ?: ""
override fun visitConstructorCall(expression: IrConstructorCall, data: Nothing?): String =
- "CONSTRUCTOR_CALL '${expression.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
+ "CONSTRUCTOR_CALL '${expression.target.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?): String =
- "DELEGATING_CONSTRUCTOR_CALL '${expression.symbol.renderReference()}'"
+ "DELEGATING_CONSTRUCTOR_CALL '${expression.target.symbol.renderReference()}'"
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall, data: Nothing?): String =
- "ENUM_CONSTRUCTOR_CALL '${expression.symbol.renderReference()}'"
+ "ENUM_CONSTRUCTOR_CALL '${expression.target.symbol.renderReference()}'"
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?): String =
- "INSTANCE_INITIALIZER_CALL classDescriptor='${expression.classSymbol.renderReference()}'"
+ "INSTANCE_INITIALIZER_CALL classDescriptor='${expression.irClass.symbol.renderReference()}'"
override fun visitGetValue(expression: IrGetValue, data: Nothing?): String =
- "GET_VAR '${expression.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
+ "GET_VAR '${expression.target.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
override fun visitSetVariable(expression: IrSetVariable, data: Nothing?): String =
- "SET_VAR '${expression.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
+ "SET_VAR '${expression.target.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
override fun visitGetField(expression: IrGetField, data: Nothing?): String =
- "GET_FIELD '${expression.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
+ "GET_FIELD '${expression.target.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
override fun visitSetField(expression: IrSetField, data: Nothing?): String =
- "SET_FIELD '${expression.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
+ "SET_FIELD '${expression.target.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
override fun visitGetObjectValue(expression: IrGetObjectValue, data: Nothing?): String =
- "GET_OBJECT '${expression.symbol.renderReference()}' type=${expression.type.render()}"
+ "GET_OBJECT '${expression.target.symbol.renderReference()}' type=${expression.type.render()}"
override fun visitGetEnumValue(expression: IrGetEnumValue, data: Nothing?): String =
- "GET_ENUM '${expression.symbol.renderReference()}' type=${expression.type.render()}"
+ "GET_ENUM '${expression.target.symbol.renderReference()}' type=${expression.type.render()}"
override fun visitStringConcatenation(expression: IrStringConcatenation, data: Nothing?): String =
"STRING_CONCATENATION type=${expression.type.render()}"
@@ -612,15 +612,15 @@
"THROW type=${expression.type.render()}"
override fun visitFunctionReference(expression: IrFunctionReference, data: Nothing?): String =
- "FUNCTION_REFERENCE '${expression.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
+ "FUNCTION_REFERENCE '${expression.target.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}"
override fun visitPropertyReference(expression: IrPropertyReference, data: Nothing?): String =
buildTrimEnd {
append("PROPERTY_REFERENCE ")
- append("'${expression.symbol.renderReference()}' ")
- appendNullableAttribute("field=", expression.field) { "'${it.renderReference()}'" }
- appendNullableAttribute("getter=", expression.getter) { "'${it.renderReference()}'" }
- appendNullableAttribute("setter=", expression.setter) { "'${it.renderReference()}'" }
+ append("'${expression.target.symbol.renderReference()}' ")
+ appendNullableAttribute("field=", expression.field) { "'${it.symbol.renderReference()}'" }
+ appendNullableAttribute("getter=", expression.getter) { "'${it.symbol.renderReference()}'" }
+ appendNullableAttribute("setter=", expression.setter) { "'${it.symbol.renderReference()}'" }
append("type=${expression.type.render()} ")
append("origin=${expression.origin}")
}
@@ -638,10 +638,10 @@
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: Nothing?): String =
buildTrimEnd {
append("LOCAL_DELEGATED_PROPERTY_REFERENCE ")
- append("'${expression.symbol.renderReference()}' ")
- append("delegate='${expression.delegate.renderReference()}' ")
- append("getter='${expression.getter.renderReference()}' ")
- appendNullableAttribute("setter=", expression.setter) { "'${it.renderReference()}'" }
+ append("'${expression.target.symbol.renderReference()}' ")
+ append("delegate='${expression.delegate.symbol.renderReference()}' ")
+ append("getter='${expression.getter.symbol.renderReference()}' ")
+ appendNullableAttribute("setter=", expression.setter) { "'${it.symbol.renderReference()}'" }
append("type=${expression.type.render()} ")
append("origin=${expression.origin}")
}
@@ -652,7 +652,7 @@
}
override fun visitClassReference(expression: IrClassReference, data: Nothing?): String =
- "CLASS_REFERENCE '${expression.symbol.renderReference()}' type=${expression.type.render()}"
+ "CLASS_REFERENCE '${expression.target.symbol.renderReference()}' type=${expression.type.render()}"
override fun visitGetClass(expression: IrGetClass, data: Nothing?): String =
"GET_CLASS type=${expression.type.render()}"
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/overrides.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/overrides.kt
index 24299c5..6ba993e 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/overrides.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/overrides.kt
@@ -27,7 +27,7 @@
declaration: IrSimpleFunction,
symbolTable: SymbolTable
) {
- declaration.descriptor.overriddenDescriptors.mapTo(declaration.overriddenSymbols) {
+ declaration.descriptor.overriddenDescriptors.mapTo(declaration.overridden) {
symbolTable.referenceSimpleFunction(it.original)
}
}
@@ -49,7 +49,7 @@
symbolTable: SymbolTable,
hasBackingField: (PropertyDescriptor) -> Boolean
) {
- declaration.descriptor.overriddenDescriptors.mapNotNullTo(declaration.overriddenSymbols) {
+ declaration.descriptor.overriddenDescriptors.mapNotNullTo(declaration.overridden) {
if (hasBackingField(it)) {
symbolTable.referenceField(it.original)
} else null
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFakeOverrideUtils.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFakeOverrideUtils.kt
index 407ba2a..7d30274 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFakeOverrideUtils.kt
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFakeOverrideUtils.kt
@@ -7,13 +7,12 @@
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.ir.declarations.*
-import org.jetbrains.kotlin.ir.symbols.IrBindableSymbol
import org.jetbrains.kotlin.ir.util.isReal
import org.jetbrains.kotlin.ir.util.original
// We may get several real supers here (e.g. see the code snippet from KT-33034).
// TODO: Consider reworking the resolution algorithm to get a determined super declaration.
-private fun <S: IrBindableSymbol<*, D>, D: IrOverridableDeclaration<S>> D.getRealSupers(): Set<D> {
+private fun <D: IrOverridableDeclaration<D>> D.getRealSupers(): Set<D> {
if (this.isReal) {
return setOf(this)
}
@@ -27,7 +26,7 @@
if (declaration.isReal) {
realSupers += declaration
} else {
- declaration.overriddenSymbols.forEach { findRealSupers(it.owner) }
+ declaration.overridden.forEach { findRealSupers(it) }
}
}
@@ -39,9 +38,9 @@
fun excludeOverridden(declaration: D) {
if (declaration in visited) return
visited += declaration
- declaration.overriddenSymbols.forEach {
- realSupers.remove(it.owner)
- excludeOverridden(it.owner)
+ declaration.overridden.forEach {
+ realSupers.remove(it)
+ excludeOverridden(it)
}
}
@@ -85,11 +84,11 @@
*/
internal fun IrField.resolveFakeOverride(): IrField = getRealSupers().first()
-val IrSimpleFunction.target: IrSimpleFunction
- get() = (if (modality == Modality.ABSTRACT) this else resolveFakeOverride()).original
+val IrSimpleFunction.resolved: IrSimpleFunction
+ get() = (if (modality == Modality.ABSTRACT) this else resolveFakeOverride())
-val IrFunction.target: IrFunction get() = when (this) {
- is IrSimpleFunction -> this.target
+val IrFunction.resolved: IrFunction get() = when (this) {
+ is IrSimpleFunction -> this.resolved
is IrConstructor -> this
else -> error(this)
}
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt
index b14134e..3842abb 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt
@@ -1059,7 +1059,7 @@
proto.isSuspend
)
}.apply {
- proto.overriddenList.mapTo(overriddenSymbols) { deserializeIrSymbol(it) as IrSimpleFunctionSymbol }
+ proto.overriddenList.mapTo(overridden) { deserializeIrSymbol(it) as IrSimpleFunctionSymbol }
(descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
}
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt
index 3ac41b4..ba4d243 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt
@@ -543,11 +543,11 @@
private fun serializeCall(call: IrCall): ProtoCall {
val proto = ProtoCall.newBuilder()
- proto.symbol = serializeIrSymbol(call.symbol)
+ proto.symbol = serializeIrSymbol(call.target.symbol)
call.origin?.let { proto.origin = serializeIrStatementOrigin(it) }
- call.superQualifierSymbol?.let {
- proto.`super` = serializeIrSymbol(it)
+ call.irSuperQualifier?.let {
+ proto.`super` = serializeIrSymbol(it.symbol)
}
proto.memberAccess = serializeMemberAccessCommon(call)
@@ -556,7 +556,7 @@
private fun serializeConstructorCall(call: IrConstructorCall): ProtoConstructorCall =
ProtoConstructorCall.newBuilder().apply {
- symbol = serializeIrSymbol(call.symbol)
+ symbol = serializeIrSymbol(call.target.symbol)
constructorTypeArgumentsCount = call.constructorTypeArgumentsCount
memberAccess = serializeMemberAccessCommon(call)
}.build()
@@ -569,7 +569,7 @@
private fun serializeFunctionReference(callable: IrFunctionReference): ProtoFunctionReference {
val proto = ProtoFunctionReference.newBuilder()
- .setSymbol(serializeIrSymbol(callable.symbol))
+ .setSymbol(serializeIrSymbol(callable.target.symbol))
.setMemberAccess(serializeMemberAccessCommon(callable))
callable.origin?.let { proto.setOrigin(serializeIrStatementOrigin(it)) }
@@ -580,12 +580,12 @@
callable: IrLocalDelegatedPropertyReference
): ProtoLocalDelegatedPropertyReference {
val proto = ProtoLocalDelegatedPropertyReference.newBuilder()
- .setDelegate(serializeIrSymbol(callable.delegate))
- .setGetter(serializeIrSymbol(callable.getter))
- .setSymbol(serializeIrSymbol(callable.symbol))
+ .setDelegate(serializeIrSymbol(callable.delegate.symbol))
+ .setGetter(serializeIrSymbol(callable.getter.symbol))
+ .setSymbol(serializeIrSymbol(callable.target.symbol))
callable.origin?.let { proto.setOrigin(serializeIrStatementOrigin(it)) }
- callable.setter?.let { proto.setSetter(serializeIrSymbol(it)) }
+ callable.setter?.let { proto.setSetter(serializeIrSymbol(it.symbol)) }
return proto.build()
}
@@ -593,18 +593,18 @@
private fun serializePropertyReference(callable: IrPropertyReference): ProtoPropertyReference {
val proto = ProtoPropertyReference.newBuilder()
.setMemberAccess(serializeMemberAccessCommon(callable))
- .setSymbol(serializeIrSymbol(callable.symbol))
+ .setSymbol(serializeIrSymbol(callable.target.symbol))
callable.origin?.let { proto.origin = serializeIrStatementOrigin(it) }
- callable.field?.let { proto.field = serializeIrSymbol(it) }
- callable.getter?.let { proto.getter = serializeIrSymbol(it) }
- callable.setter?.let { proto.setter = serializeIrSymbol(it) }
+ callable.field?.let { proto.field = serializeIrSymbol(it.symbol) }
+ callable.getter?.let { proto.getter = serializeIrSymbol(it.symbol) }
+ callable.setter?.let { proto.setter = serializeIrSymbol(it.symbol) }
return proto.build()
}
private fun serializeClassReference(expression: IrClassReference): ProtoClassReference {
val proto = ProtoClassReference.newBuilder()
- .setClassSymbol(serializeIrSymbol(expression.symbol))
+ .setClassSymbol(serializeIrSymbol(expression.target.symbol))
.setClassType(serializeIrType(expression.classType))
return proto.build()
}
@@ -628,7 +628,7 @@
private fun serializeDelegatingConstructorCall(call: IrDelegatingConstructorCall): ProtoDelegatingConstructorCall {
val proto = ProtoDelegatingConstructorCall.newBuilder()
- .setSymbol(serializeIrSymbol(call.symbol))
+ .setSymbol(serializeIrSymbol(call.target.symbol))
.setMemberAccess(serializeMemberAccessCommon(call))
return proto.build()
}
@@ -640,7 +640,7 @@
private fun serializeEnumConstructorCall(call: IrEnumConstructorCall): ProtoEnumConstructorCall {
val proto = ProtoEnumConstructorCall.newBuilder()
- .setSymbol(serializeIrSymbol(call.symbol))
+ .setSymbol(serializeIrSymbol(call.target.symbol))
.setMemberAccess(serializeMemberAccessCommon(call))
return proto.build()
}
@@ -653,14 +653,14 @@
private fun serializeGetEnumValue(expression: IrGetEnumValue): ProtoGetEnumValue {
val proto = ProtoGetEnumValue.newBuilder()
- .setSymbol(serializeIrSymbol(expression.symbol))
+ .setSymbol(serializeIrSymbol(expression.target.symbol))
return proto.build()
}
private fun serializeFieldAccessCommon(expression: IrFieldAccessExpression): ProtoFieldAccessCommon {
val proto = ProtoFieldAccessCommon.newBuilder()
- .setSymbol(serializeIrSymbol(expression.symbol))
- expression.superQualifierSymbol?.let { proto.`super` = serializeIrSymbol(it) }
+ .setSymbol(serializeIrSymbol(expression.target.symbol))
+ expression.irSuperQualifier?.let { proto.`super` = serializeIrSymbol(it.symbol) }
expression.receiver?.let { proto.receiver = serializeExpression(it) }
return proto.build()
}
@@ -674,28 +674,28 @@
private fun serializeGetValue(expression: IrGetValue): ProtoGetValue =
ProtoGetValue.newBuilder()
- .setSymbol(serializeIrSymbol(expression.symbol)).apply {
+ .setSymbol(serializeIrSymbol(expression.target.symbol)).apply {
expression.origin?.let { origin = serializeIrStatementOrigin(it) }
}
.build()
private fun serializeGetObject(expression: IrGetObjectValue): ProtoGetObject {
val proto = ProtoGetObject.newBuilder()
- .setSymbol(serializeIrSymbol(expression.symbol))
+ .setSymbol(serializeIrSymbol(expression.target.symbol))
return proto.build()
}
private fun serializeInstanceInitializerCall(call: IrInstanceInitializerCall): ProtoInstanceInitializerCall {
val proto = ProtoInstanceInitializerCall.newBuilder()
- proto.symbol = serializeIrSymbol(call.classSymbol)
+ proto.symbol = serializeIrSymbol(call.irClass.symbol)
return proto.build()
}
private fun serializeReturn(expression: IrReturn): ProtoReturn {
val proto = ProtoReturn.newBuilder()
- .setReturnTarget(serializeIrSymbol(expression.returnTargetSymbol))
+ .setReturnTarget(serializeIrSymbol(expression.irReturnTarget.symbol))
.setValue(serializeExpression(expression.value))
return proto.build()
}
@@ -710,7 +710,7 @@
private fun serializeSetVariable(expression: IrSetVariable): ProtoSetVariable =
ProtoSetVariable.newBuilder()
- .setSymbol(serializeIrSymbol(expression.symbol))
+ .setSymbol(serializeIrSymbol(expression.target.symbol))
.setValue(serializeExpression(expression.value)).apply {
expression.origin?.let { origin = serializeIrStatementOrigin(it) }
}
@@ -1103,8 +1103,8 @@
.setIsTailrec(declaration.isTailrec)
.setIsSuspend(declaration.isSuspend)
- declaration.overriddenSymbols.forEach {
- proto.addOverridden(serializeIrSymbol(it))
+ declaration.overridden.forEach {
+ proto.addOverridden(serializeIrSymbol(it.symbol))
}
return proto.build()
diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt
index 8dfac0d..bda06b5 100644
--- a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt
+++ b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt
@@ -223,11 +223,11 @@
}
override fun visitDeclarationReference(expression: IrDeclarationReference) {
- expression.symbol.checkBinding("ref", expression)
+ expression.target.checkBinding("ref", expression)
}
override fun visitFunctionReference(expression: IrFunctionReference) {
- expression.symbol.checkBinding("ref", expression)
+ expression.target.checkBinding("ref", expression)
}
override fun visitPropertyReference(expression: IrPropertyReference) {
@@ -242,11 +242,11 @@
expression.setter?.checkBinding("setter", expression)
}
- private fun IrSymbol.checkBinding(kind: String, irElement: IrElement) {
- if (!isBound) {
- error("${javaClass.simpleName} $descriptor is unbound @$kind ${irElement.render()}")
+ private fun IrSymbolOwner.checkBinding(kind: String, irElement: IrElement) {
+ if (!symbol.isBound) {
+ error("${javaClass.simpleName} ${symbol.descriptor} is unbound @$kind ${irElement.render()}")
} else {
- val irDeclaration = owner as? IrDeclaration
+ val irDeclaration = this as? IrDeclaration
if (irDeclaration != null) {
try {
irDeclaration.parent
@@ -256,9 +256,9 @@
}
}
- val otherSymbol = symbolForDeclaration.getOrPut(owner) { this }
+ val otherSymbol = symbolForDeclaration.getOrPut(this) { symbol }
if (this != otherSymbol) {
- error("Multiple symbols for $descriptor @$kind ${irElement.render()}")
+ error("Multiple symbols for ${symbol.descriptor} @$kind ${irElement.render()}")
}
}
diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt
index 02170aa..6e9ff65 100644
--- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt
+++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt
@@ -62,7 +62,7 @@
private fun IrClass.declareSimpleFunctionWithExternalOverrides(descriptor: FunctionDescriptor): IrSimpleFunction {
return compilerContext.localSymbolTable.declareSimpleFunction(startOffset, endOffset, SERIALIZABLE_PLUGIN_ORIGIN, descriptor)
.also { f ->
- descriptor.overriddenDescriptors.mapTo(f.overriddenSymbols) {
+ descriptor.overriddenDescriptors.mapTo(f.overridden) {
compilerContext.externalSymbols.referenceSimpleFunction(it.original)
}
}
@@ -79,7 +79,7 @@
f.parent = this
f.returnType = descriptor.returnType!!.toIrType()
if (!fromStubs) f.createParameterDeclarations(this.thisReceiver!!)
- f.body = compilerContext.createIrBuilder(f.symbol).at(this).irBlockBody(this.startOffset, this.endOffset) { bodyGen(f) }
+ f.body = compilerContext.createIrBuilder(f).at(this).irBlockBody(this.startOffset, this.endOffset) { bodyGen(f) }
this.addMember(f)
}
@@ -102,13 +102,13 @@
overwriteValueParameters = overwriteValueParameters,
copyTypeParameters = false
)
- c.body = compilerContext.createIrBuilder(c.symbol).at(this).irBlockBody(this.startOffset, this.endOffset) { bodyGen(c) }
+ c.body = compilerContext.createIrBuilder(c).at(this).irBlockBody(this.startOffset, this.endOffset) { bodyGen(c) }
this.addMember(c)
}
fun IrBuilderWithScope.irInvoke(
dispatchReceiver: IrExpression? = null,
- callee: IrFunctionSymbol,
+ callee: IrFunction,
vararg args: IrExpression,
typeHint: IrType? = null
): IrMemberAccessExpression {
@@ -120,7 +120,7 @@
fun IrBuilderWithScope.irInvoke(
dispatchReceiver: IrExpression? = null,
- callee: IrFunctionSymbol,
+ callee: IrFunction,
typeArguments: List<IrType?>,
valueArguments: List<IrExpression>,
returnTypeHint: IrType? = null
@@ -147,12 +147,12 @@
}
fun IrBuilderWithScope.irBinOp(name: Name, lhs: IrExpression, rhs: IrExpression): IrExpression {
- val symbol = compilerContext.ir.symbols.getBinaryOperator(
+ val function = compilerContext.ir.symbols.getBinaryOperator(
name,
lhs.type.toKotlinType(),
rhs.type.toKotlinType()
)
- return irInvoke(lhs, symbol, rhs)
+ return irInvoke(lhs, function, rhs)
}
fun IrBuilderWithScope.irGetObject(classDescriptor: ClassDescriptor) =
@@ -168,7 +168,7 @@
startOffset,
endOffset,
irObject.defaultType,
- irObject.symbol
+ irObject
)
fun <T : IrDeclaration> T.buildWithScope(builder: (T) -> Unit): T =
@@ -239,7 +239,7 @@
}
fun generateSimplePropertyWithBackingField(
- ownerSymbol: IrValueSymbol,
+ owner: IrValueDeclaration,
propertyDescriptor: PropertyDescriptor,
propertyParent: IrClass
): IrProperty {
@@ -253,10 +253,10 @@
parent = propertyParent
correspondingPropertySymbol = irProperty.symbol
}
- val fieldSymbol = irProperty.backingField!!.symbol
- irProperty.getter = propertyDescriptor.getter?.let { generatePropertyAccessor(it, fieldSymbol) }
+ val field = irProperty.backingField!!
+ irProperty.getter = propertyDescriptor.getter?.let { generatePropertyAccessor(it, field) }
?.apply { parent = propertyParent }
- irProperty.setter = propertyDescriptor.setter?.let { generatePropertyAccessor(it, fieldSymbol) }
+ irProperty.setter = propertyDescriptor.setter?.let { generatePropertyAccessor(it, field) }
?.apply { parent = propertyParent }
return irProperty
}
@@ -276,7 +276,7 @@
fun generatePropertyAccessor(
descriptor: PropertyAccessorDescriptor,
- fieldSymbol: IrFieldSymbol
+ field: IrField
): IrSimpleFunction {
// Declaration can also be called from user code. Since we lookup descriptor getter in externalSymbols
// (see generateSave/generateLoad), seems it is correct approach to declare getter lazily there.
@@ -302,12 +302,12 @@
val endOffset = irAccessor.endOffset
val irBody = IrBlockBodyImpl(startOffset, endOffset)
- val receiver = generateReceiverExpressionForFieldAccess(irAccessor.dispatchReceiverParameter!!.symbol, property)
+ val receiver = generateReceiverExpressionForFieldAccess(irAccessor.dispatchReceiverParameter!!, property)
irBody.statements.add(
IrReturnImpl(
startOffset, endOffset, compilerContext.irBuiltIns.nothingType,
- irAccessor.symbol,
+ irAccessor,
IrGetFieldImpl(
startOffset, endOffset,
compilerContext.localSymbolTable.referenceField(property),
@@ -329,7 +329,7 @@
val endOffset = irAccessor.endOffset
val irBody = IrBlockBodyImpl(startOffset, endOffset)
- val receiver = generateReceiverExpressionForFieldAccess(irAccessor.dispatchReceiverParameter!!.symbol, property)
+ val receiver = generateReceiverExpressionForFieldAccess(irAccessor.dispatchReceiverParameter!!, property)
val irValueParameter = irAccessor.valueParameters.single()
irBody.statements.add(
@@ -337,7 +337,7 @@
startOffset, endOffset,
compilerContext.localSymbolTable.referenceField(property),
receiver,
- IrGetValueImpl(startOffset, endOffset, irValueParameter.type, irValueParameter.symbol),
+ IrGetValueImpl(startOffset, endOffset, irValueParameter.type, irValueParameter),
compilerContext.irBuiltIns.unitType
)
)
@@ -345,16 +345,16 @@
}
fun generateReceiverExpressionForFieldAccess(
- ownerSymbol: IrValueSymbol,
+ owner: IrValueDeclaration,
property: PropertyDescriptor
): IrExpression {
val containingDeclaration = property.containingDeclaration
return when (containingDeclaration) {
is ClassDescriptor ->
IrGetValueImpl(
- ownerSymbol.owner.startOffset, ownerSymbol.owner.endOffset,
+ owner.startOffset, owner.endOffset,
// symbolTable.referenceValue(containingDeclaration.thisAsReceiverParameter)
- ownerSymbol
+ owner
)
else -> throw AssertionError("Property must be in class")
}
@@ -409,7 +409,7 @@
startOffset,
endOffset,
returnType.toIrType(),
- compilerContext.externalSymbols.referenceClassifier(clazz),
+ (compilerContext.externalSymbols.referenceClassifier(clazz) as IrClassSymbol).owner,
classType.toIrType()
)
}
@@ -481,7 +481,7 @@
module: ModuleDescriptor,
type: KotlinType,
expression: IrExpression,
- nullableSerializerClass: IrClassSymbol
+ nullableSerializerClass: IrClass
): IrExpression {
return if (type.isMarkedNullable)
irInvoke(
@@ -591,6 +591,6 @@
}
}
- fun ReferenceSymbolTable.serializableSyntheticConstructor(forClass: ClassDescriptor): IrConstructorSymbol =
+ fun ReferenceSymbolTable.serializableSyntheticConstructor(forClass: ClassDescriptor): IrConstructor =
referenceConstructor(forClass.constructors.single { it.isSerializationCtor() })
}
diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
index c4c36d9..e926100 100644
--- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
+++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
@@ -152,7 +152,7 @@
endOffset,
compilerContext.irBuiltIns.unitType,
superCtorRef,
- superCtorRef.owner.descriptor
+ superCtorRef.descriptor
)
arguments.forEachIndexed { index, parameter -> call.putValueArgument(index, irGet(parameter)) }
call.insertTypeArgumentsForSuperClass(superClass)
diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt
index d52ee6a..43c1628 100644
--- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt
+++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt
@@ -15,7 +15,6 @@
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
-import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
@@ -428,7 +427,7 @@
// todo: set properties in external deserialization
var args: List<IrExpression> = localProps.map { it.get() }
val typeArgs = (loadFunc.returnType as IrSimpleType).arguments.map { (it as IrTypeProjection).type }
- val ctor: IrConstructorSymbol = if (serializableDescriptor.isInternalSerializable) {
+ val ctor: IrConstructor = if (serializableDescriptor.isInternalSerializable) {
args = bitMasks.map { irGet(it) } + args + irNull()
compilerContext.externalSymbols.serializableSyntheticConstructor(serializableDescriptor)
} else {