IR: remove deprecated constructor of IrValueParameterImpl
This commit is contained in:
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.descriptors.Modality
|
|||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.descriptors.Visibility
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.builders.Scope
|
import org.jetbrains.kotlin.ir.builders.Scope
|
||||||
import org.jetbrains.kotlin.ir.builders.declarations.IrTypeParameterBuilder
|
import org.jetbrains.kotlin.ir.builders.declarations.IrTypeParameterBuilder
|
||||||
@@ -190,9 +190,13 @@ fun IrTypeParameter.copyToWithoutSuperTypes(
|
|||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
fun IrFunction.copyReceiverParametersFrom(from: IrFunction) {
|
fun IrFunction.copyReceiverParametersFrom(from: IrFunction) {
|
||||||
dispatchReceiverParameter = from.dispatchReceiverParameter?.let {
|
dispatchReceiverParameter = from.dispatchReceiverParameter?.run {
|
||||||
IrValueParameterImpl(it.startOffset, it.endOffset, it.origin, it.descriptor, it.type, it.varargElementType).also {
|
IrValueParameterImpl(
|
||||||
it.parent = this
|
startOffset, endOffset, origin, IrValueParameterSymbolImpl(descriptor), descriptor.name,
|
||||||
|
descriptor.indexOrMinusOne, type, varargElementType, descriptor.isCrossinline,
|
||||||
|
descriptor.isNoinline
|
||||||
|
).also { parameter ->
|
||||||
|
parameter.parent = this@copyReceiverParametersFrom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extensionReceiverParameter = from.extensionReceiverParameter?.copyTo(this)
|
extensionReceiverParameter = from.extensionReceiverParameter?.copyTo(this)
|
||||||
|
|||||||
+2
-10
@@ -9,10 +9,7 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
|||||||
import org.jetbrains.kotlin.backend.common.DeclarationTransformer
|
import org.jetbrains.kotlin.backend.common.DeclarationTransformer
|
||||||
import org.jetbrains.kotlin.backend.common.bridges.FunctionHandle
|
import org.jetbrains.kotlin.backend.common.bridges.FunctionHandle
|
||||||
import org.jetbrains.kotlin.backend.common.bridges.generateBridges
|
import org.jetbrains.kotlin.backend.common.bridges.generateBridges
|
||||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
import org.jetbrains.kotlin.backend.common.ir.*
|
||||||
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.isMethodOfAny
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.isSuspend
|
|
||||||
import org.jetbrains.kotlin.backend.common.lower.*
|
import org.jetbrains.kotlin.backend.common.lower.*
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
@@ -23,7 +20,6 @@ import org.jetbrains.kotlin.ir.backend.js.utils.functionSignature
|
|||||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsName
|
import org.jetbrains.kotlin.ir.backend.js.utils.getJsName
|
||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
@@ -138,11 +134,7 @@ class BridgesConstruction(val context: CommonBackendContext) : DeclarationTransf
|
|||||||
origin = origin
|
origin = origin
|
||||||
).apply {
|
).apply {
|
||||||
copyTypeParametersFrom(bridge)
|
copyTypeParametersFrom(bridge)
|
||||||
// TODO: should dispatch receiver be copied?
|
copyReceiverParametersFrom(bridge)
|
||||||
dispatchReceiverParameter = bridge.dispatchReceiverParameter?.run {
|
|
||||||
IrValueParameterImpl(startOffset, endOffset, origin, descriptor, type, varargElementType).also { it.parent = this@apply }
|
|
||||||
}
|
|
||||||
extensionReceiverParameter = bridge.extensionReceiverParameter?.copyTo(this)
|
|
||||||
valueParameters += bridge.valueParameters.map { p -> p.copyTo(this) }
|
valueParameters += bridge.valueParameters.map { p -> p.copyTo(this) }
|
||||||
annotations += bridge.annotations
|
annotations += bridge.annotations
|
||||||
overriddenSymbols += delegateTo.overriddenSymbols
|
overriddenSymbols += delegateTo.overriddenSymbols
|
||||||
|
|||||||
-22
@@ -17,19 +17,16 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations.impl
|
package org.jetbrains.kotlin.ir.declarations.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.carriers.ValueParameterCarrier
|
import org.jetbrains.kotlin.ir.declarations.impl.carriers.ValueParameterCarrier
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
|
||||||
|
|
||||||
class IrValueParameterImpl(
|
class IrValueParameterImpl(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -47,25 +44,6 @@ class IrValueParameterImpl(
|
|||||||
IrValueParameter,
|
IrValueParameter,
|
||||||
ValueParameterCarrier {
|
ValueParameterCarrier {
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
|
||||||
constructor(
|
|
||||||
startOffset: Int,
|
|
||||||
endOffset: Int,
|
|
||||||
origin: IrDeclarationOrigin,
|
|
||||||
descriptor: ParameterDescriptor,
|
|
||||||
type: IrType,
|
|
||||||
varargElementType: IrType?,
|
|
||||||
name: Name = descriptor.name,
|
|
||||||
symbol: IrValueParameterSymbol = IrValueParameterSymbolImpl(descriptor)
|
|
||||||
) : this(
|
|
||||||
startOffset, endOffset, origin, symbol,
|
|
||||||
name,
|
|
||||||
index = descriptor.safeAs<ValueParameterDescriptor>()?.index ?: -1,
|
|
||||||
type = type, varargElementType = varargElementType,
|
|
||||||
isCrossinline = descriptor.safeAs<ValueParameterDescriptor>()?.isCrossinline ?: false,
|
|
||||||
isNoinline = descriptor.safeAs<ValueParameterDescriptor>()?.isNoinline ?: false
|
|
||||||
)
|
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
@ObsoleteDescriptorBasedAPI
|
||||||
override val descriptor: ParameterDescriptor = symbol.descriptor
|
override val descriptor: ParameterDescriptor = symbol.descriptor
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -6,12 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations.lazy
|
package org.jetbrains.kotlin.ir.declarations.lazy
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|
||||||
import org.jetbrains.kotlin.ir.IrElementBase
|
import org.jetbrains.kotlin.ir.IrElementBase
|
||||||
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
|
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
|
||||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
@@ -30,8 +31,8 @@ abstract class IrLazyDeclarationBase(
|
|||||||
|
|
||||||
protected fun ReceiverParameterDescriptor.generateReceiverParameterStub(): IrValueParameter =
|
protected fun ReceiverParameterDescriptor.generateReceiverParameterStub(): IrValueParameter =
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, this,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, IrValueParameterSymbolImpl(this),
|
||||||
type.toIrType(), null
|
name, -1, type.toIrType(), null, isCrossinline = false, isNoinline = false
|
||||||
)
|
)
|
||||||
|
|
||||||
protected fun generateMemberStubs(memberScope: MemberScope, container: MutableList<IrDeclaration>) {
|
protected fun generateMemberStubs(memberScope: MemberScope, container: MutableList<IrDeclaration>) {
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
|||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.types.impl.*
|
import org.jetbrains.kotlin.ir.types.impl.*
|
||||||
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
|
||||||
import org.jetbrains.kotlin.ir.util.referenceClassifier
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||||
@@ -356,19 +354,12 @@ class IrFunctionFactory(private val irBuiltIns: IrBuiltIns, private val symbolTa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrFunction.createValueParameter(descriptor: ParameterDescriptor): IrValueParameter {
|
private fun IrFunction.createValueParameter(descriptor: ParameterDescriptor): IrValueParameter = with(descriptor) {
|
||||||
val symbol = IrValueParameterSymbolImpl(descriptor)
|
IrValueParameterImpl(
|
||||||
val varargType = if (descriptor is ValueParameterDescriptor) descriptor.varargElementType else null
|
offset, offset, memberOrigin, IrValueParameterSymbolImpl(this), name, indexOrMinusOne, toIrType(type),
|
||||||
return IrValueParameterImpl(
|
(this as? ValueParameterDescriptor)?.varargElementType?.let(::toIrType), isCrossinline, isNoinline
|
||||||
offset,
|
|
||||||
offset,
|
|
||||||
memberOrigin,
|
|
||||||
descriptor,
|
|
||||||
symbol = symbol,
|
|
||||||
type = toIrType(descriptor.type),
|
|
||||||
varargElementType = varargType?.let { toIrType(it) }
|
|
||||||
).also {
|
).also {
|
||||||
it.parent = this
|
it.parent = this@createValueParameter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.linkage.IrProvider
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||||
@@ -247,10 +248,10 @@ class DeclarationStubGenerator(
|
|||||||
|
|
||||||
private fun KotlinType.toIrType() = typeTranslator.translateType(this)
|
private fun KotlinType.toIrType() = typeTranslator.translateType(this)
|
||||||
|
|
||||||
internal fun generateValueParameterStub(descriptor: ValueParameterDescriptor): IrValueParameter {
|
internal fun generateValueParameterStub(descriptor: ValueParameterDescriptor): IrValueParameter = with(descriptor) {
|
||||||
return IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, computeOrigin(descriptor),
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, computeOrigin(this), IrValueParameterSymbolImpl(this), name, index, type.toIrType(),
|
||||||
descriptor, descriptor.type.toIrType(), descriptor.varargElementType?.toIrType()
|
varargElementType?.toIrType(), isCrossinline, isNoinline
|
||||||
).also { irValueParameter ->
|
).also { irValueParameter ->
|
||||||
if (descriptor.declaresDefaultValue()) {
|
if (descriptor.declaresDefaultValue()) {
|
||||||
irValueParameter.defaultValue =
|
irValueParameter.defaultValue =
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.ir.util
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
|
val ParameterDescriptor.indexOrMinusOne: Int
|
||||||
|
get() = if (this is ValueParameterDescriptor) index else -1
|
||||||
|
|
||||||
|
val ParameterDescriptor.varargElementType: KotlinType?
|
||||||
|
get() = (this as? ValueParameterDescriptor)?.varargElementType
|
||||||
|
|
||||||
|
val ParameterDescriptor.isCrossinline: Boolean
|
||||||
|
get() = this is ValueParameterDescriptor && isCrossinline
|
||||||
|
|
||||||
|
val ParameterDescriptor.isNoinline: Boolean
|
||||||
|
get() = this is ValueParameterDescriptor && isNoinline
|
||||||
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
@@ -379,20 +378,6 @@ fun IrValueParameter.hasDefaultValue(): Boolean = DFS.ifAny(
|
|||||||
{ current -> current.defaultValue != null }
|
{ current -> current.defaultValue != null }
|
||||||
)
|
)
|
||||||
|
|
||||||
@ObsoleteDescriptorBasedAPI
|
|
||||||
fun IrValueParameter.copy(newDescriptor: ParameterDescriptor): IrValueParameter {
|
|
||||||
assert(this.descriptor.type == newDescriptor.type)
|
|
||||||
|
|
||||||
return IrValueParameterImpl(
|
|
||||||
startOffset,
|
|
||||||
endOffset,
|
|
||||||
IrDeclarationOrigin.DEFINED,
|
|
||||||
newDescriptor,
|
|
||||||
type,
|
|
||||||
varargElementType
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// In presence of `IrBlock`s, return the expression that actually serves as the value (the last one).
|
// In presence of `IrBlock`s, return the expression that actually serves as the value (the last one).
|
||||||
tailrec fun IrExpression.removeBlocks(): IrExpression? = when (this) {
|
tailrec fun IrExpression.removeBlocks(): IrExpression? = when (this) {
|
||||||
is IrBlock -> (statements.last() as? IrExpression)?.removeBlocks()
|
is IrBlock -> (statements.last() as? IrExpression)?.removeBlocks()
|
||||||
|
|||||||
@@ -886,10 +886,8 @@ open class SymbolTable(
|
|||||||
varargElementType: IrType? = null,
|
varargElementType: IrType? = null,
|
||||||
valueParameterFactory: (IrValueParameterSymbol) -> IrValueParameter = {
|
valueParameterFactory: (IrValueParameterSymbol) -> IrValueParameter = {
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
startOffset, endOffset, origin, descriptor,
|
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor),
|
||||||
name = nameProvider.nameForDeclaration(descriptor),
|
descriptor.indexOrMinusOne, type, varargElementType, descriptor.isCrossinline, descriptor.isNoinline
|
||||||
type = type, varargElementType = varargElementType,
|
|
||||||
symbol = it
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
): IrValueParameter =
|
): IrValueParameter =
|
||||||
|
|||||||
+12
-11
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.ir.declarations.impl.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||||
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
|
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
|
||||||
@@ -377,14 +378,14 @@ interface IrBuilderExtension {
|
|||||||
overwriteValueParameters: Boolean = false,
|
overwriteValueParameters: Boolean = false,
|
||||||
copyTypeParameters: Boolean = true
|
copyTypeParameters: Boolean = true
|
||||||
) {
|
) {
|
||||||
fun ParameterDescriptor.irValueParameter() = IrValueParameterImpl(
|
val function = this
|
||||||
this@createParameterDeclarations.startOffset, this@createParameterDeclarations.endOffset,
|
fun irValueParameter(descriptor: ParameterDescriptor): IrValueParameterImpl = with(descriptor) {
|
||||||
SERIALIZABLE_PLUGIN_ORIGIN,
|
IrValueParameterImpl(
|
||||||
this,
|
function.startOffset, function.endOffset, SERIALIZABLE_PLUGIN_ORIGIN, IrValueParameterSymbolImpl(this),
|
||||||
type.toIrType(),
|
name, indexOrMinusOne, type.toIrType(), varargElementType?.toIrType(), isCrossinline, isNoinline
|
||||||
(this as? ValueParameterDescriptor)?.varargElementType?.toIrType()
|
).also {
|
||||||
).also {
|
it.parent = function
|
||||||
it.parent = this@createParameterDeclarations
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copyTypeParameters) {
|
if (copyTypeParameters) {
|
||||||
@@ -392,13 +393,13 @@ interface IrBuilderExtension {
|
|||||||
copyTypeParamsFromDescriptor()
|
copyTypeParamsFromDescriptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchReceiverParameter = descriptor.dispatchReceiverParameter?.irValueParameter()
|
dispatchReceiverParameter = descriptor.dispatchReceiverParameter?.let { irValueParameter(it) }
|
||||||
extensionReceiverParameter = descriptor.extensionReceiverParameter?.irValueParameter()
|
extensionReceiverParameter = descriptor.extensionReceiverParameter?.let { irValueParameter(it) }
|
||||||
|
|
||||||
if (!overwriteValueParameters)
|
if (!overwriteValueParameters)
|
||||||
assert(valueParameters.isEmpty())
|
assert(valueParameters.isEmpty())
|
||||||
|
|
||||||
valueParameters = descriptor.valueParameters.map { it.irValueParameter() }
|
valueParameters = descriptor.valueParameters.map { irValueParameter(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun IrFunction.copyTypeParamsFromDescriptor() {
|
fun IrFunction.copyTypeParamsFromDescriptor() {
|
||||||
|
|||||||
Reference in New Issue
Block a user