IR: cleanup expression implementations
Remove unused constructors with descriptors, minimize usages of secondary constructors and make some properties non-lateinit, fix some inspections.
This commit is contained in:
@@ -847,9 +847,7 @@ class Fir2IrVisitor(
|
|||||||
override fun visitCatch(catch: FirCatch, data: Any?): IrElement {
|
override fun visitCatch(catch: FirCatch, data: Any?): IrElement {
|
||||||
return catch.convertWithOffsets { startOffset, endOffset ->
|
return catch.convertWithOffsets { startOffset, endOffset ->
|
||||||
val catchParameter = declarationStorage.createIrVariable(catch.parameter, conversionScope.parentFromStack())
|
val catchParameter = declarationStorage.createIrVariable(catch.parameter, conversionScope.parentFromStack())
|
||||||
IrCatchImpl(startOffset, endOffset, catchParameter).apply {
|
IrCatchImpl(startOffset, endOffset, catchParameter, catch.block.convertToIrExpressionOrBlock())
|
||||||
result = catch.block.convertToIrExpressionOrBlock()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -273,9 +273,9 @@ class CallAndReferenceGenerator(
|
|||||||
val fir = calleeReference.resolvedSymbol.fir
|
val fir = calleeReference.resolvedSymbol.fir
|
||||||
if (this is FirFunctionCall && fir is FirSimpleFunction && fir.origin == FirDeclarationOrigin.SamConstructor) {
|
if (this is FirFunctionCall && fir is FirSimpleFunction && fir.origin == FirDeclarationOrigin.SamConstructor) {
|
||||||
return convertWithOffsets { startOffset, endOffset ->
|
return convertWithOffsets { startOffset, endOffset ->
|
||||||
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.SAM_CONVERSION, type).apply {
|
IrTypeOperatorCallImpl(
|
||||||
argument = visitor.convertToIrExpression(this@tryConvertToSamConstructorCall.argument)
|
startOffset, endOffset, type, IrTypeOperator.SAM_CONVERSION, type, visitor.convertToIrExpression(argument)
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
|||||||
+4
-3
@@ -220,12 +220,13 @@ class FinallyBlocksLowering(val context: CommonBackendContext, private val throw
|
|||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
type = context.irBuiltIns.unitType
|
type = context.irBuiltIns.unitType
|
||||||
).apply {
|
).apply {
|
||||||
this.catches += irCatch(catchParameter).apply {
|
this.catches += irCatch(
|
||||||
result = irComposite {
|
catchParameter,
|
||||||
|
irComposite {
|
||||||
+finallyExpression.copy()
|
+finallyExpression.copy()
|
||||||
+irThrow(irGet(catchParameter))
|
+irThrow(irGet(catchParameter))
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
this.finallyExpression = null
|
this.finallyExpression = null
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -111,11 +111,8 @@ fun IrBuilderWithScope.irNot(arg: IrExpression) =
|
|||||||
fun IrBuilderWithScope.irThrow(arg: IrExpression) =
|
fun IrBuilderWithScope.irThrow(arg: IrExpression) =
|
||||||
IrThrowImpl(startOffset, endOffset, context.irBuiltIns.nothingType, arg)
|
IrThrowImpl(startOffset, endOffset, context.irBuiltIns.nothingType, arg)
|
||||||
|
|
||||||
fun IrBuilderWithScope.irCatch(catchParameter: IrVariable) =
|
fun IrBuilderWithScope.irCatch(catchParameter: IrVariable, result: IrExpression): IrCatch =
|
||||||
IrCatchImpl(
|
IrCatchImpl(startOffset, endOffset, catchParameter, result)
|
||||||
startOffset, endOffset,
|
|
||||||
catchParameter
|
|
||||||
)
|
|
||||||
|
|
||||||
fun IrBuilderWithScope.irImplicitCoercionToUnit(arg: IrExpression) =
|
fun IrBuilderWithScope.irImplicitCoercionToUnit(arg: IrExpression) =
|
||||||
IrTypeOperatorCallImpl(
|
IrTypeOperatorCallImpl(
|
||||||
|
|||||||
+2
-2
@@ -92,9 +92,9 @@ class JsSuspendFunctionsLowering(ctx: JsIrBackendContext) : AbstractSuspendFunct
|
|||||||
body.endOffset,
|
body.endOffset,
|
||||||
unit,
|
unit,
|
||||||
COROUTINE_ROOT_LOOP,
|
COROUTINE_ROOT_LOOP,
|
||||||
rootTry,
|
|
||||||
JsIrBuilder.buildBoolean(context.irBuiltIns.booleanType, true)
|
|
||||||
).also {
|
).also {
|
||||||
|
it.condition = JsIrBuilder.buildBoolean(context.irBuiltIns.booleanType, true)
|
||||||
|
it.body = rootTry
|
||||||
it.label = "\$sm"
|
it.label = "\$sm"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -455,10 +455,10 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
|
|||||||
valueMap[expression.symbol]?.let {
|
valueMap[expression.symbol]?.let {
|
||||||
return IrSetVariableImpl(
|
return IrSetVariableImpl(
|
||||||
expression.startOffset, expression.endOffset,
|
expression.startOffset, expression.endOffset,
|
||||||
it.type, it.symbol as IrVariableSymbol, expression.origin
|
it.type, it.symbol as IrVariableSymbol,
|
||||||
).apply {
|
expression.value.transform(this@JvmInlineClassLowering, null),
|
||||||
value = expression.value.transform(this@JvmInlineClassLowering, null)
|
expression.origin
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
return super.visitSetVariable(expression)
|
return super.visitSetVariable(expression)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-8
@@ -167,14 +167,7 @@ private fun StatementGenerator.generateThisOrSuperReceiver(receiver: ReceiverVal
|
|||||||
fun IrExpression.implicitCastTo(expectedType: IrType?): IrExpression {
|
fun IrExpression.implicitCastTo(expectedType: IrType?): IrExpression {
|
||||||
if (expectedType == null) return this
|
if (expectedType == null) return this
|
||||||
|
|
||||||
return IrTypeOperatorCallImpl(
|
return IrTypeOperatorCallImpl(startOffset, endOffset, expectedType, IrTypeOperator.IMPLICIT_CAST, expectedType, this)
|
||||||
startOffset, endOffset,
|
|
||||||
expectedType,
|
|
||||||
IrTypeOperator.IMPLICIT_CAST,
|
|
||||||
expectedType
|
|
||||||
).also {
|
|
||||||
it.argument = this
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun StatementGenerator.generateBackingFieldReceiver(
|
fun StatementGenerator.generateBackingFieldReceiver(
|
||||||
|
|||||||
@@ -159,9 +159,12 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator
|
|||||||
return call.callReceiver.call { dispatchReceiver, extensionReceiver ->
|
return call.callReceiver.call { dispatchReceiver, extensionReceiver ->
|
||||||
if (dispatchReceiver != null) throw AssertionError("Dispatch receiver should be null: $dispatchReceiver")
|
if (dispatchReceiver != null) throw AssertionError("Dispatch receiver should be null: $dispatchReceiver")
|
||||||
if (extensionReceiver != null) throw AssertionError("Extension receiver should be null: $extensionReceiver")
|
if (extensionReceiver != null) throw AssertionError("Extension receiver should be null: $extensionReceiver")
|
||||||
val constructorSymbol = context.symbolTable.referenceConstructor(constructorDescriptor.original)
|
val descriptor = constructorDescriptor.original
|
||||||
|
val constructorSymbol = context.symbolTable.referenceConstructor(descriptor)
|
||||||
val returnType = constructorDescriptor.returnType.toIrType()
|
val returnType = constructorDescriptor.returnType.toIrType()
|
||||||
val irCall = IrEnumConstructorCallImpl(startOffset, endOffset, returnType, constructorSymbol)
|
val irCall = IrEnumConstructorCallImpl(
|
||||||
|
startOffset, endOffset, returnType, constructorSymbol, descriptor.typeParametersCount, descriptor.valueParameters.size
|
||||||
|
)
|
||||||
context.callToSubstitutedDescriptorMap[irCall] = constructorDescriptor
|
context.callToSubstitutedDescriptorMap[irCall] = constructorDescriptor
|
||||||
addParametersToCall(startOffset, endOffset, call, irCall, irCall.type)
|
addParametersToCall(startOffset, endOffset, call, irCall, irCall.type)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -43,10 +43,9 @@ class TryCatchExpressionGenerator(statementGenerator: StatementGenerator) : Stat
|
|||||||
ktCatchParameter.startOffsetSkippingComments, ktCatchParameter.endOffset,
|
ktCatchParameter.startOffsetSkippingComments, ktCatchParameter.endOffset,
|
||||||
IrDeclarationOrigin.CATCH_PARAMETER,
|
IrDeclarationOrigin.CATCH_PARAMETER,
|
||||||
catchParameterDescriptor, catchParameterDescriptor.type.toIrType()
|
catchParameterDescriptor, catchParameterDescriptor.type.toIrType()
|
||||||
)
|
),
|
||||||
).apply {
|
ktCatchBody.genExpr()
|
||||||
result = ktCatchBody.genExpr()
|
)
|
||||||
}
|
|
||||||
|
|
||||||
irTryCatch.catches.add(irCatch)
|
irTryCatch.catches.add(irCatch)
|
||||||
}
|
}
|
||||||
@@ -55,4 +54,4 @@ class TryCatchExpressionGenerator(statementGenerator: StatementGenerator) : Stat
|
|||||||
|
|
||||||
return irTryCatch
|
return irTryCatch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -87,7 +87,7 @@ internal class InsertImplicitCasts(
|
|||||||
element.acceptChildrenVoid(object : IrElementVisitorVoid {
|
element.acceptChildrenVoid(object : IrElementVisitorVoid {
|
||||||
override fun visitReturn(expression: IrReturn) {
|
override fun visitReturn(expression: IrReturn) {
|
||||||
super.visitReturn(expression)
|
super.visitReturn(expression)
|
||||||
val expectedReturnType = expectedFunctionExpressionReturnType[expression.returnTarget] ?: return
|
val expectedReturnType = expectedFunctionExpressionReturnType[expression.returnTargetSymbol.descriptor] ?: return
|
||||||
expression.value = expression.value.cast(expectedReturnType)
|
expression.value = expression.value.cast(expectedReturnType)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ internal class InsertImplicitCasts(
|
|||||||
value = if (expression.returnTargetSymbol is IrConstructorSymbol) {
|
value = if (expression.returnTargetSymbol is IrConstructorSymbol) {
|
||||||
value.coerceToUnit(irBuiltIns)
|
value.coerceToUnit(irBuiltIns)
|
||||||
} else {
|
} else {
|
||||||
val returnTargetDescriptor = expression.returnTarget
|
val returnTargetDescriptor = expression.returnTargetSymbol.descriptor
|
||||||
val isLambdaReturnValue = returnTargetDescriptor is AnonymousFunctionDescriptor
|
val isLambdaReturnValue = returnTargetDescriptor is AnonymousFunctionDescriptor
|
||||||
value.cast(returnTargetDescriptor.returnType, isLambdaReturnValue = isLambdaReturnValue)
|
value.cast(returnTargetDescriptor.returnType, isLambdaReturnValue = isLambdaReturnValue)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrReturnTarget
|
import org.jetbrains.kotlin.ir.declarations.IrReturnTarget
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
|
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.IrFileSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
|
||||||
@@ -46,8 +45,3 @@ interface IrReturnableBlock : IrBlock, IrSymbolOwner, IrReturnTarget {
|
|||||||
|
|
||||||
val IrReturnableBlock.sourceFileSymbol: IrFileSymbol?
|
val IrReturnableBlock.sourceFileSymbol: IrFileSymbol?
|
||||||
get() = inlineFunctionSymbol?.owner?.file?.symbol
|
get() = inlineFunctionSymbol?.owner?.file?.symbol
|
||||||
|
|
||||||
@Deprecated("Please avoid using it")
|
|
||||||
val IrReturnableBlock.sourceFileName: String
|
|
||||||
get() = sourceFileSymbol?.owner?.name ?: "no source file"
|
|
||||||
|
|
||||||
|
|||||||
-3
@@ -16,11 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
|
|
||||||
interface IrInstanceInitializerCall : IrExpression {
|
interface IrInstanceInitializerCall : IrExpression {
|
||||||
val classDescriptor: ClassDescriptor
|
|
||||||
val classSymbol: IrClassSymbol
|
val classSymbol: IrClassSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
|
||||||
|
|
||||||
|
|
||||||
interface IrReturn : IrExpression {
|
interface IrReturn : IrExpression {
|
||||||
var value: IrExpression
|
var value: IrExpression
|
||||||
val returnTarget: FunctionDescriptor
|
|
||||||
val returnTargetSymbol: IrReturnTargetSymbol
|
val returnTargetSymbol: IrReturnTargetSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
@@ -31,9 +29,6 @@ interface IrTry : IrExpression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IrCatch : IrElement {
|
interface IrCatch : IrElement {
|
||||||
@ObsoleteDescriptorBasedAPI
|
|
||||||
val parameter: VariableDescriptor
|
|
||||||
|
|
||||||
var catchParameter: IrVariable
|
var catchParameter: IrVariable
|
||||||
var result: IrExpression
|
var result: IrExpression
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlock
|
import org.jetbrains.kotlin.ir.expressions.IrBlock
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
|
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
@@ -43,7 +44,7 @@ class IrBlockImpl(
|
|||||||
origin: IrStatementOrigin?,
|
origin: IrStatementOrigin?,
|
||||||
statements: List<IrStatement>
|
statements: List<IrStatement>
|
||||||
) :
|
) :
|
||||||
this(startOffset, endOffset, type, origin) {
|
this(startOffset, endOffset, type, origin) {
|
||||||
this.statements.addAll(statements)
|
this.statements.addAll(statements)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,18 +65,19 @@ fun IrBlockImpl.inlineStatement(statement: IrStatement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IrReturnableBlockImpl(
|
class IrReturnableBlockImpl(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
override val symbol: IrReturnableBlockSymbol,
|
override val symbol: IrReturnableBlockSymbol,
|
||||||
origin: IrStatementOrigin? = null,
|
origin: IrStatementOrigin? = null,
|
||||||
override val inlineFunctionSymbol: IrFunctionSymbol? = null
|
override val inlineFunctionSymbol: IrFunctionSymbol? = null
|
||||||
) :
|
) :
|
||||||
IrContainerExpressionBase(startOffset, endOffset, type, origin),
|
IrContainerExpressionBase(startOffset, endOffset, type, origin),
|
||||||
IrReturnableBlock {
|
IrReturnableBlock {
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
override val descriptor = symbol.descriptor
|
override val descriptor: FunctionDescriptor
|
||||||
|
get() = symbol.descriptor
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
|
|||||||
+1
-14
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrDoWhileLoop
|
import org.jetbrains.kotlin.ir.expressions.IrDoWhileLoop
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
@@ -32,18 +31,6 @@ class IrDoWhileLoopImpl(
|
|||||||
IrLoopBase(startOffset, endOffset, type, origin),
|
IrLoopBase(startOffset, endOffset, type, origin),
|
||||||
IrDoWhileLoop {
|
IrDoWhileLoop {
|
||||||
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: IrType,
|
|
||||||
origin: IrStatementOrigin?,
|
|
||||||
body: IrExpression,
|
|
||||||
condition: IrExpression
|
|
||||||
) : this(startOffset, endOffset, type, origin) {
|
|
||||||
this.condition = condition
|
|
||||||
this.body = body
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitDoWhileLoop(this, data)
|
return visitor.visitDoWhileLoop(this, data)
|
||||||
}
|
}
|
||||||
@@ -57,4 +44,4 @@ class IrDoWhileLoopImpl(
|
|||||||
body = body?.transform(transformer, data)
|
body = body?.transform(transformer, data)
|
||||||
condition = condition.transform(transformer, data)
|
condition = condition.transform(transformer, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ir.expressions.impl
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall
|
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.symbols.IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
@@ -40,14 +39,6 @@ class IrEnumConstructorCallImpl(
|
|||||||
),
|
),
|
||||||
IrEnumConstructorCall {
|
IrEnumConstructorCall {
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: IrType,
|
|
||||||
symbol: IrConstructorSymbol
|
|
||||||
) : this(startOffset, endOffset, type, symbol, symbol.descriptor.typeParametersCount, symbol.descriptor.valueParameters.size)
|
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
constructor(
|
constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
|
|||||||
@@ -26,5 +26,6 @@ abstract class IrExpressionBase(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
override val type: IrType
|
override val type: IrType
|
||||||
) : IrElementBase(startOffset, endOffset), IrExpression {
|
) : IrElementBase(startOffset, endOffset), IrExpression {
|
||||||
|
@Suppress("LeakingThis")
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|||||||
class IrGetClassImpl(
|
class IrGetClassImpl(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType
|
type: IrType,
|
||||||
|
override var argument: IrExpression,
|
||||||
) :
|
) :
|
||||||
IrExpressionBase(startOffset, endOffset, type),
|
IrExpressionBase(startOffset, endOffset, type),
|
||||||
IrGetClass {
|
IrGetClass {
|
||||||
|
|
||||||
constructor(startOffset: Int, endOffset: Int, type: IrType, argument: IrExpression) : this(startOffset, endOffset, type) {
|
|
||||||
this.argument = argument
|
|
||||||
}
|
|
||||||
|
|
||||||
override lateinit var argument: IrExpression
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitGetClass(this, data)
|
return visitor.visitGetClass(this, data)
|
||||||
}
|
}
|
||||||
@@ -47,4 +42,4 @@ class IrGetClassImpl(
|
|||||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||||
argument = argument.transform(transformer, data)
|
argument = argument.transform(transformer, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-5
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrInstanceInitializerCall
|
import org.jetbrains.kotlin.ir.expressions.IrInstanceInitializerCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
@@ -32,9 +30,6 @@ class IrInstanceInitializerCallImpl(
|
|||||||
IrTerminalExpressionBase(startOffset, endOffset, type),
|
IrTerminalExpressionBase(startOffset, endOffset, type),
|
||||||
IrInstanceInitializerCall {
|
IrInstanceInitializerCall {
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
|
||||||
override val classDescriptor: ClassDescriptor get() = classSymbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitInstanceInitializerCall(this, data)
|
return visitor.visitInstanceInitializerCall(this, data)
|
||||||
}
|
}
|
||||||
|
|||||||
-19
@@ -16,14 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
|
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
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.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -42,23 +40,6 @@ class IrPropertyReferenceImpl(
|
|||||||
IrMemberAccessExpressionBase<IrPropertySymbol>(startOffset, endOffset, type, typeArgumentsCount, 0, origin),
|
IrMemberAccessExpressionBase<IrPropertySymbol>(startOffset, endOffset, type, typeArgumentsCount, 0, origin),
|
||||||
IrPropertyReference {
|
IrPropertyReference {
|
||||||
|
|
||||||
@Deprecated(message = "Don't use descriptor-based API for IrPropertyReference", level = DeprecationLevel.WARNING)
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: IrType,
|
|
||||||
descriptor: PropertyDescriptor,
|
|
||||||
typeArgumentsCount: Int,
|
|
||||||
field: IrFieldSymbol?,
|
|
||||||
getter: IrSimpleFunctionSymbol?,
|
|
||||||
setter: IrSimpleFunctionSymbol?,
|
|
||||||
origin: IrStatementOrigin? = null
|
|
||||||
) : this(
|
|
||||||
startOffset, endOffset, type,
|
|
||||||
IrPropertySymbolImpl(descriptor),
|
|
||||||
typeArgumentsCount, field, getter, setter, origin
|
|
||||||
)
|
|
||||||
|
|
||||||
override val referencedName: Name
|
override val referencedName: Name
|
||||||
get() = symbol.owner.name
|
get() = symbol.owner.name
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrReturn
|
import org.jetbrains.kotlin.ir.expressions.IrReturn
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
|
||||||
@@ -35,9 +33,6 @@ class IrReturnImpl(
|
|||||||
IrExpressionBase(startOffset, endOffset, type),
|
IrExpressionBase(startOffset, endOffset, type),
|
||||||
IrReturn {
|
IrReturn {
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
|
||||||
override val returnTarget: FunctionDescriptor get() = returnTargetSymbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitReturn(this, data)
|
visitor.visitReturn(this, data)
|
||||||
|
|
||||||
|
|||||||
+1
-14
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
|
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||||
@@ -30,24 +29,12 @@ class IrSetVariableImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
override val symbol: IrVariableSymbol,
|
override val symbol: IrVariableSymbol,
|
||||||
|
override var value: IrExpression,
|
||||||
override val origin: IrStatementOrigin?
|
override val origin: IrStatementOrigin?
|
||||||
) :
|
) :
|
||||||
IrExpressionBase(startOffset, endOffset, type),
|
IrExpressionBase(startOffset, endOffset, type),
|
||||||
IrSetVariable {
|
IrSetVariable {
|
||||||
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: IrType,
|
|
||||||
symbol: IrVariableSymbol,
|
|
||||||
value: IrExpression,
|
|
||||||
origin: IrStatementOrigin?
|
|
||||||
) : this(startOffset, endOffset, type, symbol, origin) {
|
|
||||||
this.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
override lateinit var value: IrExpression
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitSetVariable(this, data)
|
return visitor.visitSetVariable(this, data)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-8
@@ -24,17 +24,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|||||||
|
|
||||||
class IrSpreadElementImpl(
|
class IrSpreadElementImpl(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int
|
endOffset: Int,
|
||||||
|
override var expression: IrExpression,
|
||||||
) :
|
) :
|
||||||
IrElementBase(startOffset, endOffset),
|
IrElementBase(startOffset, endOffset),
|
||||||
IrSpreadElement {
|
IrSpreadElement {
|
||||||
|
|
||||||
constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) {
|
|
||||||
this.expression = expression
|
|
||||||
}
|
|
||||||
|
|
||||||
override lateinit var expression: IrExpression
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitSpreadElement(this, data)
|
return visitor.visitSpreadElement(this, data)
|
||||||
}
|
}
|
||||||
@@ -46,4 +41,4 @@ class IrSpreadElementImpl(
|
|||||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||||
expression = expression.transform(transformer, data)
|
expression = expression.transform(transformer, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,22 +25,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|||||||
class IrThrowImpl(
|
class IrThrowImpl(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType
|
type: IrType,
|
||||||
|
override var value: IrExpression,
|
||||||
) :
|
) :
|
||||||
IrExpressionBase(startOffset, endOffset, type),
|
IrExpressionBase(startOffset, endOffset, type),
|
||||||
IrThrow {
|
IrThrow {
|
||||||
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: IrType,
|
|
||||||
value: IrExpression
|
|
||||||
) : this(startOffset, endOffset, type) {
|
|
||||||
this.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
override lateinit var value: IrExpression
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitThrow(this, data)
|
visitor.visitThrow(this, data)
|
||||||
|
|
||||||
@@ -51,4 +41,4 @@ class IrThrowImpl(
|
|||||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||||
value = value.transform(transformer, data)
|
value = value.transform(transformer, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions.impl
|
package org.jetbrains.kotlin.ir.expressions.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.IrElementBase
|
import org.jetbrains.kotlin.ir.IrElementBase
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCatch
|
import org.jetbrains.kotlin.ir.expressions.IrCatch
|
||||||
@@ -76,19 +74,12 @@ class IrTryImpl(
|
|||||||
|
|
||||||
class IrCatchImpl(
|
class IrCatchImpl(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int
|
endOffset: Int,
|
||||||
|
override var catchParameter: IrVariable,
|
||||||
) :
|
) :
|
||||||
IrElementBase(startOffset, endOffset),
|
IrElementBase(startOffset, endOffset),
|
||||||
IrCatch {
|
IrCatch {
|
||||||
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
catchParameter: IrVariable
|
|
||||||
) : this(startOffset, endOffset) {
|
|
||||||
this.catchParameter = catchParameter
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
@@ -98,12 +89,8 @@ class IrCatchImpl(
|
|||||||
this.result = result
|
this.result = result
|
||||||
}
|
}
|
||||||
|
|
||||||
override lateinit var catchParameter: IrVariable
|
|
||||||
override lateinit var result: IrExpression
|
override lateinit var result: IrExpression
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
|
||||||
override val parameter: VariableDescriptor get() = catchParameter.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitCatch(this, data)
|
return visitor.visitCatch(this, data)
|
||||||
}
|
}
|
||||||
@@ -117,4 +104,4 @@ class IrCatchImpl(
|
|||||||
catchParameter = catchParameter.transform(transformer, data) as IrVariable
|
catchParameter = catchParameter.transform(transformer, data) as IrVariable
|
||||||
result = result.transform(transformer, data)
|
result = result.transform(transformer, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-28
@@ -30,40 +30,15 @@ class IrTypeOperatorCallImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
override val operator: IrTypeOperator,
|
override val operator: IrTypeOperator,
|
||||||
override val typeOperand: IrType
|
override val typeOperand: IrType,
|
||||||
|
override var argument: IrExpression,
|
||||||
) :
|
) :
|
||||||
IrExpressionBase(startOffset, endOffset, type),
|
IrExpressionBase(startOffset, endOffset, type),
|
||||||
IrTypeOperatorCall {
|
IrTypeOperatorCall {
|
||||||
|
|
||||||
override lateinit var argument: IrExpression
|
|
||||||
|
|
||||||
override val typeOperandClassifier: IrClassifierSymbol
|
override val typeOperandClassifier: IrClassifierSymbol
|
||||||
get() = typeOperand.classifierOrFail
|
get() = typeOperand.classifierOrFail
|
||||||
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: IrType,
|
|
||||||
operator: IrTypeOperator,
|
|
||||||
typeOperand: IrType,
|
|
||||||
argument: IrExpression
|
|
||||||
) : this(startOffset, endOffset, type, operator, typeOperand) {
|
|
||||||
this.argument = argument
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated("Doesn't require typeOperandClassifier")
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
type: IrType,
|
|
||||||
operator: IrTypeOperator,
|
|
||||||
typeOperand: IrType,
|
|
||||||
typeOperandClassifier: IrClassifierSymbol,
|
|
||||||
argument: IrExpression
|
|
||||||
) : this(startOffset, endOffset, type, operator, typeOperand) {
|
|
||||||
this.argument = argument
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitTypeOperator(this, data)
|
visitor.visitTypeOperator(this, data)
|
||||||
|
|
||||||
@@ -74,4 +49,4 @@ class IrTypeOperatorCallImpl(
|
|||||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||||
argument = argument.transform(transformer, data)
|
argument = argument.transform(transformer, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -673,9 +673,7 @@ abstract class IrFileDeserializer(
|
|||||||
val operator = deserializeTypeOperator(proto.operator)
|
val operator = deserializeTypeOperator(proto.operator)
|
||||||
val operand = deserializeIrType(proto.operand)//.brokenIr
|
val operand = deserializeIrType(proto.operand)//.brokenIr
|
||||||
val argument = deserializeExpression(proto.argument)
|
val argument = deserializeExpression(proto.argument)
|
||||||
return IrTypeOperatorCallImpl(start, end, type, operator, operand).apply {
|
return IrTypeOperatorCallImpl(start, end, type, operator, operand, argument)
|
||||||
this.argument = argument
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deserializeVararg(proto: ProtoVararg, start: Int, end: Int, type: IrType): IrVararg {
|
private fun deserializeVararg(proto: ProtoVararg, start: Int, end: Int, type: IrType): IrVararg {
|
||||||
|
|||||||
Reference in New Issue
Block a user