From 4992ca9179e0640882b8ce35102cb55f1f7160ad Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 20 Apr 2018 16:10:22 +0300 Subject: [PATCH] IR expressions: KotlinType -> IrType --- .../jvm/intrinsics/IrIntrinsicFunction.kt | 15 ++-- .../kotlin/ir/expressions/IrClassReference.kt | 4 +- .../kotlin/ir/expressions/IrExpression.kt | 4 +- .../expressions/IrMemberAccessExpression.kt | 21 +---- .../ir/expressions/IrTypeOperatorCall.kt | 4 +- .../kotlin/ir/expressions/IrVararg.kt | 4 +- .../ir/expressions/impl/IrBlockBodyImpl.kt | 1 + .../kotlin/ir/expressions/impl/IrBlockImpl.kt | 62 +++++++++---- .../expressions/impl/IrBreakContinueBase.kt | 4 +- .../kotlin/ir/expressions/impl/IrBreakImpl.kt | 4 +- .../kotlin/ir/expressions/impl/IrCallImpl.kt | 80 ++--------------- .../impl/IrCallWithIndexedArgumentsBase.kt | 5 +- .../expressions/impl/IrClassReferenceImpl.kt | 16 ++-- .../ir/expressions/impl/IrCompositeImpl.kt | 22 +++-- .../kotlin/ir/expressions/impl/IrConstImpl.kt | 28 +++--- .../impl/IrContainerExpressionBase.kt | 4 +- .../ir/expressions/impl/IrContinueImpl.kt | 4 +- .../impl/IrDeclarationReferenceBase.kt | 7 +- .../impl/IrDelegatingConstructorCallImpl.kt | 36 ++------ .../ir/expressions/impl/IrDoWhileLoopImpl.kt | 21 +++-- .../impl/IrEnumConstructorCallImpl.kt | 30 ++----- .../impl/IrErrorCallExpressionImpl.kt | 4 +- .../expressions/impl/IrErrorExpressionImpl.kt | 4 +- .../ir/expressions/impl/IrExpressionBase.kt | 4 +- .../expressions/impl/IrExpressionBodyImpl.kt | 1 + .../expressions/impl/IrFieldExpressionBase.kt | 11 ++- .../impl/IrFunctionReferenceImpl.kt | 35 +------- .../ir/expressions/impl/IrGetClassImpl.kt | 13 ++- .../ir/expressions/impl/IrGetEnumValueImpl.kt | 12 +-- .../ir/expressions/impl/IrGetFieldImpl.kt | 37 +++++--- .../expressions/impl/IrGetObjectValueImpl.kt | 12 +-- .../ir/expressions/impl/IrGetValueImpl.kt | 15 ++-- .../ir/expressions/impl/IrIfThenElseImpl.kt | 10 ++- .../impl/IrInstanceInitializerCallImpl.kt | 13 +-- .../IrLocalDelegatedPropertyReferenceImpl.kt | 4 +- .../kotlin/ir/expressions/impl/IrLoopBase.kt | 9 +- .../impl/IrMemberAccessExpressionBase.kt | 10 +-- .../IrNoArgumentsCallableReferenceBase.kt | 4 +- .../ir/expressions/impl/IrPrimitiveCall.kt | 88 ++++++++++++------- .../impl/IrPropertyAccessorCall.kt | 66 ++++---------- .../impl/IrPropertyReferenceImpl.kt | 21 +---- .../ir/expressions/impl/IrReturnImpl.kt | 28 ++---- .../ir/expressions/impl/IrSetFieldImpl.kt | 31 +++++-- .../ir/expressions/impl/IrSetVariableImpl.kt | 23 +++-- .../expressions/impl/IrSpreadElementImpl.kt | 1 + .../impl/IrStringConcatenationImpl.kt | 23 +++-- .../expressions/impl/IrSyntheticBodyImpl.kt | 7 +- .../IrTerminalDeclarationReferenceBase.kt | 8 +- .../impl/IrTerminalExpressionBase.kt | 4 +- .../kotlin/ir/expressions/impl/IrThrowImpl.kt | 6 +- .../kotlin/ir/expressions/impl/IrTryImpl.kt | 43 ++++++--- .../impl/IrTypeOperatorCallImpl.kt | 34 +++---- .../ir/expressions/impl/IrVarargImpl.kt | 16 ++-- .../kotlin/ir/expressions/impl/IrWhenImpl.kt | 51 +++++++---- .../ir/expressions/impl/IrWhileLoopImpl.kt | 13 ++- 55 files changed, 507 insertions(+), 530 deletions(-) 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 0f37a5ce73a..a281b3850a9 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 @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.resolve.calls.components.isVararg @@ -25,7 +26,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import java.util.* private class IrEmptyVarargExpression( - override val type: KotlinType, + override val type: IrType, override val startOffset: Int, override val endOffset: Int ) : IrExpression { @@ -122,13 +123,11 @@ open class IrIntrinsicFunction( } } - fun createWithResult( - expression: IrMemberAccessExpression, - signature: JvmMethodSignature, - context: JvmBackendContext, - argsTypes: List = expression.argTypes(context), - invokeInstruction: IrIntrinsicFunction.(InstructionAdapter) -> Type - ): IrIntrinsicFunction { + fun createWithResult(expression: IrMemberAccessExpression, + signature: JvmMethodSignature, + context: JvmBackendContext, + argsTypes: List = expression.argTypes(context), + invokeInstruction: IrIntrinsicFunction.(InstructionAdapter) -> Type): IrIntrinsicFunction { return object : IrIntrinsicFunction(expression, signature, context, argsTypes) { override fun genInvokeInstructionWithResult(v: InstructionAdapter) = invokeInstruction(v) 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 35675b14711..3ea1ba7f56c 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 @@ -18,12 +18,12 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType interface IrClassReference : IrDeclarationReference { override val descriptor: ClassifierDescriptor override val symbol: IrClassifierSymbol - val classType: KotlinType + val classType: IrType } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt index fec6d71e592..2b590267a76 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpression.kt @@ -17,11 +17,11 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.ir.IrStatement +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer -import org.jetbrains.kotlin.types.KotlinType interface IrExpression : IrStatement, IrVarargElement { - val type: KotlinType + val type: IrType override fun transform(transformer: IrElementTransformer, data: D): IrExpression = accept(transformer, data) as IrExpression 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 b87adb66d05..5b8170e8935 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 @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType interface IrMemberAccessExpression : IrExpression { var dispatchReceiver: IrExpression? @@ -28,8 +28,8 @@ interface IrMemberAccessExpression : IrExpression { val origin: IrStatementOrigin? val typeArgumentsCount: Int - fun getTypeArgument(index: Int): KotlinType? - fun putTypeArgument(index: Int, type: KotlinType?) + fun getTypeArgument(index: Int): IrType? + fun putTypeArgument(index: Int, type: IrType?) val valueArgumentsCount: Int fun getValueArgument(index: Int): IrExpression? @@ -37,7 +37,7 @@ interface IrMemberAccessExpression : IrExpression { fun removeValueArgument(index: Int) } -fun IrMemberAccessExpression.getTypeArgument(typeParameterDescriptor: TypeParameterDescriptor): KotlinType? = +fun IrMemberAccessExpression.getTypeArgument(typeParameterDescriptor: TypeParameterDescriptor): IrType? = getTypeArgument(typeParameterDescriptor.index) fun IrMemberAccessExpression.copyTypeArgumentsFrom(other: IrMemberAccessExpression) { @@ -49,19 +49,6 @@ fun IrMemberAccessExpression.copyTypeArgumentsFrom(other: IrMemberAccessExpressi } } -fun IrMemberAccessExpression.copyTypeArgumentsFrom(source: Map?) { - if (source == null) return - for ((typeParameter, typeArgument) in source) { - val index = typeParameter.index - assert(index < typeArgumentsCount) { - "Index out of range for type parameter $typeParameter; " + - "containingDeclaration: ${typeParameter.containingDeclaration}; " + - "callee: $descriptor" - } - putTypeArgument(index, typeArgument) - } -} - val CallableDescriptor.typeArgumentsCount: Int get() = when (this) { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt index 367cd7f0147..c233add29f7 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrTypeOperatorCall.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType enum class IrTypeOperator { CAST, @@ -33,7 +33,7 @@ enum class IrTypeOperator { interface IrTypeOperatorCall : IrExpression { val operator: IrTypeOperator var argument: IrExpression - val typeOperand: KotlinType + val typeOperand: IrType val typeOperandClassifier: IrClassifierSymbol } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt index 477d1d04ee6..6fee83b17aa 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrVararg.kt @@ -17,13 +17,13 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer -import org.jetbrains.kotlin.types.KotlinType interface IrVarargElement : IrElement interface IrVararg : IrExpression { - val varargElementType: KotlinType + val varargElementType: IrType val elements: List diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt index 0f28bd5bf25..a76f671ca0d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import java.util.* class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrBlockBody { + constructor(startOffset: Int, endOffset: Int, statements: List) : this(startOffset, endOffset) { this.statements.addAll(statements) } 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 f3c941e7a36..5ba32546122 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 @@ -23,13 +23,26 @@ import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin 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 -import org.jetbrains.kotlin.types.KotlinType -class IrBlockImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin? = null) : - IrContainerExpressionBase(startOffset, endOffset, type, origin), IrBlock { - constructor(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?, statements: List) : +class IrBlockImpl( + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin? = null +) : + IrContainerExpressionBase(startOffset, endOffset, type, origin), + IrBlock { + + constructor( + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin?, + statements: List + ) : this(startOffset, endOffset, type, origin) { this.statements.addAll(statements) } @@ -52,35 +65,48 @@ fun IrBlockImpl.inlineStatement(statement: IrStatement) { class IrReturnableBlockImpl( - startOffset: Int, endOffset: Int, type: KotlinType, - override val symbol: IrReturnableBlockSymbol, origin: IrStatementOrigin? = null, override val sourceFileName: String = "no source file" -) : IrContainerExpressionBase(startOffset, endOffset, type, origin), IrReturnableBlock { + startOffset: Int, + endOffset: Int, + type: IrType, + override val symbol: IrReturnableBlockSymbol, + origin: IrStatementOrigin? = null, + override val sourceFileName: String = "no source file" +) : + IrContainerExpressionBase(startOffset, endOffset, type, origin), + IrReturnableBlock { + override val descriptor = symbol.descriptor constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, symbol: IrReturnableBlockSymbol, origin: IrStatementOrigin?, statements: List, sourceFileName: String = "no source file" - ) : - this(startOffset, endOffset, type, symbol, origin, sourceFileName) { + ) : this(startOffset, endOffset, type, symbol, origin, sourceFileName) { this.statements.addAll(statements) } constructor( - startOffset: Int, endOffset: Int, type: KotlinType, - descriptor: FunctionDescriptor, origin: IrStatementOrigin? = null, sourceFileName: String = "no source file" - ) : - this(startOffset, endOffset, type, IrReturnableBlockSymbolImpl(descriptor), origin, sourceFileName) + startOffset: Int, + endOffset: Int, + type: IrType, + descriptor: FunctionDescriptor, + origin: IrStatementOrigin? = null, + sourceFileName: String = "no source file" + ) : this(startOffset, endOffset, type, IrReturnableBlockSymbolImpl(descriptor), origin, sourceFileName) constructor( - startOffset: Int, endOffset: Int, type: KotlinType, - descriptor: FunctionDescriptor, origin: IrStatementOrigin?, statements: List, sourceFileName: String = "no source file" - ) : - this(startOffset, endOffset, type, descriptor, origin, sourceFileName) { + startOffset: Int, + endOffset: Int, + type: IrType, + descriptor: FunctionDescriptor, + origin: IrStatementOrigin?, + statements: List, + sourceFileName: String = "no source file" + ) : this(startOffset, endOffset, type, descriptor, origin, sourceFileName) { this.statements.addAll(statements) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt index ad900678e93..31ff82511fa 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakContinueBase.kt @@ -18,12 +18,12 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrBreakContinue import org.jetbrains.kotlin.ir.expressions.IrLoop -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType abstract class IrBreakContinueBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override var loop: IrLoop ) : IrTerminalExpressionBase(startOffset, endOffset, type), IrBreakContinue { override var label: String? = null diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt index 9313aa8915b..bdae6522c19 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBreakImpl.kt @@ -18,13 +18,13 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrBreak import org.jetbrains.kotlin.ir.expressions.IrLoop +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrBreakImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, loop: IrLoop ) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrBreak { override fun accept(visitor: IrElementVisitor, data: D): R = 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 72129831c80..4f436658e24 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 @@ -18,22 +18,20 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom import org.jetbrains.kotlin.ir.expressions.typeArgumentsCount import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.createClassSymbolOrNull import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrCallImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val symbol: IrFunctionSymbol, override val descriptor: FunctionDescriptor, typeArgumentsCount: Int, @@ -51,21 +49,18 @@ class IrCallImpl( constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, symbol: IrFunctionSymbol, descriptor: FunctionDescriptor, - typeArguments: Map?, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, type, symbol, descriptor, descriptor.typeArgumentsCount, origin, superQualifierSymbol) { - copyTypeArgumentsFrom(typeArguments) - } + ) : this(startOffset, endOffset, type, symbol, descriptor, descriptor.typeArgumentsCount, origin, superQualifierSymbol) @Deprecated("Creates unbound symbols") constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, descriptor: FunctionDescriptor, typeArgumentsCount: Int, origin: IrStatementOrigin? = null, @@ -80,69 +75,8 @@ class IrCallImpl( createClassSymbolOrNull(superQualifierDescriptor) ) - @Deprecated("Creates unbound symbols") - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - descriptor: FunctionDescriptor, - typeArguments: Map? = null, - origin: IrStatementOrigin? = null, - superQualifierDescriptor: ClassDescriptor? = null - ) : this( - startOffset, endOffset, - type, - createFunctionSymbol(descriptor), - descriptor, - descriptor.typeArgumentsCount, - origin, - createClassSymbolOrNull(superQualifierDescriptor) - ) { - copyTypeArgumentsFrom(typeArguments) - } - - @Deprecated("Creates unbound symbols") - constructor( - startOffset: Int, - endOffset: Int, - descriptor: FunctionDescriptor, - typeArguments: Map? = null, - origin: IrStatementOrigin? = null, - superQualifierDescriptor: ClassDescriptor? = null - ) : this( - startOffset, endOffset, - descriptor.returnType!!, - createFunctionSymbol(descriptor), - descriptor, - descriptor.typeArgumentsCount, - origin, - createClassSymbolOrNull(superQualifierDescriptor) - ) { - copyTypeArgumentsFrom(typeArguments) - } - - constructor( - startOffset: Int, endOffset: Int, - symbol: IrFunctionSymbol, - descriptor: FunctionDescriptor, - typeArguments: Map? = null, - origin: IrStatementOrigin? = null, - superQualifierSymbol: IrClassSymbol? = null - ) : this( - startOffset, - endOffset, - descriptor.returnType!!, - symbol, - descriptor, - descriptor.typeArgumentsCount, - origin, - superQualifierSymbol - ) { - copyTypeArgumentsFrom(typeArguments) - } - - constructor(startOffset: Int, endOffset: Int, symbol: IrFunctionSymbol, origin: IrStatementOrigin? = null) : - this(startOffset, endOffset, symbol, symbol.descriptor, origin = origin) + constructor(startOffset: Int, endOffset: Int, type: IrType, symbol: IrFunctionSymbol) : + this(startOffset, endOffset, type, symbol, symbol.descriptor) override val superQualifier: ClassDescriptor? = superQualifierSymbol?.descriptor diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallWithIndexedArgumentsBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallWithIndexedArgumentsBase.kt index 11923ae71d4..34867f88021 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallWithIndexedArgumentsBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallWithIndexedArgumentsBase.kt @@ -18,15 +18,14 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.util.render +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType abstract class IrCallWithIndexedArgumentsBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, typeArgumentsCount: Int, valueArgumentsCount: Int, origin: IrStatementOrigin? = null 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 09d8dddde46..7049a5a1fae 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 @@ -23,27 +23,29 @@ import org.jetbrains.kotlin.ir.expressions.IrClassReference import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrClassReferenceImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, symbol: IrClassifierSymbol, - override val classType: KotlinType -) : IrClassReference, + override val classType: IrType +) : IrTerminalDeclarationReferenceBase( startOffset, endOffset, type, symbol, symbol.descriptor - ) { + ), + IrClassReference { + @Deprecated("Creates unbound symbols") constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, descriptor: ClassifierDescriptor, - classType: KotlinType + classType: IrType ) : this(startOffset, endOffset, type, createClassifierSymbol(descriptor), classType) override val descriptor: ClassifierDescriptor get() = symbol.descriptor diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCompositeImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCompositeImpl.kt index a89a2abb03d..6373dad96ad 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCompositeImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCompositeImpl.kt @@ -19,14 +19,26 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.expressions.IrComposite import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -class IrCompositeImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin? = null) : - IrContainerExpressionBase(startOffset, endOffset, type, origin), IrComposite { - constructor(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?, statements: List) : - this(startOffset, endOffset, type, origin) { +class IrCompositeImpl( + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin? = null +) : + IrContainerExpressionBase(startOffset, endOffset, type, origin), + IrComposite { + + constructor( + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin?, + statements: List + ) : this(startOffset, endOffset, type, origin) { this.statements.addAll(statements) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt index da7dd4b8e4d..573e435299a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstImpl.kt @@ -19,13 +19,13 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrConst import org.jetbrains.kotlin.ir.expressions.IrConstKind import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrConstImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val kind: IrConstKind, override val value: T ) : IrTerminalExpressionBase(startOffset, endOffset, type), IrConst { @@ -36,40 +36,40 @@ class IrConstImpl( IrConstImpl(startOffset, endOffset, type, kind, value) companion object { - fun string(startOffset: Int, endOffset: Int, type: KotlinType, value: String): IrConstImpl = + fun string(startOffset: Int, endOffset: Int, type: IrType, value: String): IrConstImpl = IrConstImpl(startOffset, endOffset, type, IrConstKind.String, value) - fun int(startOffset: Int, endOffset: Int, type: KotlinType, value: Int): IrConstImpl = + fun int(startOffset: Int, endOffset: Int, type: IrType, value: Int): IrConstImpl = IrConstImpl(startOffset, endOffset, type, IrConstKind.Int, value) - fun constNull(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = + fun constNull(startOffset: Int, endOffset: Int, type: IrType): IrConstImpl = IrConstImpl(startOffset, endOffset, type, IrConstKind.Null, null) - fun boolean(startOffset: Int, endOffset: Int, type: KotlinType, value: Boolean): IrConstImpl = + fun boolean(startOffset: Int, endOffset: Int, type: IrType, value: Boolean): IrConstImpl = IrConstImpl(startOffset, endOffset, type, IrConstKind.Boolean, value) - fun constTrue(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = + fun constTrue(startOffset: Int, endOffset: Int, type: IrType): IrConstImpl = boolean(startOffset, endOffset, type, true) - fun constFalse(startOffset: Int, endOffset: Int, type: KotlinType): IrConstImpl = + fun constFalse(startOffset: Int, endOffset: Int, type: IrType): IrConstImpl = boolean(startOffset, endOffset, type, false) - fun long(startOffset: Int, endOffset: Int, type: KotlinType, value: Long): IrExpression = + fun long(startOffset: Int, endOffset: Int, type: IrType, value: Long): IrExpression = IrConstImpl(startOffset, endOffset, type, IrConstKind.Long, value) - fun float(startOffset: Int, endOffset: Int, type: KotlinType, value: Float): IrExpression = + fun float(startOffset: Int, endOffset: Int, type: IrType, value: Float): IrExpression = IrConstImpl(startOffset, endOffset, type, IrConstKind.Float, value) - fun double(startOffset: Int, endOffset: Int, type: KotlinType, value: Double): IrExpression = + fun double(startOffset: Int, endOffset: Int, type: IrType, value: Double): IrExpression = IrConstImpl(startOffset, endOffset, type, IrConstKind.Double, value) - fun char(startOffset: Int, endOffset: Int, type: KotlinType, value: Char): IrExpression = + fun char(startOffset: Int, endOffset: Int, type: IrType, value: Char): IrExpression = IrConstImpl(startOffset, endOffset, type, IrConstKind.Char, value) - fun byte(startOffset: Int, endOffset: Int, type: KotlinType, value: Byte): IrExpression = + fun byte(startOffset: Int, endOffset: Int, type: IrType, value: Byte): IrExpression = IrConstImpl(startOffset, endOffset, type, IrConstKind.Byte, value) - fun short(startOffset: Int, endOffset: Int, type: KotlinType, value: Short): IrExpression = + fun short(startOffset: Int, endOffset: Int, type: IrType, value: Short): IrExpression = IrConstImpl(startOffset, endOffset, type, IrConstKind.Short, value) } } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt index c28a7b63123..e9569a48f8d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt @@ -19,16 +19,16 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.expressions.IrContainerExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.util.transform import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType import java.util.* abstract class IrContainerExpressionBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val origin: IrStatementOrigin? = null ) : IrExpressionBase(startOffset, endOffset, type), IrContainerExpression { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt index 4035f24e034..b6a17b4f72f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContinueImpl.kt @@ -18,13 +18,13 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrContinue import org.jetbrains.kotlin.ir.expressions.IrLoop +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrContinueImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, loop: IrLoop ) : IrBreakContinueBase(startOffset, endOffset, type, loop), IrContinue { override fun accept(visitor: IrElementVisitor, data: D): R = 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 f7c30c0b889..c5204c1ed27 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 @@ -19,12 +19,13 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference import org.jetbrains.kotlin.ir.symbols.IrSymbol -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType abstract class IrDeclarationReferenceBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val symbol: S, override val descriptor: D -) : IrExpressionBase(startOffset, endOffset, type), IrDeclarationReference \ No newline at end of file +) : IrExpressionBase(startOffset, endOffset, type), + IrDeclarationReference \ No newline at end of file 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 ba4b770f4ad..56b3d98d5f4 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,19 +17,16 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.IrDelegatingConstructorCall -import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom -import org.jetbrains.kotlin.ir.expressions.typeArgumentsCount import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -import org.jetbrains.kotlin.types.KotlinType class IrDelegatingConstructorCallImpl( startOffset: Int, endOffset: Int, + type: IrType, override val symbol: IrConstructorSymbol, override val descriptor: ClassConstructorDescriptor, typeArgumentsCount: Int @@ -37,49 +34,26 @@ class IrDelegatingConstructorCallImpl( IrCallWithIndexedArgumentsBase( startOffset, endOffset, - symbol.descriptor.builtIns.unitType, + type, typeArgumentsCount = typeArgumentsCount, valueArgumentsCount = symbol.descriptor.valueParameters.size ), IrDelegatingConstructorCall { - @Deprecated("Use constructor with typeArgumentsCount and fill type arguments explicitly or with copyTypeArgumentsFrom") - constructor( - startOffset: Int, - endOffset: Int, - symbol: IrConstructorSymbol, - descriptor: ClassConstructorDescriptor, - typeArguments: Map? = null - ) : this(startOffset, endOffset, symbol, descriptor, descriptor.typeArgumentsCount) { - copyTypeArgumentsFrom(typeArguments) - } - @Deprecated("Creates unbound symbol") constructor( startOffset: Int, endOffset: Int, + type: IrType, descriptor: ClassConstructorDescriptor, typeArgumentsCount: Int ) : this( - startOffset, endOffset, + startOffset, endOffset, type, IrConstructorSymbolImpl(descriptor.original), descriptor, typeArgumentsCount ) - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - descriptor: ClassConstructorDescriptor, - typeArguments: Map? = null - ) : this( - startOffset, endOffset, - IrConstructorSymbolImpl(descriptor.original), - descriptor, - typeArguments - ) - override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitDelegatingConstructorCall(this, data) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt index 78ddbe414cf..c91f2deab3d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDoWhileLoopImpl.kt @@ -19,15 +19,26 @@ package org.jetbrains.kotlin.ir.expressions.impl 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.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -class IrDoWhileLoopImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?) : - IrLoopBase(startOffset, endOffset, type, origin), IrDoWhileLoop { +class IrDoWhileLoopImpl( + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin? +) : + IrLoopBase(startOffset, endOffset, type, origin), + IrDoWhileLoop { + constructor( - startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?, - body: IrExpression, condition: IrExpression + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin?, + body: IrExpression, + condition: IrExpression ) : this(startOffset, endOffset, type, origin) { this.condition = condition this.body = body 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 0b8ff7cca56..5eff2d3c69e 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,56 +17,36 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall -import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom -import org.jetbrains.kotlin.ir.expressions.typeArgumentsCount import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -import org.jetbrains.kotlin.types.KotlinType class IrEnumConstructorCallImpl( startOffset: Int, endOffset: Int, + type: IrType, override val symbol: IrConstructorSymbol, typeArgumentsCount: Int ) : IrCallWithIndexedArgumentsBase( startOffset, endOffset, - symbol.descriptor.builtIns.unitType, + type, typeArgumentsCount = typeArgumentsCount, valueArgumentsCount = symbol.descriptor.valueParameters.size ), IrEnumConstructorCall { - @Deprecated("Use constructor with typeArgumentsCount and fill type arguments explicitly or with copyTypeArgumentsFrom") - constructor( - startOffset: Int, - endOffset: Int, - symbol: IrConstructorSymbol, - typeArguments: Map? = null - ) : this(startOffset, endOffset, symbol, symbol.descriptor.typeArgumentsCount) { - copyTypeArgumentsFrom(typeArguments) - } - @Deprecated("Creates unbound symbols") constructor( startOffset: Int, endOffset: Int, + type: IrType, descriptor: ClassConstructorDescriptor, typeArgumentsCount: Int - ) : this(startOffset, endOffset, IrConstructorSymbolImpl(descriptor), typeArgumentsCount) - - @Deprecated("Creates unbound symbols") - constructor( - startOffset: Int, - endOffset: Int, - descriptor: ClassConstructorDescriptor, - typeArguments: Map? = null - ) : this(startOffset, endOffset, IrConstructorSymbolImpl(descriptor), typeArguments) + ) : this(startOffset, endOffset, type, IrConstructorSymbolImpl(descriptor), typeArgumentsCount) override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt index 7602fb39cc1..37dff8750b6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt @@ -18,15 +18,15 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpression import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.SmartList class IrErrorCallExpressionImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val description: String ) : IrExpressionBase(startOffset, endOffset, type), IrErrorCallExpression { override var explicitReceiver: IrExpression? = null diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt index 425fbb0f6c3..26699220820 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorExpressionImpl.kt @@ -18,13 +18,13 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrErrorExpression import org.jetbrains.kotlin.ir.expressions.IrExpressionWithCopy +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrErrorExpressionImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val description: String ) : IrTerminalExpressionBase(startOffset, endOffset, type), IrExpressionWithCopy, IrErrorExpression { override fun accept(visitor: IrElementVisitor, data: D): R = diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt index 8a88aaa777d..0320af0e738 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBase.kt @@ -18,10 +18,10 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.IrElementBase import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType abstract class IrExpressionBase( startOffset: Int, endOffset: Int, - override val type: KotlinType + override val type: IrType ) : IrElementBase(startOffset, endOffset), IrExpression \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt index 8f74057827c..2c4468b3570 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrExpressionBody { + constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) { this.expression = expression } 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 4905c23d73a..7800d7a749c 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 @@ -23,17 +23,20 @@ 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.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType abstract class IrFieldExpressionBase( startOffset: Int, endOffset: Int, override val symbol: IrFieldSymbol, - type: KotlinType, + type: IrType, override val origin: IrStatementOrigin? = null, override val superQualifierSymbol: IrClassSymbol? -) : IrExpressionBase(startOffset, endOffset, type), IrFieldAccessExpression { +) : + IrExpressionBase(startOffset, endOffset, type), + IrFieldAccessExpression { + override val descriptor: PropertyDescriptor get() = symbol.descriptor override val superQualifier: ClassDescriptor? get() = superQualifierSymbol?.descriptor - override final var receiver: IrExpression? = null + 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 e12c6734913..35609dc29ff 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,20 +17,17 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.IrFunctionReference import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom -import org.jetbrains.kotlin.ir.expressions.typeArgumentsCount import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrFunctionReferenceImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val symbol: IrFunctionSymbol, override val descriptor: FunctionDescriptor, typeArgumentsCount: Int, @@ -46,42 +43,16 @@ class IrFunctionReferenceImpl( ), IrFunctionReference { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - symbol: IrFunctionSymbol, - descriptor: FunctionDescriptor, - typeArguments: Map? = null, - origin: IrStatementOrigin? = null - ) : this(startOffset, endOffset, type, symbol, descriptor, descriptor.typeArgumentsCount, origin) { - copyTypeArgumentsFrom(typeArguments) - } - @Deprecated("Creates unbound symbol") constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, descriptor: FunctionDescriptor, typeArgumentsCount: Int, origin: IrStatementOrigin? = null ) : this(startOffset, endOffset, type, createFunctionSymbol(descriptor.original), descriptor, typeArgumentsCount, origin) - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - descriptor: FunctionDescriptor, - typeArguments: Map? = null, - origin: IrStatementOrigin? = null - ) : this( - startOffset, endOffset, type, createFunctionSymbol(descriptor.original), descriptor, descriptor.typeArgumentsCount, origin - ) { - copyTypeArgumentsFrom(typeArguments) - } - override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitFunctionReference(this, data) } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt index 1c88b3f1963..32af2467cd9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt @@ -18,12 +18,19 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrGetClass +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -class IrGetClassImpl(startOffset: Int, endOffset: Int, type: KotlinType) : IrExpressionBase(startOffset, endOffset, type), IrGetClass { - constructor(startOffset: Int, endOffset: Int, type: KotlinType, argument: IrExpression) : this(startOffset, endOffset, type) { +class IrGetClassImpl( + startOffset: Int, + endOffset: Int, + type: IrType +) : + IrExpressionBase(startOffset, endOffset, type), + IrGetClass { + + constructor(startOffset: Int, endOffset: Int, type: IrType, argument: IrExpression) : this(startOffset, endOffset, type) { this.argument = argument } 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 4f99d82edf5..cb11ba08a9e 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 @@ -20,21 +20,23 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol import org.jetbrains.kotlin.ir.symbols.impl.IrEnumEntrySymbolImpl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrGetEnumValueImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, symbol: IrEnumEntrySymbol -) : IrGetEnumValue, - IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, symbol, symbol.descriptor) { +) : + IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, symbol, symbol.descriptor), + IrGetEnumValue { + @Deprecated("Creates unbound symbol") constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, descriptor: ClassDescriptor ) : this(startOffset, endOffset, type, IrEnumEntrySymbolImpl(descriptor)) 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 040f491dd3b..8603a1c37db 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 @@ -25,51 +25,64 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.createClassSymbolOrNull +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor class IrGetFieldImpl( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, symbol: IrFieldSymbol, + type: IrType, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null -) : IrGetField, - IrFieldExpressionBase(startOffset, endOffset, symbol, symbol.descriptor.type, origin, superQualifierSymbol) { +) : IrFieldExpressionBase(startOffset, endOffset, symbol, type, origin, superQualifierSymbol), + IrGetField { + @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, propertyDescriptor: PropertyDescriptor, + type: IrType, origin: IrStatementOrigin? = null, superQualifier: ClassDescriptor? = null ) : this( startOffset, endOffset, IrFieldSymbolImpl(propertyDescriptor), + type, origin, createClassSymbolOrNull(superQualifier) ) @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, propertyDescriptor: PropertyDescriptor, receiver: IrExpression?, + type: IrType, origin: IrStatementOrigin? = null, superQualifier: ClassDescriptor? = null - ) : this( - startOffset, endOffset, - IrFieldSymbolImpl(propertyDescriptor), - receiver, origin, - createClassSymbolOrNull(superQualifier) - ) + ) : + this( + startOffset, endOffset, + IrFieldSymbolImpl(propertyDescriptor), + receiver, + type, + origin, + createClassSymbolOrNull(superQualifier) + ) constructor( startOffset: Int, endOffset: Int, symbol: IrFieldSymbol, receiver: IrExpression?, + type: IrType, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, symbol, origin, superQualifierSymbol) { + ) : this(startOffset, endOffset, symbol, type, origin, superQualifierSymbol) { 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 beb3534a462..3705a1ac298 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 @@ -20,21 +20,23 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.expressions.IrGetObjectValue import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrGetObjectValueImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, symbol: IrClassSymbol -) : IrGetObjectValue, - IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, symbol, symbol.descriptor) { +) : + IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, symbol, symbol.descriptor), + IrGetObjectValue { + @Deprecated("Creates unbound symbol") constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, descriptor: ClassDescriptor ) : this(startOffset, endOffset, type, IrClassSymbolImpl(descriptor)) 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 45ab05c9fd3..17d4047c6b4 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 @@ -21,30 +21,35 @@ 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.symbols.impl.createValueSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor class IrGetValueImpl( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, symbol: IrValueSymbol, override val origin: IrStatementOrigin? = null ) : IrGetValue, IrTerminalDeclarationReferenceBase( startOffset, endOffset, - symbol.descriptor.type, + type, symbol, symbol.descriptor ) { @Deprecated("Creates unbound reference") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, descriptor: ValueDescriptor, origin: IrStatementOrigin? = null - ) : this(startOffset, endOffset, createValueSymbol(descriptor), origin) + ) : this(startOffset, endOffset, type, createValueSymbol(descriptor), origin) override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitGetValue(this, data) override fun copy(): IrGetValue = - IrGetValueImpl(startOffset, endOffset, symbol, origin) + IrGetValueImpl(startOffset, endOffset, type, symbol, origin) } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt index 6510d11585c..585d89735f7 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt @@ -19,17 +19,21 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrBranch import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.utils.SmartList class IrIfThenElseImpl( - startOffset: Int, endOffset: Int, type: KotlinType, + startOffset: Int, + endOffset: Int, + type: IrType, override val origin: IrStatementOrigin? = null ) : IrWhenBase(startOffset, endOffset, type) { override val branches: MutableList = SmartList() constructor( - startOffset: Int, endOffset: Int, type: KotlinType, + startOffset: Int, + endOffset: Int, + type: IrType, condition: IrExpression, thenBranch: IrExpression, elseBranch: IrExpression? = null, 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 1b733cb4b26..8f83108eb49 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 @@ -20,20 +20,23 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.expressions.IrInstanceInitializerCall import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns class IrInstanceInitializerCallImpl( startOffset: Int, endOffset: Int, - override val classSymbol: IrClassSymbol -) : IrTerminalExpressionBase(startOffset, endOffset, classSymbol.descriptor.builtIns.unitType), IrInstanceInitializerCall { + override val classSymbol: IrClassSymbol, + type: IrType +) : IrTerminalExpressionBase(startOffset, endOffset, type), IrInstanceInitializerCall { + @Deprecated("Creates unbound symbol") constructor( startOffset: Int, endOffset: Int, - descriptor: ClassDescriptor - ) : this(startOffset, endOffset, IrClassSymbolImpl(descriptor)) + descriptor: ClassDescriptor, + type: IrType + ) : this(startOffset, endOffset, IrClassSymbolImpl(descriptor), type) override val classDescriptor: ClassDescriptor get() = classSymbol.descriptor 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 f01128abf29..1665bac9e13 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 @@ -21,13 +21,13 @@ import org.jetbrains.kotlin.ir.expressions.IrLocalDelegatedPropertyReference import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrLocalDelegatedPropertyReferenceImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val descriptor: VariableDescriptorWithAccessors, override val delegate: IrVariableSymbol, override val getter: IrFunctionSymbol, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt index 4d7399f7f78..d8ba88762e1 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt @@ -19,14 +19,17 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrLoop import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType abstract class IrLoopBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val origin: IrStatementOrigin? -) : IrExpressionBase(startOffset, endOffset, type), IrLoop { +) : + IrExpressionBase(startOffset, endOffset, type), + IrLoop { + override var label: String? = null override lateinit var condition: IrExpression diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt index ba1cc31216c..bdfb76433ff 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt @@ -19,14 +19,14 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType abstract class IrMemberAccessExpressionBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, final override val typeArgumentsCount: Int, final override val valueArgumentsCount: Int, final override val origin: IrStatementOrigin? = null @@ -36,16 +36,16 @@ abstract class IrMemberAccessExpressionBase( override var dispatchReceiver: IrExpression? = null override var extensionReceiver: IrExpression? = null - private val typeArgumentsByIndex = arrayOfNulls(typeArgumentsCount) + private val typeArgumentsByIndex = arrayOfNulls(typeArgumentsCount) - override fun getTypeArgument(index: Int): KotlinType? { + override fun getTypeArgument(index: Int): IrType? { if (index >= typeArgumentsCount) { throw AssertionError("$this: No such type argument slot: $index") } return typeArgumentsByIndex[index] } - override fun putTypeArgument(index: Int, type: KotlinType?) { + override fun putTypeArgument(index: Int, type: IrType?) { if (index >= typeArgumentsCount) { throw AssertionError("$this: No such type argument slot: $index") } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrNoArgumentsCallableReferenceBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrNoArgumentsCallableReferenceBase.kt index 34b5381f08a..52181c1bd67 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrNoArgumentsCallableReferenceBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrNoArgumentsCallableReferenceBase.kt @@ -19,12 +19,12 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrCallableReference import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.ir.types.IrType abstract class IrNoArgumentsCallableReferenceBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, typeArgumentsCount: Int, origin: IrStatementOrigin? = null ) : IrMemberAccessExpressionBase(startOffset, endOffset, type, typeArgumentsCount, 0, origin), diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt index 3ae80f410b7..52123707314 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt @@ -25,18 +25,20 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType import java.lang.UnsupportedOperationException abstract class IrPrimitiveCallBase( startOffset: Int, endOffset: Int, + type: IrType, override val origin: IrStatementOrigin?, override val symbol: IrFunctionSymbol, override val valueArgumentsCount: Int -) : IrExpressionBase(startOffset, endOffset, symbol.descriptor.returnType!!), +) : + IrExpressionBase(startOffset, endOffset, type), IrCall { override val descriptor: FunctionDescriptor get() = symbol.descriptor @@ -45,10 +47,10 @@ abstract class IrPrimitiveCallBase( override val typeArgumentsCount: Int = 0 - override fun getTypeArgument(index: Int): KotlinType? = + override fun getTypeArgument(index: Int): IrType? = throw AssertionError("Primitive $descriptor has no type arguments") - override fun putTypeArgument(index: Int, type: KotlinType?) { + override fun putTypeArgument(index: Int, type: IrType?) { throw AssertionError("Primitive $descriptor has no type arguments") } @@ -83,9 +85,10 @@ abstract class IrPrimitiveCallBase( class IrNullaryPrimitiveImpl( startOffset: Int, endOffset: Int, + type: IrType, origin: IrStatementOrigin?, symbol: IrFunctionSymbol -) : IrPrimitiveCallBase(startOffset, endOffset, origin, symbol, 0), +) : IrPrimitiveCallBase(startOffset, endOffset, type, origin, symbol, 0), IrCallWithShallowCopy { override fun getValueArgument(index: Int): IrExpression? = null @@ -103,49 +106,56 @@ class IrNullaryPrimitiveImpl( } override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = - IrNullaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee) + IrNullaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - IrNullaryPrimitiveImpl(startOffset, endOffset, newOrigin, createFunctionSymbol(newCallee)) + IrNullaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, createFunctionSymbol(newCallee)) } class IrUnaryPrimitiveImpl( startOffset: Int, endOffset: Int, + type: IrType, origin: IrStatementOrigin?, symbol: IrFunctionSymbol -) : IrPrimitiveCallBase(startOffset, endOffset, origin, symbol, 1), +) : IrPrimitiveCallBase(startOffset, endOffset, type, origin, symbol, 1), IrCallWithShallowCopy { @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, origin: IrStatementOrigin?, functionDescriptor: FunctionDescriptor ) : this( - startOffset, endOffset, origin, + startOffset, endOffset, type, origin, createFunctionSymbol(functionDescriptor) ) @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, origin: IrStatementOrigin?, functionDescriptor: FunctionDescriptor, argument: IrExpression ) : this( - startOffset, endOffset, origin, + startOffset, endOffset, type, origin, createFunctionSymbol(functionDescriptor), argument ) constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, origin: IrStatementOrigin?, symbol: IrFunctionSymbol, argument: IrExpression - ) : this(startOffset, endOffset, origin, symbol) { + ) : this(startOffset, endOffset, type, origin, symbol) { this.argument = argument } @@ -174,49 +184,61 @@ class IrUnaryPrimitiveImpl( } override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = - IrUnaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee) + IrUnaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - IrUnaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee) + IrUnaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) } class IrBinaryPrimitiveImpl( startOffset: Int, endOffset: Int, + type: IrType, origin: IrStatementOrigin?, symbol: IrFunctionSymbol -) : IrPrimitiveCallBase(startOffset, endOffset, origin, symbol, 2), +) : IrPrimitiveCallBase(startOffset, endOffset, type, origin, symbol, 2), IrCallWithShallowCopy { + constructor( + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin?, + symbol: IrFunctionSymbol, + argument0: IrExpression, + argument1: IrExpression + ) : this(startOffset, endOffset, type, origin, symbol) { + this.argument0 = argument0 + this.argument1 = argument1 + } + @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, origin: IrStatementOrigin?, + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin?, descriptor: FunctionDescriptor ) : this( - startOffset, endOffset, origin, + startOffset, endOffset, type, origin, createFunctionSymbol(descriptor) ) @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, origin: IrStatementOrigin?, + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin?, descriptor: FunctionDescriptor, - argument0: IrExpression, argument1: IrExpression + argument0: IrExpression, + argument1: IrExpression ) : this( - startOffset, endOffset, origin, + startOffset, endOffset, type, origin, createFunctionSymbol(descriptor), argument0, argument1 ) - constructor( - startOffset: Int, endOffset: Int, origin: IrStatementOrigin?, - symbol: IrFunctionSymbol, - argument0: IrExpression, argument1: IrExpression - ) : this(startOffset, endOffset, origin, symbol) { - this.argument0 = argument0 - this.argument1 = argument1 - } - lateinit var argument0: IrExpression lateinit var argument1: IrExpression @@ -248,8 +270,8 @@ class IrBinaryPrimitiveImpl( } override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = - IrBinaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee) + IrBinaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - IrBinaryPrimitiveImpl(startOffset, endOffset, newOrigin, newCallee) + IrBinaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt index fa728be5281..8730375be3f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt @@ -18,27 +18,27 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.createClassSymbolOrNull import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType import java.lang.AssertionError import java.lang.UnsupportedOperationException abstract class IrPropertyAccessorCallBase( startOffset: Int, endOffset: Int, + type: IrType, override val symbol: IrFunctionSymbol, override val descriptor: FunctionDescriptor, typeArgumentsCount: Int, valueArgumentsCount: Int, origin: IrStatementOrigin? = null, override val superQualifierSymbol: IrClassSymbol? = null -) : IrMemberAccessExpressionBase(startOffset, endOffset, descriptor.returnType!!, typeArgumentsCount, valueArgumentsCount, origin), +) : IrMemberAccessExpressionBase(startOffset, endOffset, type, typeArgumentsCount, valueArgumentsCount, origin), IrCall { override val superQualifier: ClassDescriptor? get() = superQualifierSymbol?.descriptor @@ -55,17 +55,20 @@ abstract class IrPropertyAccessorCallBase( class IrGetterCallImpl( startOffset: Int, endOffset: Int, + type: IrType, symbol: IrFunctionSymbol, descriptor: FunctionDescriptor, typeArgumentsCount: Int, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null -) : IrPropertyAccessorCallBase(startOffset, endOffset, symbol, descriptor, typeArgumentsCount, 0, origin, superQualifierSymbol), +) : + IrPropertyAccessorCallBase(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, 0, origin, superQualifierSymbol), IrCallWithShallowCopy { constructor( startOffset: Int, endOffset: Int, + type: IrType, symbol: IrFunctionSymbol, descriptor: FunctionDescriptor, typeArgumentsCount: Int, @@ -73,29 +76,11 @@ class IrGetterCallImpl( extensionReceiver: IrExpression?, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, symbol, descriptor, typeArgumentsCount, origin, superQualifierSymbol) { + ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, origin, superQualifierSymbol) { this.dispatchReceiver = dispatchReceiver this.extensionReceiver = extensionReceiver } - constructor( - startOffset: Int, - endOffset: Int, - symbol: IrFunctionSymbol, - descriptor: FunctionDescriptor, - typeArguments: Map?, - dispatchReceiver: IrExpression?, - extensionReceiver: IrExpression?, - origin: IrStatementOrigin? = null, - superQualifierSymbol: IrClassSymbol? = null - ) : this( - startOffset, endOffset, symbol, descriptor, - descriptor.typeArgumentsCount, - dispatchReceiver, extensionReceiver, origin, superQualifierSymbol - ) { - copyTypeArgumentsFrom(typeArguments) - } - override fun getValueArgument(index: Int): IrExpression? = null override fun putValueArgument(index: Int, valueArgument: IrExpression?) { @@ -108,7 +93,7 @@ class IrGetterCallImpl( override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = IrGetterCallImpl( - startOffset, endOffset, newCallee, + startOffset, endOffset, type, newCallee, descriptor, // TODO substitute descriptor for new callee? typeArgumentsCount, dispatchReceiver, extensionReceiver, newOrigin, newSuperQualifier ).also { newCall -> @@ -117,7 +102,7 @@ class IrGetterCallImpl( override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = IrGetterCallImpl( - startOffset, endOffset, + startOffset, endOffset, type, createFunctionSymbol(newCallee), newCallee, typeArgumentsCount, @@ -132,16 +117,20 @@ class IrGetterCallImpl( class IrSetterCallImpl( startOffset: Int, endOffset: Int, + type: IrType, symbol: IrFunctionSymbol, descriptor: FunctionDescriptor, typeArgumentsCount: Int, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null -) : IrPropertyAccessorCallBase(startOffset, endOffset, symbol, descriptor, typeArgumentsCount, 1, origin, superQualifierSymbol), +) : + IrPropertyAccessorCallBase(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, 1, origin, superQualifierSymbol), IrCallWithShallowCopy { constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, symbol: IrFunctionSymbol, descriptor: FunctionDescriptor, typeArgumentsCount: Int, @@ -150,24 +139,7 @@ class IrSetterCallImpl( argument: IrExpression, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, symbol, descriptor, typeArgumentsCount, origin, superQualifierSymbol) { - this.dispatchReceiver = dispatchReceiver - this.extensionReceiver = extensionReceiver - putValueArgument(SETTER_ARGUMENT_INDEX, argument) - } - - constructor( - startOffset: Int, endOffset: Int, - symbol: IrFunctionSymbol, - descriptor: FunctionDescriptor, - typeArguments: Map?, - dispatchReceiver: IrExpression?, - extensionReceiver: IrExpression?, - argument: IrExpression, - origin: IrStatementOrigin? = null, - superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, symbol, descriptor, descriptor.typeArgumentsCount, origin, superQualifierSymbol) { - copyTypeArgumentsFrom(typeArguments) + ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, origin, superQualifierSymbol) { this.dispatchReceiver = dispatchReceiver this.extensionReceiver = extensionReceiver putValueArgument(SETTER_ARGUMENT_INDEX, argument) @@ -190,7 +162,7 @@ class IrSetterCallImpl( override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = IrSetterCallImpl( - startOffset, endOffset, newCallee, + startOffset, endOffset, type, newCallee, descriptor, // TODO substitute newCallee.descriptor? typeArgumentsCount, dispatchReceiver, extensionReceiver, argumentImpl!!, newOrigin, newSuperQualifier ).also { newCall -> @@ -199,7 +171,7 @@ class IrSetterCallImpl( override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = IrSetterCallImpl( - startOffset, endOffset, + startOffset, endOffset, type, createFunctionSymbol(newCallee), newCallee, typeArgumentsCount, 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 caccc21a960..9706f243e8c 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,20 +17,17 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.PropertyDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.IrPropertyReference import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom -import org.jetbrains.kotlin.ir.expressions.typeArgumentsCount import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrPropertyReferenceImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val descriptor: PropertyDescriptor, typeArgumentsCount: Int, override val field: IrFieldSymbol?, @@ -40,20 +37,6 @@ class IrPropertyReferenceImpl( ) : IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, typeArgumentsCount, origin), IrPropertyReference { - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - descriptor: PropertyDescriptor, - field: IrFieldSymbol?, - getter: IrFunctionSymbol?, - setter: IrFunctionSymbol?, - typeArguments: Map?, - origin: IrStatementOrigin? = null - ) : this(startOffset, endOffset, type, descriptor, descriptor.typeArgumentsCount, field, getter, setter, origin) { - copyTypeArgumentsFrom(typeArguments) - } - override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitPropertyReference(this, data) } \ No newline at end of file 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 396ba9049bc..53ebcb43ecc 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 @@ -19,39 +19,25 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrReturn -import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -import org.jetbrains.kotlin.types.KotlinType class IrReturnImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val returnTargetSymbol: IrReturnTargetSymbol, override var value: IrExpression -) : IrExpressionBase(startOffset, endOffset, type), IrReturn { - constructor(startOffset: Int, endOffset: Int, returnTargetSymbol: IrFunctionSymbol, value: IrExpression) : - this(startOffset, endOffset, returnTargetSymbol.descriptor.builtIns.nothingType, returnTargetSymbol, value) +) : + IrExpressionBase(startOffset, endOffset, type), + IrReturn { @Deprecated("Creates unbound symbol") - constructor(startOffset: Int, endOffset: Int, type: KotlinType, returnTargetDescriptor: FunctionDescriptor, value: IrExpression) : - this( - startOffset, endOffset, type, - createFunctionSymbol(returnTargetDescriptor), - value - ) - - @Deprecated("Creates unbound symbol") - constructor(startOffset: Int, endOffset: Int, returnTargetDescriptor: FunctionDescriptor, value: IrExpression) : - this( - startOffset, endOffset, returnTargetDescriptor.builtIns.nothingType, - createFunctionSymbol(returnTargetDescriptor), - value - ) + constructor(startOffset: Int, endOffset: Int, type: IrType, returnTargetDescriptor: FunctionDescriptor, value: IrExpression) : + this(startOffset, endOffset, type, createFunctionSymbol(returnTargetDescriptor), value) override val returnTarget: FunctionDescriptor get() = returnTargetSymbol.descriptor 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 9a99da4c559..1da47cc7816 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 @@ -25,48 +25,60 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.createClassSymbolOrNull +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.typeUtil.builtIns class IrSetFieldImpl( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, symbol: IrFieldSymbol, + type: IrType, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null -) : IrSetField, +) : IrFieldExpressionBase( startOffset, endOffset, symbol, - symbol.descriptor.type.builtIns.unitType, + type, origin, superQualifierSymbol - ) { + ), + IrSetField { + @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, propertyDescriptor: PropertyDescriptor, + type: IrType, origin: IrStatementOrigin? = null, superQualifier: ClassDescriptor? = null ) : this( startOffset, endOffset, IrFieldSymbolImpl(propertyDescriptor), + type, origin, createClassSymbolOrNull(superQualifier) ) @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, propertyDescriptor: PropertyDescriptor, receiver: IrExpression?, value: IrExpression, + type: IrType, origin: IrStatementOrigin? = null, superQualifier: ClassDescriptor? = null ) : this( startOffset, endOffset, IrFieldSymbolImpl(propertyDescriptor), - receiver, value, origin, + receiver, + value, + type, + origin, createClassSymbolOrNull(superQualifier) ) @@ -75,9 +87,10 @@ class IrSetFieldImpl( symbol: IrFieldSymbol, receiver: IrExpression?, value: IrExpression, + type: IrType, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, symbol, origin, superQualifierSymbol) { + ) : this(startOffset, endOffset, symbol, type, origin, superQualifierSymbol) { 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 93eb2f15747..1b48dd5d7eb 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 @@ -22,31 +22,40 @@ 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.symbols.impl.IrVariableSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns class IrSetVariableImpl( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, override val symbol: IrVariableSymbol, override val origin: IrStatementOrigin? -) : IrExpressionBase(startOffset, endOffset, symbol.descriptor.builtIns.unitType), IrSetVariable { +) : + IrExpressionBase(startOffset, endOffset, type), + IrSetVariable { + constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, symbol: IrVariableSymbol, value: IrExpression, origin: IrStatementOrigin? - ) : this(startOffset, endOffset, symbol, origin) { + ) : this(startOffset, endOffset, type, symbol, origin) { this.value = value } @Deprecated("Creates unbound symbol") constructor( - startOffset: Int, endOffset: Int, + startOffset: Int, + endOffset: Int, + type: IrType, descriptor: VariableDescriptor, value: IrExpression, origin: IrStatementOrigin? - ) : this(startOffset, endOffset, IrVariableSymbolImpl(descriptor), value, origin) + ) : this(startOffset, endOffset, type, IrVariableSymbolImpl(descriptor), value, origin) override val descriptor: VariableDescriptor get() = symbol.descriptor diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt index d6e56d068f2..e44390cc415 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt @@ -26,6 +26,7 @@ class IrSpreadElementImpl( startOffset: Int, endOffset: Int ) : IrElementBase(startOffset, endOffset), IrSpreadElement { + constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) { this.expression = expression } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt index 18f4c1434cf..b50be13813d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt @@ -18,18 +18,25 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStringConcatenation +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType import java.util.* -class IrStringConcatenationImpl(startOffset: Int, endOffset: Int, type: KotlinType) : - IrExpressionBase(startOffset, endOffset, type), IrStringConcatenation { - constructor(startOffset: Int, endOffset: Int, type: KotlinType, arguments: Collection) : this( - startOffset, - endOffset, - type - ) { +class IrStringConcatenationImpl( + startOffset: Int, + endOffset: Int, + type: IrType +) : + IrExpressionBase(startOffset, endOffset, type), + IrStringConcatenation { + + constructor( + startOffset: Int, + endOffset: Int, + type: IrType, + arguments: Collection + ) : this(startOffset, endOffset, type) { this.arguments.addAll(arguments) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt index 55eff331988..0ee2ebb70ce 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSyntheticBodyImpl.kt @@ -22,7 +22,12 @@ import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: IrSyntheticBodyKind) : IrElementBase(startOffset, endOffset), +class IrSyntheticBodyImpl( + startOffset: Int, + endOffset: Int, + override val kind: IrSyntheticBodyKind +) : + IrElementBase(startOffset, endOffset), IrSyntheticBody { override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitSyntheticBody(this, data) 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 2e5611d5cf0..14cb6682a37 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 @@ -19,17 +19,19 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.descriptors.DeclarationDescriptor 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 -import org.jetbrains.kotlin.types.KotlinType abstract class IrTerminalDeclarationReferenceBase( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, symbol: S, descriptor: D -) : IrDeclarationReferenceBase(startOffset, endOffset, type, symbol, descriptor), IrDeclarationReference { +) : IrDeclarationReferenceBase(startOffset, endOffset, type, symbol, descriptor), + IrDeclarationReference { + override fun acceptChildren(visitor: IrElementVisitor, data: D) { // No children } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt index 9b2a3c23773..a584775595c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTerminalExpressionBase.kt @@ -16,14 +16,14 @@ package org.jetbrains.kotlin.ir.expressions.impl +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType abstract class IrTerminalExpressionBase( startOffset: Int, endOffset: Int, - type: KotlinType + type: IrType ) : IrExpressionBase(startOffset, endOffset, type) { override fun acceptChildren(visitor: IrElementVisitor, data: D) { // No children diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt index 9642f5e4032..bfcc072b504 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt @@ -18,19 +18,19 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrThrow +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrThrowImpl( startOffset: Int, endOffset: Int, - type: KotlinType + type: IrType ) : IrExpressionBase(startOffset, endOffset, type), IrThrow { constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, value: IrExpression ) : this(startOffset, endOffset, type) { this.value = value diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryImpl.kt index e37cdd4e14f..6072cadaf61 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryImpl.kt @@ -22,16 +22,26 @@ import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.expressions.IrCatch import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrTry +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.SmartList -class IrTryImpl(startOffset: Int, endOffset: Int, type: KotlinType) : - IrExpressionBase(startOffset, endOffset, type), IrTry { +class IrTryImpl( + startOffset: Int, + endOffset: Int, + type: IrType +) : + IrExpressionBase(startOffset, endOffset, type), + IrTry { + constructor( - startOffset: Int, endOffset: Int, type: KotlinType, - tryResult: IrExpression, catches: List, finallyExpression: IrExpression? + startOffset: Int, + endOffset: Int, + type: IrType, + tryResult: IrExpression, + catches: List, + finallyExpression: IrExpression? ) : this(startOffset, endOffset, type) { this.tryResult = tryResult this.catches.addAll(catches) @@ -63,14 +73,27 @@ class IrTryImpl(startOffset: Int, endOffset: Int, type: KotlinType) : } } -class IrCatchImpl(startOffset: Int, endOffset: Int) : IrCatch, IrElementBase(startOffset, endOffset) { - constructor(startOffset: Int, endOffset: Int, catchParameter: IrVariable) - : this(startOffset, endOffset) { +class IrCatchImpl( + startOffset: Int, + endOffset: Int +) : + IrElementBase(startOffset, endOffset), + IrCatch { + + constructor( + startOffset: Int, + endOffset: Int, + catchParameter: IrVariable + ) : this(startOffset, endOffset) { this.catchParameter = catchParameter } - constructor(startOffset: Int, endOffset: Int, catchParameter: IrVariable, result: IrExpression) - : this(startOffset, endOffset, catchParameter) { + constructor( + startOffset: Int, + endOffset: Int, + catchParameter: IrVariable, + result: IrExpression + ) : this(startOffset, endOffset, catchParameter) { this.result = result } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt index 03cd3d7aa41..b1aa9437fc9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt @@ -20,40 +20,29 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrTypeOperator import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType class IrTypeOperatorCallImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val operator: IrTypeOperator, - override val typeOperand: KotlinType -) : IrExpressionBase(startOffset, endOffset, type), IrTypeOperatorCall { - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: KotlinType, - operator: IrTypeOperator, - typeOperand: KotlinType, - argument: IrExpression - ) : this(startOffset, endOffset, type, operator, typeOperand) { - this.argument = argument + override val typeOperand: IrType +) : + IrExpressionBase(startOffset, endOffset, type), + IrTypeOperatorCall { - val typeOperandDescriptor = typeOperand.constructor.declarationDescriptor - if (typeOperandDescriptor != null) { - this.typeOperandClassifier = createClassifierSymbol(typeOperandDescriptor) - } - } + override lateinit var argument: IrExpression + override lateinit var typeOperandClassifier: IrClassifierSymbol constructor( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, operator: IrTypeOperator, - typeOperand: KotlinType, + typeOperand: IrType, argument: IrExpression, typeOperandClassifier: IrClassifierSymbol ) : this(startOffset, endOffset, type, operator, typeOperand) { @@ -61,9 +50,6 @@ class IrTypeOperatorCallImpl( this.typeOperandClassifier = typeOperandClassifier } - override lateinit var argument: IrExpression - override lateinit var typeOperandClassifier: IrClassifierSymbol - override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitTypeOperator(this, data) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt index 6682305e7f2..c72302445f5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt @@ -18,19 +18,25 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrVararg import org.jetbrains.kotlin.ir.expressions.IrVarargElement +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.SmartList class IrVarargImpl( startOffset: Int, endOffset: Int, - type: KotlinType, - override val varargElementType: KotlinType -) : IrVararg, IrExpressionBase(startOffset, endOffset, type) { + type: IrType, + override val varargElementType: IrType +) : + IrExpressionBase(startOffset, endOffset, type), + IrVararg { + constructor( - startOffset: Int, endOffset: Int, type: KotlinType, varargElementType: KotlinType, + startOffset: Int, + endOffset: Int, + type: IrType, + varargElementType: IrType, elements: List ) : this(startOffset, endOffset, type, varargElementType) { this.elements.addAll(elements) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt index 15e56e00076..7b572462fc0 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt @@ -18,14 +18,19 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.IrElementBase import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.typeUtil.builtIns import java.util.* -abstract class IrWhenBase(startOffset: Int, endOffset: Int, type: KotlinType, override val origin: IrStatementOrigin? = null) : - IrExpressionBase(startOffset, endOffset, type), IrWhen { +abstract class IrWhenBase( + startOffset: Int, + endOffset: Int, + type: IrType, + override val origin: IrStatementOrigin? = null +) : IrExpressionBase(startOffset, endOffset, type), + IrWhen { + override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitWhen(this, data) @@ -43,11 +48,15 @@ abstract class IrWhenBase(startOffset: Int, endOffset: Int, type: KotlinType, ov class IrWhenImpl( startOffset: Int, endOffset: Int, - type: KotlinType, + type: IrType, override val origin: IrStatementOrigin? = null ) : IrWhenBase(startOffset, endOffset, type) { + constructor( - startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?, + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin?, branches: List ) : this(startOffset, endOffset, type, origin) { this.branches.addAll(branches) @@ -56,9 +65,15 @@ class IrWhenImpl( override val branches: MutableList = ArrayList() } -open class IrBranchImpl(startOffset: Int, endOffset: Int, override var condition: IrExpression, override var result: IrExpression) : - IrElementBase(startOffset, endOffset), IrBranch { - constructor(condition: IrExpression, result: IrExpression) : this(condition.startOffset, condition.endOffset, condition, result) +open class IrBranchImpl( + startOffset: Int, + endOffset: Int, + override var condition: IrExpression, + override var result: IrExpression +) : IrElementBase(startOffset, endOffset), IrBranch { + + constructor(condition: IrExpression, result: IrExpression) : + this(condition.startOffset, condition.endOffset, condition, result) override fun acceptChildren(visitor: IrElementVisitor, data: D) { condition.accept(visitor, data) @@ -70,16 +85,16 @@ open class IrBranchImpl(startOffset: Int, endOffset: Int, override var condition result = result.transform(transformer, data) } - companion object { - fun elseBranch(result: IrExpression) = - IrElseBranchImpl( - IrConstImpl.boolean(result.startOffset, result.endOffset, result.type.builtIns.booleanType, true), - result - ) - } } -class IrElseBranchImpl(startOffset: Int, endOffset: Int, condition: IrExpression, result: IrExpression) : - IrBranchImpl(startOffset, endOffset, condition, result), IrElseBranch { +class IrElseBranchImpl( + startOffset: Int, + endOffset: Int, + condition: IrExpression, + result: IrExpression +) : + IrBranchImpl(startOffset, endOffset, condition, result), + IrElseBranch { + constructor(condition: IrExpression, result: IrExpression) : this(condition.startOffset, condition.endOffset, condition, result) } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt index c698681a94d..16d3e079fc5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhileLoopImpl.kt @@ -18,12 +18,19 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.expressions.IrWhileLoop +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.types.KotlinType -class IrWhileLoopImpl(startOffset: Int, endOffset: Int, type: KotlinType, origin: IrStatementOrigin?) : - IrLoopBase(startOffset, endOffset, type, origin), IrWhileLoop { +class IrWhileLoopImpl( + startOffset: Int, + endOffset: Int, + type: IrType, + origin: IrStatementOrigin? +) : + IrLoopBase(startOffset, endOffset, type, origin), + IrWhileLoop { + override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitWhileLoop(this, data) }