From 0c8e58936c18a9ab63e37475d906576b3b1b98c8 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 7 Mar 2019 17:43:54 +0100 Subject: [PATCH] Remove DeepCopyIrTree and most "Creates unbound symbol" deprecated members --- .../ir/builders/IrMemberFunctionBuilder.kt | 55 -- .../impl/IrAnonymousInitializerImpl.kt | 23 +- .../ir/declarations/impl/IrClassImpl.kt | 21 - .../ir/declarations/impl/IrConstructorImpl.kt | 23 +- .../ir/declarations/impl/IrEnumEntryImpl.kt | 23 +- .../ir/declarations/impl/IrFieldImpl.kt | 11 - .../kotlin/ir/declarations/impl/IrFileImpl.kt | 10 - .../ir/declarations/impl/IrFunctionImpl.kt | 15 +- .../declarations/impl/IrValueParameterImpl.kt | 14 +- .../jetbrains/kotlin/ir/expressions/IrCall.kt | 5 - .../kotlin/ir/expressions/impl/IrCallImpl.kt | 32 +- .../expressions/impl/IrClassReferenceImpl.kt | 20 - .../impl/IrDelegatingConstructorCallImpl.kt | 18 +- .../impl/IrEnumConstructorCallImpl.kt | 12 +- .../impl/IrFunctionReferenceImpl.kt | 16 +- .../ir/expressions/impl/IrGetEnumValueImpl.kt | 11 +- .../ir/expressions/impl/IrGetFieldImpl.kt | 42 +- .../expressions/impl/IrGetObjectValueImpl.kt | 11 +- .../ir/expressions/impl/IrGetValueImpl.kt | 12 +- .../impl/IrInstanceInitializerCallImpl.kt | 11 +- .../ir/expressions/impl/IrPrimitiveCall.kt | 65 -- .../impl/IrPropertyAccessorCall.kt | 33 - .../ir/expressions/impl/IrReturnImpl.kt | 7 +- .../ir/expressions/impl/IrSetFieldImpl.kt | 42 +- .../ir/expressions/impl/IrSetVariableImpl.kt | 13 +- .../kotlin/ir/symbols/impl/IrSymbolBase.kt | 12 +- .../kotlin/ir/util/DeepCopyIrTree.kt | 692 ------------------ .../kotlin/ir/AbstractIrTextTestCase.kt | 4 - 28 files changed, 26 insertions(+), 1227 deletions(-) delete mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt delete mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt deleted file mode 100644 index acbbad7385c..00000000000 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir.builders - -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl -import org.jetbrains.kotlin.ir.declarations.putDefault -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.types.IrType - -// This class can be used by kotlin-native. -@Suppress("unused") -@Deprecated("Migrate to symbols") -class IrMemberFunctionBuilder( - context: IrGeneratorContext, - val irClass: IrClass, - val function: FunctionDescriptor, - val returnType: IrType, - val origin: IrDeclarationOrigin, - startOffset: Int = UNDEFINED_OFFSET, - endOffset: Int = UNDEFINED_OFFSET -) : IrBlockBodyBuilder(context, Scope(function), startOffset, endOffset) { - lateinit var irFunction: IrFunction - - inline fun addToClass(body: IrMemberFunctionBuilder.(IrFunction) -> Unit): IrFunction { - irFunction = IrFunctionImpl(startOffset, endOffset, origin, function, returnType) - body(irFunction) - irFunction.body = doBuild() - irClass.declarations.add(irFunction) - return irFunction - } - - fun putDefault(parameter: ValueParameterDescriptor, value: IrExpression) { - irFunction.putDefault(parameter, irExprBody(value)) - } -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt index f14451967ae..843deb21cd6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.declarations.IrAnonymousInitializer import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.symbols.IrAnonymousInitializerSymbol -import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -34,26 +33,6 @@ class IrAnonymousInitializerImpl( ) : IrDeclarationBase(startOffset, endOffset, origin), IrAnonymousInitializer { - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassDescriptor, - isStatic: Boolean = false - ) : - this(startOffset, endOffset, origin, IrAnonymousInitializerSymbolImpl(descriptor), isStatic) - - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassDescriptor, - body: IrBlockBody, - isStatic: Boolean = false - ) : this(startOffset, endOffset, origin, descriptor, isStatic) { - this.body = body - } - init { symbol.bind(this) } @@ -73,4 +52,4 @@ class IrAnonymousInitializerImpl( override fun transformChildren(transformer: IrElementTransformer, data: D) { body = body.transform(transformer, data) as IrBlockBody } -} \ No newline at end of file +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt index 8a24521b175..bddcf3e26cc 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.ir.declarations.* 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.util.transform import org.jetbrains.kotlin.ir.visitors.IrElementTransformer @@ -68,26 +67,6 @@ class IrClassImpl( isInline = symbol.descriptor.isInline ) - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassDescriptor, - modality: Modality = descriptor.modality - ) : - this(startOffset, endOffset, origin, IrClassSymbolImpl(descriptor), modality) - - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassDescriptor, - modality: Modality = descriptor.modality, - members: List = emptyList() - ) : this(startOffset, endOffset, origin, descriptor, modality) { - addAll(members) - } - init { symbol.bind(this) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt index 722a262a5a8..eb8005f05f5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.ir.declarations.IrConstructor import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.expressions.IrBody 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.name.Name @@ -65,26 +64,6 @@ class IrConstructorImpl( this.body = body } - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassConstructorDescriptor, - returnType: IrType - ) : this(startOffset, endOffset, origin, IrConstructorSymbolImpl(descriptor), returnType) - - @Deprecated("Use constructor which takes symbol instead of descriptor") - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassConstructorDescriptor, - returnType: IrType, - body: IrBody? - ) : this(startOffset, endOffset, origin, descriptor, returnType) { - this.body = body - } - init { symbol.bind(this) } @@ -93,4 +72,4 @@ class IrConstructorImpl( override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitConstructor(this, data) -} \ No newline at end of file +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt index 246af435acf..afc2327e072 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrEnumEntry import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol -import org.jetbrains.kotlin.ir.symbols.impl.IrEnumEntrySymbolImpl import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.name.Name @@ -44,26 +43,6 @@ class IrEnumEntryImpl( ) : this(startOffset, endOffset, origin, symbol, symbol.descriptor.name) - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassDescriptor - ) : - this(startOffset, endOffset, origin, IrEnumEntrySymbolImpl(descriptor)) - - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ClassDescriptor, - correspondingClass: IrClass?, - initializerExpression: IrExpression? - ) : this(startOffset, endOffset, origin, descriptor) { - this.correspondingClass = correspondingClass - this.initializerExpression = initializerExpression - } - init { symbol.bind(this) } @@ -85,4 +64,4 @@ class IrEnumEntryImpl( initializerExpression = initializerExpression?.transform(transformer, data) correspondingClass = correspondingClass?.transform(transformer, data) as? IrClass } -} \ No newline at end of file +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt index 746dcb80beb..0afe1a3f8ca 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt @@ -70,17 +70,6 @@ class IrFieldImpl( ) : this(startOffset, endOffset, origin, IrFieldSymbolImpl(descriptor), type) - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: PropertyDescriptor, - type: IrType, - initializer: IrExpressionBody? - ) : this(startOffset, endOffset, origin, descriptor, type) { - this.initializer = initializer - } - init { symbol.bind(this) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt index d018c25accd..395f51ce900 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt @@ -51,16 +51,6 @@ class IrFileImpl( ) : this(fileEntry, IrFileSymbolImpl(packageFragmentDescriptor), packageFragmentDescriptor.fqName) - constructor( - fileEntry: SourceManager.FileEntry, - packageFragmentDescriptor: PackageFragmentDescriptor, - fileAnnotations: List, - declarations: List - ) : this(fileEntry, packageFragmentDescriptor) { - this.fileAnnotations.addAll(fileAnnotations) - this.declarations.addAll(declarations) - } - init { symbol.bind(this) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt index f6dd581723c..e4af0e30687 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrProperty import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction -import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.types.IrType @@ -62,6 +61,7 @@ class IrFunctionImpl( override var correspondingProperty: IrProperty? = null + // Used by kotlin-native in InteropLowering.kt and IrUtils2.kt constructor( startOffset: Int, endOffset: Int, @@ -73,21 +73,10 @@ class IrFunctionImpl( IrSimpleFunctionSymbolImpl(descriptor), returnType ) - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: FunctionDescriptor, - returnType: IrType, - body: IrBody? - ) : this(startOffset, endOffset, origin, descriptor, returnType) { - this.body = body - } - init { symbol.bind(this) } override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitSimpleFunction(this, data) -} \ No newline at end of file +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt index bc69883fd11..1c7b124d050 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt @@ -73,18 +73,6 @@ class IrValueParameterImpl( ) : this(startOffset, endOffset, origin, IrValueParameterSymbolImpl(descriptor), type, varargElementType) - constructor( - startOffset: Int, - endOffset: Int, - origin: IrDeclarationOrigin, - descriptor: ParameterDescriptor, - type: IrType, - varargElementType: IrType?, - defaultValue: IrExpressionBody? - ) : this(startOffset, endOffset, origin, descriptor, type, varargElementType) { - this.defaultValue = defaultValue - } - override val descriptor: ParameterDescriptor = symbol.descriptor init { @@ -106,4 +94,4 @@ class IrValueParameterImpl( override fun transformChildren(transformer: IrElementTransformer, data: D) { defaultValue = defaultValue?.transform(transformer, data) } -} \ No newline at end of file +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt index 2e3766e983b..b14eabb484f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCall.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol @@ -28,8 +27,4 @@ interface IrCall : IrFunctionAccessExpression { interface IrCallWithShallowCopy : IrCall { fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall - - @Deprecated("Creates unbound symbols") - fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall } - 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 e765c5872be..53ae18eaacc 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 @@ -23,8 +23,6 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.expressions.typeParametersCount import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol -import org.jetbrains.kotlin.ir.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 @@ -55,8 +53,10 @@ class IrCallImpl( descriptor: FunctionDescriptor, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, type, symbol, descriptor, descriptor.typeParametersCount, - descriptor.valueParameters.size, origin, superQualifierSymbol) + ) : this( + startOffset, endOffset, type, symbol, descriptor, descriptor.typeParametersCount, + descriptor.valueParameters.size, origin, superQualifierSymbol + ) constructor( startOffset: Int, @@ -67,27 +67,9 @@ class IrCallImpl( typeArgumentsCount: Int, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null - ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, - descriptor.valueParameters.size, origin, superQualifierSymbol) - - @Deprecated("Creates unbound symbols") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: FunctionDescriptor, - typeArgumentsCount: Int, - origin: IrStatementOrigin? = null, - superQualifierDescriptor: ClassDescriptor? = null ) : this( - startOffset, endOffset, - type, - createFunctionSymbol(descriptor), - descriptor, - typeArgumentsCount, - descriptor.valueParameters.size, - origin, - createClassSymbolOrNull(superQualifierDescriptor) + startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, + descriptor.valueParameters.size, origin, superQualifierSymbol ) constructor(startOffset: Int, endOffset: Int, type: IrType, symbol: IrFunctionSymbol) : @@ -98,4 +80,4 @@ class IrCallImpl( override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitCall(this, data) -} \ No newline at end of file +} 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 7049a5a1fae..cf126d768c7 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 @@ -16,13 +16,9 @@ package org.jetbrains.kotlin.ir.expressions.impl -import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor 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 @@ -39,24 +35,8 @@ class IrClassReferenceImpl( ), IrClassReference { - @Deprecated("Creates unbound symbols") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: ClassifierDescriptor, - classType: IrType - ) : this(startOffset, endOffset, type, createClassifierSymbol(descriptor), classType) - override val descriptor: ClassifierDescriptor get() = symbol.descriptor override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitClassReference(this, data) } - -internal fun createClassifierSymbol(descriptor: ClassifierDescriptor): IrClassifierSymbol = - when (descriptor) { - is ClassDescriptor -> IrClassSymbolImpl(descriptor) - is TypeParameterDescriptor -> IrTypeParameterSymbolImpl(descriptor) - else -> throw IllegalArgumentException("Unexpected referenced classifier: $descriptor") - } \ 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 12d6739af6d..001548b87d7 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 @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor import org.jetbrains.kotlin.ir.expressions.IrDelegatingConstructorCall import org.jetbrains.kotlin.ir.expressions.typeParametersCount import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -66,22 +65,7 @@ class IrDelegatingConstructorCallImpl( typeArgumentsCount: Int ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, descriptor.valueParameters.size) - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: ClassConstructorDescriptor, - typeArgumentsCount: Int - ) : this( - startOffset, endOffset, type, - IrConstructorSymbolImpl(descriptor.original), - descriptor, - typeArgumentsCount, - descriptor.valueParameters.size - ) - override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitDelegatingConstructorCall(this, data) } -} \ No newline at end of file +} 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 9613cf1d98c..ba7c70dbecc 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 @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall import org.jetbrains.kotlin.ir.expressions.typeParametersCount import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol -import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -56,18 +55,9 @@ class IrEnumConstructorCallImpl( typeArgumentsCount: Int ) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size) - @Deprecated("Creates unbound symbols") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: ClassConstructorDescriptor, - typeArgumentsCount: Int - ) : this(startOffset, endOffset, type, IrConstructorSymbolImpl(descriptor), typeArgumentsCount, descriptor.valueParameters.size) - override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitEnumConstructorCall(this, data) } -} \ 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 fe44ac2964a..9af008f9ffe 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 @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.ir.expressions.IrFunctionReference import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol -import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -52,19 +51,8 @@ class IrFunctionReferenceImpl( descriptor: FunctionDescriptor, typeArgumentsCount: Int, origin: IrStatementOrigin? = null - ): this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, descriptor.valueParameters.size, origin) - - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: FunctionDescriptor, - typeArgumentsCount: Int, - origin: IrStatementOrigin? = null - ) : this(startOffset, endOffset, type, createFunctionSymbol(descriptor.original), descriptor, - typeArgumentsCount, descriptor.valueParameters.size, origin) + ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, descriptor.valueParameters.size, origin) 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/IrGetEnumValueImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetEnumValueImpl.kt index cb11ba08a9e..359e3ed3d2f 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 @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.ir.expressions.impl 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 @@ -32,15 +31,7 @@ class IrGetEnumValueImpl( IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, symbol, symbol.descriptor), IrGetEnumValue { - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: ClassDescriptor - ) : this(startOffset, endOffset, type, IrEnumEntrySymbolImpl(descriptor)) - override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitGetEnumValue(this, data) } -} \ No newline at end of file +} 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 9b9ebe4e392..7a4edd93aeb 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetFieldImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetFieldImpl.kt @@ -16,15 +16,11 @@ package org.jetbrains.kotlin.ir.expressions.impl -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrGetField import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol -import org.jetbrains.kotlin.ir.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 @@ -40,42 +36,6 @@ class IrGetFieldImpl( IrFieldExpressionBase(startOffset, endOffset, symbol, type, origin, superQualifierSymbol), IrGetField { - @Deprecated("Creates unbound symbol") - constructor( - 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, - propertyDescriptor: PropertyDescriptor, - receiver: IrExpression?, - type: IrType, - origin: IrStatementOrigin? = null, - superQualifier: ClassDescriptor? = null - ) : - this( - startOffset, endOffset, - IrFieldSymbolImpl(propertyDescriptor), - type, - receiver, - origin, - createClassSymbolOrNull(superQualifier) - ) - - constructor( startOffset: Int, endOffset: Int, symbol: IrFieldSymbol, @@ -98,4 +58,4 @@ class IrGetFieldImpl( override fun transformChildren(transformer: IrElementTransformer, data: D) { receiver = receiver?.transform(transformer, data) } -} \ No newline at end of file +} 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 3705a1ac298..24f715a84d9 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 @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.ir.expressions.impl 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 @@ -32,14 +31,6 @@ class IrGetObjectValueImpl( IrTerminalDeclarationReferenceBase(startOffset, endOffset, type, symbol, symbol.descriptor), IrGetObjectValue { - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: ClassDescriptor - ) : this(startOffset, endOffset, type, IrClassSymbolImpl(descriptor)) - override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitGetObjectValue(this, data) -} \ No newline at end of file +} 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 56b5688d201..87c2676004a 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 @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.descriptors.ValueDescriptor 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 @@ -36,18 +35,9 @@ class IrGetValueImpl( origin: IrStatementOrigin? = null ) : this(startOffset, endOffset, symbol.owner.type, symbol, origin) - @Deprecated("Creates unbound reference") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: ValueDescriptor, - origin: IrStatementOrigin? = null - ) : 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, type, symbol, origin) -} \ No newline at end of file +} 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 849a6819635..f25f0140acb 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 @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.ir.expressions.impl 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 @@ -32,17 +31,9 @@ class IrInstanceInitializerCallImpl( IrTerminalExpressionBase(startOffset, endOffset, type), IrInstanceInitializerCall { - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - descriptor: ClassDescriptor, - type: IrType - ) : this(startOffset, endOffset, IrClassSymbolImpl(descriptor), type) - override val classDescriptor: ClassDescriptor get() = classSymbol.descriptor override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitInstanceInitializerCall(this, data) } -} \ No newline at end of file +} 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 52123707314..cb7d7055358 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 @@ -24,11 +24,9 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression 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 java.lang.UnsupportedOperationException abstract class IrPrimitiveCallBase( startOffset: Int, @@ -107,9 +105,6 @@ class IrNullaryPrimitiveImpl( override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = IrNullaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) - - override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - IrNullaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, createFunctionSymbol(newCallee)) } class IrUnaryPrimitiveImpl( @@ -121,33 +116,6 @@ class IrUnaryPrimitiveImpl( ) : IrPrimitiveCallBase(startOffset, endOffset, type, origin, symbol, 1), IrCallWithShallowCopy { - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - origin: IrStatementOrigin?, - functionDescriptor: FunctionDescriptor - ) : this( - startOffset, endOffset, type, origin, - createFunctionSymbol(functionDescriptor) - ) - - - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - origin: IrStatementOrigin?, - functionDescriptor: FunctionDescriptor, - argument: IrExpression - ) : this( - startOffset, endOffset, type, origin, - createFunctionSymbol(functionDescriptor), - argument - ) - constructor( startOffset: Int, endOffset: Int, @@ -185,9 +153,6 @@ class IrUnaryPrimitiveImpl( override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = IrUnaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) - - override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - IrUnaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) } class IrBinaryPrimitiveImpl( @@ -212,33 +177,6 @@ class IrBinaryPrimitiveImpl( this.argument1 = argument1 } - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - origin: IrStatementOrigin?, - descriptor: FunctionDescriptor - ) : this( - startOffset, endOffset, type, origin, - createFunctionSymbol(descriptor) - ) - - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - origin: IrStatementOrigin?, - descriptor: FunctionDescriptor, - argument0: IrExpression, - argument1: IrExpression - ) : this( - startOffset, endOffset, type, origin, - createFunctionSymbol(descriptor), - argument0, argument1 - ) - lateinit var argument0: IrExpression lateinit var argument1: IrExpression @@ -271,7 +209,4 @@ class IrBinaryPrimitiveImpl( override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = IrBinaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) - - override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - 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 42d166da87b..1db2cc849ef 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 @@ -21,13 +21,9 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor 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 java.lang.AssertionError -import java.lang.UnsupportedOperationException abstract class IrPropertyAccessorCallBase( startOffset: Int, endOffset: Int, @@ -100,20 +96,6 @@ class IrGetterCallImpl( ).also { newCall -> newCall.copyTypeArgumentsFrom(this) } - - override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - IrGetterCallImpl( - startOffset, endOffset, type, - createFunctionSymbol(newCallee), - newCallee, - typeArgumentsCount, - dispatchReceiver, - extensionReceiver, - newOrigin, - createClassSymbolOrNull(newSuperQualifier) - ).also { newCall -> - newCall.copyTypeArgumentsFrom(this) - } } class IrSetterCallImpl( @@ -170,21 +152,6 @@ class IrSetterCallImpl( newCall.copyTypeArgumentsFrom(this) } - override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: FunctionDescriptor, newSuperQualifier: ClassDescriptor?): IrCall = - IrSetterCallImpl( - startOffset, endOffset, type, - createFunctionSymbol(newCallee), - newCallee, - typeArgumentsCount, - dispatchReceiver, - extensionReceiver, - argumentImpl!!, - newOrigin, - createClassSymbolOrNull(newSuperQualifier) - ).also { newCall -> - newCall.copyTypeArgumentsFrom(this) - } - override fun transformChildren(transformer: IrElementTransformer, data: D) { super.transformChildren(transformer, data) argumentImpl = argumentImpl?.transform(transformer, data) 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 53ebcb43ecc..04e669ff8ae 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 @@ -20,7 +20,6 @@ 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.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 @@ -35,10 +34,6 @@ class IrReturnImpl( IrExpressionBase(startOffset, endOffset, type), IrReturn { - @Deprecated("Creates unbound symbol") - 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 override fun accept(visitor: IrElementVisitor, data: D): R = @@ -51,4 +46,4 @@ class IrReturnImpl( override fun transformChildren(transformer: IrElementTransformer, data: D) { value = value.transform(transformer, data) } -} \ No newline at end of file +} 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 1da47cc7816..b3fe569a7ee 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetFieldImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetFieldImpl.kt @@ -16,15 +16,11 @@ package org.jetbrains.kotlin.ir.expressions.impl -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrSetField import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol -import org.jetbrains.kotlin.ir.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 @@ -46,42 +42,6 @@ class IrSetFieldImpl( ), IrSetField { - @Deprecated("Creates unbound symbol") - constructor( - 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, - propertyDescriptor: PropertyDescriptor, - receiver: IrExpression?, - value: IrExpression, - type: IrType, - origin: IrStatementOrigin? = null, - superQualifier: ClassDescriptor? = null - ) : this( - startOffset, endOffset, - IrFieldSymbolImpl(propertyDescriptor), - receiver, - value, - type, - origin, - createClassSymbolOrNull(superQualifier) - ) - constructor( startOffset: Int, endOffset: Int, symbol: IrFieldSymbol, @@ -110,4 +70,4 @@ class IrSetFieldImpl( receiver = receiver?.transform(transformer, data) value = value.transform(transformer, data) } -} \ No newline at end of file +} 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 1b48dd5d7eb..ec1ae7f4417 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 @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrSetVariable import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol -import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -47,16 +46,6 @@ class IrSetVariableImpl( this.value = value } - @Deprecated("Creates unbound symbol") - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - descriptor: VariableDescriptor, - value: IrExpression, - origin: IrStatementOrigin? - ) : this(startOffset, endOffset, type, IrVariableSymbolImpl(descriptor), value, origin) - override val descriptor: VariableDescriptor get() = symbol.descriptor override lateinit var value: IrExpression @@ -72,4 +61,4 @@ class IrSetVariableImpl( override fun transformChildren(transformer: IrElementTransformer, data: D) { value = value.transform(transformer, data) } -} \ No newline at end of file +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt index 16946398179..b964481d98a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt @@ -70,9 +70,6 @@ class IrClassSymbolImpl(descriptor: ClassDescriptor) : IrBindableSymbolBase(descriptor), IrClassSymbol -fun createClassSymbolOrNull(descriptor: ClassDescriptor?) = - descriptor?.let { IrClassSymbolImpl(it) } - class IrEnumEntrySymbolImpl(descriptor: ClassDescriptor) : IrBindableSymbolBase(descriptor), IrEnumEntrySymbol @@ -93,13 +90,6 @@ class IrVariableSymbolImpl(descriptor: VariableDescriptor) : IrBindableSymbolBase(descriptor), IrVariableSymbol -fun createValueSymbol(descriptor: ValueDescriptor): IrValueSymbol = - when (descriptor) { - is ParameterDescriptor -> IrValueParameterSymbolImpl(descriptor) - is VariableDescriptor -> IrVariableSymbolImpl(descriptor) - else -> throw IllegalArgumentException("Unexpected descriptor kind: $descriptor") - } - class IrSimpleFunctionSymbolImpl(descriptor: FunctionDescriptor) : IrBindableSymbolBase(descriptor), IrSimpleFunctionSymbol @@ -117,4 +107,4 @@ fun createFunctionSymbol(descriptor: CallableMemberDescriptor): IrFunctionSymbol class IrReturnableBlockSymbolImpl(descriptor: FunctionDescriptor) : IrBindableSymbolBase(descriptor), - IrReturnableBlockSymbol \ No newline at end of file + IrReturnableBlockSymbol diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt deleted file mode 100644 index 74059862e71..00000000000 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt +++ /dev/null @@ -1,692 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.ir.util - -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.IrStatement -import org.jetbrains.kotlin.ir.SourceManager -import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.declarations.impl.* -import org.jetbrains.kotlin.ir.expressions.* -import org.jetbrains.kotlin.ir.expressions.impl.* -import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol -import org.jetbrains.kotlin.ir.symbols.impl.* -import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid - -@Suppress("DEPRECATION") -inline fun T.deepCopyOld(): T = - transform(DeepCopyIrTree(), null).patchDeclarationParents() as T - -@Deprecated("Creates unbound symbols") -@Suppress("DEPRECATION") -open class DeepCopyIrTree : IrElementTransformerVoid() { - - protected open fun mapDeclarationOrigin(declarationOrigin: IrDeclarationOrigin) = declarationOrigin - protected open fun mapStatementOrigin(statementOrigin: IrStatementOrigin?) = statementOrigin - protected open fun mapFileEntry(fileEntry: SourceManager.FileEntry) = fileEntry - - protected open fun mapModuleDescriptor(descriptor: ModuleDescriptor) = descriptor - protected open fun mapPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor) = descriptor - protected open fun mapClassDeclaration(descriptor: ClassDescriptor) = descriptor - protected open fun mapTypeAliasDeclaration(descriptor: TypeAliasDescriptor) = descriptor - protected open fun mapFunctionDeclaration(descriptor: FunctionDescriptor) = descriptor - protected open fun mapConstructorDeclaration(descriptor: ClassConstructorDescriptor) = descriptor - protected open fun mapPropertyDeclaration(descriptor: PropertyDescriptor) = descriptor - protected open fun mapLocalPropertyDeclaration(descriptor: VariableDescriptorWithAccessors) = descriptor - protected open fun mapEnumEntryDeclaration(descriptor: ClassDescriptor) = descriptor - protected open fun mapVariableDeclaration(descriptor: VariableDescriptor) = descriptor - protected open fun mapErrorDeclaration(descriptor: DeclarationDescriptor) = descriptor - - protected open fun mapSuperQualifier(qualifier: ClassDescriptor?) = qualifier - protected open fun mapClassReference(descriptor: ClassDescriptor) = descriptor - protected open fun mapValueReference(descriptor: ValueDescriptor) = descriptor - protected open fun mapVariableReference(descriptor: VariableDescriptor) = descriptor - protected open fun mapPropertyReference(descriptor: PropertyDescriptor) = descriptor - protected open fun mapCallee(descriptor: FunctionDescriptor) = descriptor - protected open fun mapDelegatedConstructorCallee(descriptor: ClassConstructorDescriptor) = descriptor - protected open fun mapEnumConstructorCallee(descriptor: ClassConstructorDescriptor) = descriptor - protected open fun mapLocalPropertyReference(descriptor: VariableDescriptorWithAccessors) = descriptor - protected open fun mapClassifierReference(descriptor: ClassifierDescriptor) = descriptor - protected open fun mapReturnTarget(descriptor: FunctionDescriptor) = mapCallee(descriptor) - - private inline fun T.transform() = transform(this@DeepCopyIrTree, null) as T - - override fun visitElement(element: IrElement): IrElement = - throw IllegalArgumentException("Unsupported element type: $element") - - override fun visitModuleFragment(declaration: IrModuleFragment): IrModuleFragment = - IrModuleFragmentImpl( - mapModuleDescriptor(declaration.descriptor), - declaration.irBuiltins, - declaration.files.map { it.transform() } - ) - - override fun visitFile(declaration: IrFile): IrFile = - IrFileImpl( - mapFileEntry(declaration.fileEntry), - mapPackageFragmentDescriptor(declaration.packageFragmentDescriptor), - declaration.fileAnnotations.toMutableList(), - declaration.declarations.map { it.transform() } - ).apply { - transformAnnotations(declaration) - } - - override fun visitDeclaration(declaration: IrDeclaration): IrStatement = - throw IllegalArgumentException("Unsupported declaration type: $declaration") - - override fun visitClass(declaration: IrClass): IrClass = - IrClassImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapClassDeclaration(declaration.descriptor), - declaration.modality, - declaration.declarations.map { it.transform() } - ).apply { - transformAnnotations(declaration) - thisReceiver = declaration.thisReceiver?.replaceDescriptor(descriptor.thisAsReceiverParameter) - - transformTypeParameters(declaration, descriptor.declaredTypeParameters) - - superTypes.addAll(declaration.superTypes) // TODO - } - - override fun visitTypeAlias(declaration: IrTypeAlias): IrTypeAlias = - IrTypeAliasImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapTypeAliasDeclaration(declaration.descriptor) - ).apply { - transformAnnotations(declaration) - } - - override fun visitSimpleFunction(declaration: IrSimpleFunction): IrFunction = - IrFunctionImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapFunctionDeclaration(declaration.descriptor), - declaration.returnType, // TODO - declaration.body?.transform() - ).transformParameters(declaration).apply { - transformAnnotations(declaration) - descriptor.overriddenDescriptors.mapIndexedTo(overriddenSymbols) { index, overriddenDescriptor -> - val oldOverriddenSymbol = declaration.overriddenSymbols.getOrNull(index) - if (overriddenDescriptor.original == oldOverriddenSymbol?.descriptor?.original) - oldOverriddenSymbol - else - IrSimpleFunctionSymbolImpl(overriddenDescriptor.original) - } - } - - override fun visitConstructor(declaration: IrConstructor): IrConstructor = - IrConstructorImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapConstructorDeclaration(declaration.descriptor), - declaration.returnType, // TODO - declaration.body?.transform() - ).transformParameters(declaration).apply { - transformAnnotations(declaration) - } - - protected fun T.transformTypeParameters( - original: T, - myTypeParameters: List - ): T = - apply { - original.typeParameters.mapTo(typeParameters) { originalTypeParameter -> - copyTypeParameter(originalTypeParameter, myTypeParameters[originalTypeParameter.descriptor.index]) - } - } - - private fun FunctionDescriptor.getTypeParametersToTransform() = - when { - this is PropertyAccessorDescriptor -> correspondingProperty.typeParameters - else -> typeParameters - } - - protected fun T.transformParameters(original: T): T = - apply { - transformTypeParameters(original, descriptor.getTypeParametersToTransform()) - transformValueParameters(original) - } - - protected fun T.transformValueParameters(original: T) = - apply { - dispatchReceiverParameter = - original.dispatchReceiverParameter?.replaceDescriptor( - descriptor.dispatchReceiverParameter ?: throw AssertionError("No dispatch receiver in $descriptor") - ) - - extensionReceiverParameter = - original.extensionReceiverParameter?.replaceDescriptor( - descriptor.extensionReceiverParameter ?: throw AssertionError("No extension receiver in $descriptor") - ) - - original.valueParameters.mapIndexedTo(valueParameters) { i, originalValueParameter -> - originalValueParameter.replaceDescriptor(descriptor.valueParameters[i]) - } - } - - protected fun IrAnnotationContainer.transformAnnotations(original: IrAnnotationContainer) { - original.annotations.mapTo(annotations) { it.transform() } - } - - protected fun copyTypeParameter( - originalTypeParameter: IrTypeParameter, - newTypeParameterDescriptor: TypeParameterDescriptor - ): IrTypeParameterImpl = - IrTypeParameterImpl( - originalTypeParameter.startOffset, originalTypeParameter.endOffset, - mapDeclarationOrigin(originalTypeParameter.origin), - newTypeParameterDescriptor - ).apply { - transformAnnotations(originalTypeParameter) - superTypes.addAll(originalTypeParameter.superTypes) // TODO - } - - protected fun createUnboundClassifierSymbol(classifier: ClassifierDescriptor): IrClassifierSymbol = - when (classifier) { - is TypeParameterDescriptor -> IrTypeParameterSymbolImpl(classifier) - is ClassDescriptor -> IrClassSymbolImpl(classifier) - else -> throw IllegalArgumentException("Unexpected classifier descriptor: $classifier") - } - - protected fun copyValueParameter(valueParameter: IrValueParameter, newDescriptor: ParameterDescriptor) = - valueParameter.replaceDescriptor(newDescriptor) - - protected fun IrValueParameter.replaceDescriptor(newDescriptor: ParameterDescriptor) = - IrValueParameterImpl( - startOffset, endOffset, - mapDeclarationOrigin(origin), - newDescriptor, - type, // TODO - varargElementType, // TODO - defaultValue?.transform() - ).also { irValueParameter -> - irValueParameter.transformAnnotations(this) - } - - // TODO visitTypeParameter - // TODO visitValueParameter - - override fun visitProperty(declaration: IrProperty): IrProperty = - IrPropertyImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - declaration.isDelegated, - mapPropertyDeclaration(declaration.descriptor), - declaration.backingField?.transform(), - declaration.getter?.transform(), - declaration.setter?.transform() - ).apply { - transformAnnotations(declaration) - } - - override fun visitField(declaration: IrField): IrField = - IrFieldImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapPropertyDeclaration(declaration.descriptor), - declaration.type, // TODO - declaration.initializer?.transform() - ).apply { - transformAnnotations(declaration) - if (declaration.origin == IrDeclarationOrigin.FAKE_OVERRIDE) { - descriptor.overriddenDescriptors.mapIndexedTo(overriddenSymbols) { index, overriddenDescriptor -> - val oldOverriddenSymbol = declaration.overriddenSymbols.getOrNull(index) - if (overriddenDescriptor.original == oldOverriddenSymbol?.descriptor?.original) - oldOverriddenSymbol - else - IrFieldSymbolImpl(overriddenDescriptor.original) - } - } - } - - override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrLocalDelegatedProperty = - IrLocalDelegatedPropertyImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapLocalPropertyDeclaration(declaration.descriptor), - declaration.type, // TODO - declaration.delegate.transform(), - declaration.getter.transform(), - declaration.setter?.transform() - ).apply { - transformAnnotations(declaration) - } - - override fun visitEnumEntry(declaration: IrEnumEntry): IrEnumEntry = - IrEnumEntryImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapEnumEntryDeclaration(declaration.descriptor), - declaration.correspondingClass?.transform(), - declaration.initializerExpression?.transform() - ).apply { - transformAnnotations(declaration) - } - - override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer): IrAnonymousInitializer = - IrAnonymousInitializerImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapClassDeclaration(declaration.descriptor), - declaration.body.transform() - ) - - override fun visitVariable(declaration: IrVariable): IrVariable = - IrVariableImpl( - declaration.startOffset, declaration.endOffset, - mapDeclarationOrigin(declaration.origin), - mapVariableDeclaration(declaration.descriptor), - declaration.type, // TODO - declaration.initializer?.transform() - ).apply { - transformAnnotations(declaration) - } - - override fun visitBody(body: IrBody): IrBody = - throw IllegalArgumentException("Unsupported body type: $body") - - override fun visitExpressionBody(body: IrExpressionBody): IrExpressionBody = - IrExpressionBodyImpl(body.expression.transform()) - - override fun visitBlockBody(body: IrBlockBody): IrBlockBody = - IrBlockBodyImpl( - body.startOffset, body.endOffset, - body.statements.map { it.transform() } - ) - - override fun visitSyntheticBody(body: IrSyntheticBody): IrSyntheticBody = - IrSyntheticBodyImpl(body.startOffset, body.endOffset, body.kind) - - override fun visitExpression(expression: IrExpression): IrExpression = - throw IllegalArgumentException("Unsupported expression type: $expression") - - override fun visitConst(expression: IrConst): IrConst = - expression.copy() - - override fun visitVararg(expression: IrVararg): IrVararg = - IrVarargImpl( - expression.startOffset, expression.endOffset, - expression.type, expression.varargElementType, - expression.elements.map { it.transform() } - ) - - override fun visitSpreadElement(spread: IrSpreadElement): IrSpreadElement = - IrSpreadElementImpl( - spread.startOffset, spread.endOffset, - spread.expression.transform() - ) - - override fun visitBlock(expression: IrBlock): IrBlock = - IrBlockImpl( - expression.startOffset, expression.endOffset, - expression.type, - mapStatementOrigin(expression.origin), - expression.statements.map { it.transform() } - ) - - override fun visitComposite(expression: IrComposite): IrComposite = - IrCompositeImpl( - expression.startOffset, expression.endOffset, - expression.type, - mapStatementOrigin(expression.origin), - expression.statements.map { it.transform() } - ) - - override fun visitStringConcatenation(expression: IrStringConcatenation): IrStringConcatenation = - IrStringConcatenationImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.arguments.map { it.transform() } - ) - - override fun visitGetObjectValue(expression: IrGetObjectValue): IrGetObjectValue = - IrGetObjectValueImpl( - expression.startOffset, expression.endOffset, - expression.type, - mapClassReference(expression.descriptor) - ) - - override fun visitGetEnumValue(expression: IrGetEnumValue): IrGetEnumValue = - IrGetEnumValueImpl( - expression.startOffset, expression.endOffset, - expression.type, - mapClassReference(expression.descriptor) - ) - - override fun visitGetValue(expression: IrGetValue): IrGetValue = - IrGetValueImpl( - expression.startOffset, expression.endOffset, - expression.type, // TODO - mapValueReference(expression.descriptor), - mapStatementOrigin(expression.origin) - ) - - override fun visitSetVariable(expression: IrSetVariable): IrSetVariable = - IrSetVariableImpl( - expression.startOffset, expression.endOffset, - expression.type, // TODO - mapVariableReference(expression.descriptor), - expression.value.transform(), - mapStatementOrigin(expression.origin) - ) - - override fun visitGetField(expression: IrGetField): IrGetField = - IrGetFieldImpl( - expression.startOffset, expression.endOffset, - mapPropertyReference(expression.descriptor), - expression.receiver?.transform(), - expression.type, // TODO - mapStatementOrigin(expression.origin), - mapSuperQualifier(expression.superQualifier) - ) - - override fun visitSetField(expression: IrSetField): IrSetField = - IrSetFieldImpl( - expression.startOffset, expression.endOffset, - mapPropertyReference(expression.descriptor), - expression.receiver?.transform(), - expression.value.transform(), - expression.type, // TODO - mapStatementOrigin(expression.origin), - mapSuperQualifier(expression.superQualifier) - ) - - override fun visitCall(expression: IrCall): IrCall = - shallowCopyCall(expression).apply { - transformValueArguments(expression) - } - - protected fun shallowCopyCall(expression: IrCall) = - when (expression) { - is IrCallWithShallowCopy -> - expression.shallowCopy( - mapStatementOrigin(expression.origin), - mapCallee(expression.descriptor), - mapSuperQualifier(expression.superQualifier) - ) - else -> { - val newCallee = mapCallee(expression.descriptor) - IrCallImpl( - expression.startOffset, expression.endOffset, - expression.type, - newCallee, - expression.typeArgumentsCount, - mapStatementOrigin(expression.origin), - mapSuperQualifier(expression.superQualifier) - ).apply { - copyTypeArgumentsFrom(expression) - } - } - } - - protected fun T.transformValueArguments(original: IrMemberAccessExpression) { - dispatchReceiver = original.dispatchReceiver?.transform() - extensionReceiver = original.extensionReceiver?.transform() - mapValueParameters { valueParameter -> - original.getValueArgument(valueParameter)?.transform() - } - } - - override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrDelegatingConstructorCall { - val newCallee = mapDelegatedConstructorCallee(expression.descriptor) - return IrDelegatingConstructorCallImpl( - expression.startOffset, expression.endOffset, - expression.type, // TODO - newCallee, - expression.typeArgumentsCount - ).apply { - copyTypeArgumentsFrom(expression) - transformValueArguments(expression) - } - } - - override fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrEnumConstructorCall { - val oldConstructor = expression.descriptor - val newConstructor = mapEnumConstructorCallee(oldConstructor) - return IrEnumConstructorCallImpl( - expression.startOffset, expression.endOffset, - expression.type, // TODO - newConstructor, - expression.typeArgumentsCount - ).apply { - copyTypeArgumentsFrom(expression) - transformValueArguments(expression) - } - } - - override fun visitGetClass(expression: IrGetClass): IrGetClass = - IrGetClassImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.argument.transform() - ) - - override fun visitFunctionReference(expression: IrFunctionReference): IrExpression { - val newCallee = mapCallee(expression.descriptor) - return IrFunctionReferenceImpl( - expression.startOffset, expression.endOffset, - expression.type, - newCallee, - expression.typeArgumentsCount, - mapStatementOrigin(expression.origin) - ).apply { - copyTypeArgumentsFrom(expression) - transformValueArguments(expression) - } - } - - override fun visitPropertyReference(expression: IrPropertyReference): IrExpression { - val newProperty = mapPropertyReference(expression.descriptor) - val newFieldSymbol = if (newProperty.getter == null) IrFieldSymbolImpl(newProperty) else null - val newGetterSymbol = newProperty.getter?.let { IrSimpleFunctionSymbolImpl(it.original) } - val newSetterSymbol = newProperty.setter?.let { IrSimpleFunctionSymbolImpl(it.original) } - return IrPropertyReferenceImpl( - expression.startOffset, expression.endOffset, expression.type, - newProperty, - expression.typeArgumentsCount, newFieldSymbol, newGetterSymbol, newSetterSymbol, - mapStatementOrigin(expression.origin) - ).apply { - copyTypeArgumentsFrom(expression) - transformValueArguments(expression) - } - } - - override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression { - val newLocalDelegatedProperty = mapLocalPropertyReference(expression.descriptor) - val newDelegateDescriptor = mapVariableReference(expression.delegate.descriptor) - val newDelegateSymbol = IrVariableSymbolImpl(newDelegateDescriptor) - val newGetterSymbol = newLocalDelegatedProperty.getter!!.let { IrSimpleFunctionSymbolImpl(it.original) } - val newSetterSymbol = newLocalDelegatedProperty.setter?.let { IrSimpleFunctionSymbolImpl(it.original) } - return IrLocalDelegatedPropertyReferenceImpl( - expression.startOffset, expression.endOffset, expression.type, - newLocalDelegatedProperty, - newDelegateSymbol, newGetterSymbol, newSetterSymbol, - mapStatementOrigin(expression.origin) - ) - } - - override fun visitClassReference(expression: IrClassReference): IrClassReference = - IrClassReferenceImpl( - expression.startOffset, expression.endOffset, - expression.type, - mapClassifierReference(expression.descriptor), - expression.classType - ) - - override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall): IrInstanceInitializerCall = - IrInstanceInitializerCallImpl( - expression.startOffset, expression.endOffset, - mapClassReference(expression.classDescriptor), - expression.type // TODO - ) - - override fun visitTypeOperator(expression: IrTypeOperatorCall): IrTypeOperatorCall = - IrTypeOperatorCallImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.operator, - expression.typeOperand, - run { - val oldTypeDescriptor = expression.typeOperandClassifier.descriptor - val newTypeDescriptor = mapClassifierReference(oldTypeDescriptor) - if (newTypeDescriptor == oldTypeDescriptor) - expression.typeOperandClassifier - else - createUnboundClassifierSymbol(newTypeDescriptor) - }, - expression.argument.transform() - ) - - override fun visitWhen(expression: IrWhen): IrWhen = - IrWhenImpl( - expression.startOffset, expression.endOffset, - expression.type, - mapStatementOrigin(expression.origin), - expression.branches.map { it.transform() } - ) - - override fun visitBranch(branch: IrBranch): IrBranch = - IrBranchImpl( - branch.startOffset, branch.endOffset, - branch.condition.transform(), - branch.result.transform() - ) - - override fun visitElseBranch(branch: IrElseBranch): IrElseBranch = - IrElseBranchImpl( - branch.startOffset, branch.endOffset, - branch.condition.transform(), - branch.result.transform() - ) - - private val transformedLoops = HashMap() - - private fun getTransformedLoop(irLoop: IrLoop): IrLoop = - transformedLoops.getOrElse(irLoop) { getNonTransformedLoop(irLoop) } - - protected open fun getNonTransformedLoop(irLoop: IrLoop): IrLoop = - throw AssertionError("Outer loop was not transformed: ${irLoop.render()}") - - override fun visitWhileLoop(loop: IrWhileLoop): IrWhileLoop { - val newLoop = IrWhileLoopImpl(loop.startOffset, loop.endOffset, loop.type, mapStatementOrigin(loop.origin)) - transformedLoops[loop] = newLoop - newLoop.label = loop.label - newLoop.condition = loop.condition.transform() - newLoop.body = loop.body?.transform() - return newLoop - } - - override fun visitDoWhileLoop(loop: IrDoWhileLoop): IrDoWhileLoop { - val newLoop = IrDoWhileLoopImpl(loop.startOffset, loop.endOffset, loop.type, mapStatementOrigin(loop.origin)) - transformedLoops[loop] = newLoop - newLoop.label = loop.label - newLoop.condition = loop.condition.transform() - newLoop.body = loop.body?.transform() - return newLoop - } - - override fun visitBreak(jump: IrBreak): IrBreak = - IrBreakImpl( - jump.startOffset, jump.endOffset, - jump.type, - getTransformedLoop(jump.loop) - ).apply { label = jump.label } - - override fun visitContinue(jump: IrContinue): IrContinue = - IrContinueImpl( - jump.startOffset, jump.endOffset, - jump.type, - getTransformedLoop(jump.loop) - ).apply { label = jump.label } - - override fun visitTry(aTry: IrTry): IrTry = - IrTryImpl( - aTry.startOffset, aTry.endOffset, - aTry.type, - aTry.tryResult.transform(), - aTry.catches.map { it.transform() }, - aTry.finallyExpression?.transform() - ) - - override fun visitCatch(aCatch: IrCatch): IrCatch = - IrCatchImpl( - aCatch.startOffset, aCatch.endOffset, - aCatch.catchParameter.transform(), - aCatch.result.transform() - ) - - override fun visitReturn(expression: IrReturn): IrReturn = - IrReturnImpl( - expression.startOffset, expression.endOffset, - expression.type, - mapReturnTarget(expression.returnTarget), - expression.value.transform() - ) - - override fun visitThrow(expression: IrThrow): IrThrow = - IrThrowImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.value.transform() - ) - - override fun visitDynamicOperatorExpression(expression: IrDynamicOperatorExpression): IrDynamicOperatorExpression = - IrDynamicOperatorExpressionImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.operator - ).apply { - receiver = expression.receiver.transform() - expression.arguments.mapTo(arguments) { it.transform() } - } - - override fun visitDynamicMemberExpression(expression: IrDynamicMemberExpression): IrDynamicMemberExpression = - IrDynamicMemberExpressionImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.memberName, - expression.receiver.transform() - ) - - override fun visitErrorDeclaration(declaration: IrErrorDeclaration): IrErrorDeclaration = - IrErrorDeclarationImpl( - declaration.startOffset, declaration.endOffset, - mapErrorDeclaration(declaration.descriptor) - ) - - override fun visitErrorExpression(expression: IrErrorExpression): IrErrorExpression = - IrErrorExpressionImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.description - ) - - override fun visitErrorCallExpression(expression: IrErrorCallExpression): IrErrorCallExpression = - IrErrorCallExpressionImpl( - expression.startOffset, expression.endOffset, - expression.type, - expression.description - ).apply { - explicitReceiver = expression.explicitReceiver?.transform() - expression.arguments.mapTo(arguments) { it.transform() } - } - -} \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt index c169a99465e..4016b4ac777 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt @@ -98,10 +98,6 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() { val copiedTrees = irFileCopy.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber) TestCase.assertEquals("IR dump mismatch after deep copy with symbols", actualTrees, copiedTrees) verify(irFileCopy) - - val irFileCopyOld = irFile.deepCopyOld() - val copiedTreesOld = irFileCopyOld.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber) - TestCase.assertEquals("IR dump mismatch after old deep copy", actualTrees, copiedTreesOld) } try {