IR: remove WrappedDescriptors altogether
This commit is contained in:
+2
-18
@@ -16,26 +16,16 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.common
|
package org.jetbrains.kotlin.backend.common
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrLoop
|
import org.jetbrains.kotlin.ir.expressions.IrLoop
|
||||||
import org.jetbrains.kotlin.ir.util.DeepCopyIrTreeWithSymbols
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper
|
|
||||||
import org.jetbrains.kotlin.ir.util.DeepCopyTypeRemapper
|
|
||||||
import org.jetbrains.kotlin.ir.util.DescriptorsRemapper
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
fun <T : IrElement> T.deepCopyWithVariables(): T {
|
fun <T : IrElement> T.deepCopyWithVariables(): T {
|
||||||
val descriptorsRemapper = object : DescriptorsRemapper {
|
val symbolsRemapper = DeepCopySymbolRemapper(NullDescriptorsRemapper)
|
||||||
override fun remapDeclaredVariable(descriptor: VariableDescriptor) = WrappedVariableDescriptor()
|
|
||||||
}
|
|
||||||
|
|
||||||
val symbolsRemapper = DeepCopySymbolRemapper(descriptorsRemapper)
|
|
||||||
acceptVoid(symbolsRemapper)
|
acceptVoid(symbolsRemapper)
|
||||||
|
|
||||||
val typesRemapper = DeepCopyTypeRemapper(symbolsRemapper)
|
val typesRemapper = DeepCopyTypeRemapper(symbolsRemapper)
|
||||||
@@ -45,12 +35,6 @@ fun <T : IrElement> T.deepCopyWithVariables(): T {
|
|||||||
override fun getNonTransformedLoop(irLoop: IrLoop): IrLoop {
|
override fun getNonTransformedLoop(irLoop: IrLoop): IrLoop {
|
||||||
return irLoop
|
return irLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitVariable(declaration: IrVariable): IrVariable {
|
|
||||||
val variable = super.visitVariable(declaration)
|
|
||||||
variable.descriptor.let { if (it is WrappedVariableDescriptor) it.bind(variable) }
|
|
||||||
return variable
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
null
|
null
|
||||||
) as T
|
) as T
|
||||||
|
|||||||
+3
-11
@@ -6,11 +6,9 @@
|
|||||||
package org.jetbrains.kotlin.backend.common.ir
|
package org.jetbrains.kotlin.backend.common.ir
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.lower.VariableRemapper
|
import org.jetbrains.kotlin.backend.common.lower.VariableRemapper
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnableBlockImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnableBlockImpl
|
||||||
@@ -83,12 +81,6 @@ private fun IrBody.move(
|
|||||||
// TODO use a generic inliner (e.g. JS/Native's FunctionInlining.Inliner)
|
// TODO use a generic inliner (e.g. JS/Native's FunctionInlining.Inliner)
|
||||||
// Inline simple function calls without type parameters, default parameters, or varargs.
|
// Inline simple function calls without type parameters, default parameters, or varargs.
|
||||||
fun IrFunction.inline(target: IrDeclarationParent, arguments: List<IrValueDeclaration> = listOf()): IrReturnableBlock =
|
fun IrFunction.inline(target: IrDeclarationParent, arguments: List<IrValueDeclaration> = listOf()): IrReturnableBlock =
|
||||||
IrReturnableBlockImpl(startOffset, endOffset, returnType, IrReturnableBlockSymbolImpl(getNewWrappedDescriptor()), null, symbol).apply {
|
IrReturnableBlockImpl(startOffset, endOffset, returnType, IrReturnableBlockSymbolImpl(), null, symbol).apply {
|
||||||
statements += body!!.move(this@inline, target, symbol, valueParameters.zip(arguments).toMap()).statements
|
statements += body!!.move(this@inline, target, symbol, valueParameters.zip(arguments).toMap()).statements
|
||||||
}
|
}
|
||||||
|
|
||||||
fun IrFunction.getNewWrappedDescriptor(): FunctionDescriptor = when (this) {
|
|
||||||
is IrConstructor -> WrappedClassConstructorDescriptor().apply { bind(this@getNewWrappedDescriptor) }
|
|
||||||
is IrSimpleFunction -> WrappedSimpleFunctionDescriptor().apply { bind(this@getNewWrappedDescriptor) }
|
|
||||||
else -> error("Unknown IrFunction kind: $this")
|
|
||||||
}
|
|
||||||
+2
-3
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildVariable
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
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.IrReturnTargetSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrReturnTargetSymbol
|
||||||
@@ -175,7 +174,7 @@ class FinallyBlocksLowering(val context: CommonBackendContext, private val throw
|
|||||||
currentTryScope.jumps.getOrPut(jump) {
|
currentTryScope.jumps.getOrPut(jump) {
|
||||||
val type = (jump as? Return)?.target?.owner?.returnType(context) ?: value.type
|
val type = (jump as? Return)?.target?.owner?.returnType(context) ?: value.type
|
||||||
jump.toString()
|
jump.toString()
|
||||||
val symbol = IrReturnableBlockSymbolImpl(WrappedSimpleFunctionDescriptor())
|
val symbol = IrReturnableBlockSymbolImpl()
|
||||||
with(currentTryScope) {
|
with(currentTryScope) {
|
||||||
irBuilder.run {
|
irBuilder.run {
|
||||||
val inlinedFinally = irInlineFinally(symbol, type, expression, finallyExpression)
|
val inlinedFinally = irInlineFinally(symbol, type, expression, finallyExpression)
|
||||||
@@ -234,7 +233,7 @@ class FinallyBlocksLowering(val context: CommonBackendContext, private val throw
|
|||||||
using(TryScope(syntheticTry, transformedFinallyExpression, this)) {
|
using(TryScope(syntheticTry, transformedFinallyExpression, this)) {
|
||||||
|
|
||||||
val fallThroughType = aTry.type
|
val fallThroughType = aTry.type
|
||||||
val fallThroughSymbol = IrReturnableBlockSymbolImpl(WrappedSimpleFunctionDescriptor())
|
val fallThroughSymbol = IrReturnableBlockSymbolImpl()
|
||||||
val transformedResult = aTry.tryResult.transform(transformer, null)
|
val transformedResult = aTry.tryResult.transform(transformer, null)
|
||||||
val returnedResult = irReturn(fallThroughSymbol, transformedResult)
|
val returnedResult = irReturn(fallThroughSymbol, transformedResult)
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.backend.common.lower.inline
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.*
|
import org.jetbrains.kotlin.backend.common.*
|
||||||
import org.jetbrains.kotlin.backend.common.ir.Symbols
|
import org.jetbrains.kotlin.backend.common.ir.Symbols
|
||||||
import org.jetbrains.kotlin.backend.common.ir.getNewWrappedDescriptor
|
|
||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
@@ -178,7 +177,7 @@ class FunctionInlining(
|
|||||||
val evaluationStatements = evaluateArguments(callSite, copiedCallee)
|
val evaluationStatements = evaluateArguments(callSite, copiedCallee)
|
||||||
val statements = (copiedCallee.body as IrBlockBody).statements
|
val statements = (copiedCallee.body as IrBlockBody).statements
|
||||||
|
|
||||||
val irReturnableBlockSymbol = IrReturnableBlockSymbolImpl(callee.getNewWrappedDescriptor())
|
val irReturnableBlockSymbol = IrReturnableBlockSymbolImpl()
|
||||||
val endOffset = callee.endOffset
|
val endOffset = callee.endOffset
|
||||||
/* creates irBuilder appending to the end of the given returnable block: thus why we initialize
|
/* creates irBuilder appending to the end of the given returnable block: thus why we initialize
|
||||||
* irBuilder with (..., endOffset, endOffset).
|
* irBuilder with (..., endOffset, endOffset).
|
||||||
|
|||||||
-1
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||||
|
|||||||
-1
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrEnumEntryImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrEnumEntryImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedEnumEntryDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.ir.builders.*
|
|||||||
import org.jetbrains.kotlin.ir.builders.declarations.*
|
import org.jetbrains.kotlin.ir.builders.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.*
|
import org.jetbrains.kotlin.ir.declarations.impl.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor
|
|
||||||
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.*
|
||||||
|
|||||||
-5
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.jvm.lower
|
package org.jetbrains.kotlin.backend.jvm.lower
|
||||||
|
|
||||||
import com.intellij.lang.jvm.source.JvmDeclarationSearch
|
|
||||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||||
import org.jetbrains.kotlin.backend.common.ir.*
|
import org.jetbrains.kotlin.backend.common.ir.*
|
||||||
@@ -27,12 +26,9 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
|||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.builders.declarations.*
|
import org.jetbrains.kotlin.ir.builders.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
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.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||||
@@ -41,7 +37,6 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
|||||||
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities
|
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.name.SpecialNames
|
import org.jetbrains.kotlin.name.SpecialNames
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
|
||||||
|
|
||||||
internal val suspendLambdaPhase = makeIrFilePhase(
|
internal val suspendLambdaPhase = makeIrFilePhase(
|
||||||
::SuspendLambdaLowering,
|
::SuspendLambdaLowering,
|
||||||
|
|||||||
+19
-34
@@ -28,10 +28,10 @@ import org.jetbrains.kotlin.ir.builders.irGet
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
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.impl.IrSimpleFunctionSymbolImpl
|
||||||
|
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.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
@@ -358,41 +358,26 @@ private fun StatementGenerator.createFunctionForSuspendConversion(
|
|||||||
val suspendFunReturnType = suspendFunType.arguments.last().type
|
val suspendFunReturnType = suspendFunType.arguments.last().type
|
||||||
val irSuspendFunReturnType = suspendFunReturnType.toIrType()
|
val irSuspendFunReturnType = suspendFunReturnType.toIrType()
|
||||||
|
|
||||||
val adapterFunctionDescriptor = WrappedSimpleFunctionDescriptor()
|
val irAdapterFun = context.irFactory.createFunction(
|
||||||
|
startOffset, endOffset,
|
||||||
val irAdapterFun = context.symbolTable.declareSimpleFunction(
|
IrDeclarationOrigin.ADAPTER_FOR_SUSPEND_CONVERSION,
|
||||||
adapterFunctionDescriptor
|
IrSimpleFunctionSymbolImpl(),
|
||||||
) { irAdapterSymbol ->
|
Name.identifier(scope.inventNameForTemporary("suspendConversion")),
|
||||||
context.irFactory.createFunction(
|
DescriptorVisibilities.LOCAL, Modality.FINAL,
|
||||||
startOffset, endOffset,
|
irSuspendFunReturnType,
|
||||||
IrDeclarationOrigin.ADAPTER_FOR_SUSPEND_CONVERSION,
|
isInline = false, isExternal = false, isTailrec = false,
|
||||||
irAdapterSymbol,
|
isSuspend = true,
|
||||||
Name.identifier(scope.inventNameForTemporary("suspendConversion")),
|
isOperator = false, isInfix = false, isExpect = false, isFakeOverride = false
|
||||||
DescriptorVisibilities.LOCAL, Modality.FINAL,
|
)
|
||||||
irSuspendFunReturnType,
|
|
||||||
isInline = false, isExternal = false, isTailrec = false,
|
|
||||||
isSuspend = true,
|
|
||||||
isOperator = false, isInfix = false, isExpect = false, isFakeOverride = false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
adapterFunctionDescriptor.bind(irAdapterFun)
|
|
||||||
|
|
||||||
context.symbolTable.enterScope(irAdapterFun)
|
context.symbolTable.enterScope(irAdapterFun)
|
||||||
|
|
||||||
fun createValueParameter(name: String, index: Int, type: IrType): IrValueParameter {
|
fun createValueParameter(name: String, index: Int, type: IrType): IrValueParameter =
|
||||||
val descriptor = WrappedValueParameterDescriptor()
|
context.irFactory.createValueParameter(
|
||||||
return context.symbolTable.declareValueParameter(
|
startOffset, endOffset, IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION, IrValueParameterSymbolImpl(),
|
||||||
startOffset, endOffset, IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION, descriptor, type
|
Name.identifier(name), index, type, varargElementType = null, isCrossinline = false, isNoinline = false,
|
||||||
) {
|
isHidden = false, isAssignable = false
|
||||||
context.irFactory.createValueParameter(
|
)
|
||||||
startOffset, endOffset, IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION,
|
|
||||||
it, Name.identifier(name), index, type, varargElementType = null, isCrossinline = false, isNoinline = false,
|
|
||||||
isHidden = false, isAssignable = false
|
|
||||||
)
|
|
||||||
}.also {
|
|
||||||
descriptor.bind(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
irAdapterFun.extensionReceiverParameter = createValueParameter("callee", -1, funType.toIrType())
|
irAdapterFun.extensionReceiverParameter = createValueParameter("callee", -1, funType.toIrType())
|
||||||
irAdapterFun.valueParameters = suspendFunType.arguments
|
irAdapterFun.valueParameters = suspendFunType.arguments
|
||||||
|
|||||||
+41
-57
@@ -25,14 +25,14 @@ import org.jetbrains.kotlin.ir.declarations.DescriptorMetadataSource
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
|
|
||||||
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.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.util.referenceClassifier
|
import org.jetbrains.kotlin.ir.util.referenceClassifier
|
||||||
import org.jetbrains.kotlin.ir.util.referenceFunction
|
import org.jetbrains.kotlin.ir.util.referenceFunction
|
||||||
import org.jetbrains.kotlin.ir.util.withScope
|
import org.jetbrains.kotlin.ir.util.withScope
|
||||||
@@ -313,49 +313,41 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
|||||||
callBuilder: CallBuilder,
|
callBuilder: CallBuilder,
|
||||||
callableReferenceType: KotlinType
|
callableReferenceType: KotlinType
|
||||||
): IrSimpleFunction {
|
): IrSimpleFunction {
|
||||||
val adapterFunctionDescriptor = WrappedSimpleFunctionDescriptor()
|
|
||||||
|
|
||||||
val hasSuspendConversion = !adapteeDescriptor.isSuspend &&
|
val hasSuspendConversion = !adapteeDescriptor.isSuspend &&
|
||||||
callableReferenceType.isKSuspendFunctionType
|
callableReferenceType.isKSuspendFunctionType
|
||||||
|
|
||||||
return context.symbolTable.declareSimpleFunction(
|
return context.irFactory.createFunction(
|
||||||
adapterFunctionDescriptor
|
startOffset, endOffset,
|
||||||
) { irAdapterSymbol ->
|
IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE,
|
||||||
context.irFactory.createFunction(
|
IrSimpleFunctionSymbolImpl(),
|
||||||
startOffset, endOffset,
|
adapteeDescriptor.name,
|
||||||
IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE,
|
DescriptorVisibilities.LOCAL,
|
||||||
irAdapterSymbol,
|
Modality.FINAL,
|
||||||
adapteeDescriptor.name,
|
ktExpectedReturnType.toIrType(),
|
||||||
DescriptorVisibilities.LOCAL,
|
isInline = adapteeDescriptor.isInline, // TODO ?
|
||||||
Modality.FINAL,
|
isExternal = false,
|
||||||
ktExpectedReturnType.toIrType(),
|
isTailrec = false,
|
||||||
isInline = adapteeDescriptor.isInline, // TODO ?
|
isSuspend = adapteeDescriptor.isSuspend || hasSuspendConversion,
|
||||||
isExternal = false,
|
isOperator = adapteeDescriptor.isOperator, // TODO ?
|
||||||
isTailrec = false,
|
isInfix = adapteeDescriptor.isInfix,
|
||||||
isSuspend = adapteeDescriptor.isSuspend || hasSuspendConversion,
|
isExpect = false,
|
||||||
isOperator = adapteeDescriptor.isOperator, // TODO ?
|
isFakeOverride = false
|
||||||
isInfix = adapteeDescriptor.isInfix,
|
).also { irAdapterFun ->
|
||||||
isExpect = false,
|
context.symbolTable.withScope(irAdapterFun) {
|
||||||
isFakeOverride = false
|
irAdapterFun.metadata = DescriptorMetadataSource.Function(adapteeDescriptor)
|
||||||
).also { irAdapterFun ->
|
|
||||||
adapterFunctionDescriptor.bind(irAdapterFun)
|
|
||||||
|
|
||||||
context.symbolTable.withScope(irAdapterFun) {
|
irAdapterFun.dispatchReceiverParameter = null
|
||||||
irAdapterFun.metadata = DescriptorMetadataSource.Function(adapteeDescriptor)
|
|
||||||
|
|
||||||
irAdapterFun.dispatchReceiverParameter = null
|
val boundReceiver = callBuilder.original.selectBoundReceiver()
|
||||||
|
if (boundReceiver != null) {
|
||||||
|
irAdapterFun.extensionReceiverParameter =
|
||||||
|
createAdapterParameter(startOffset, endOffset, Name.identifier("receiver"), -1, boundReceiver.type)
|
||||||
|
} else {
|
||||||
|
irAdapterFun.extensionReceiverParameter = null
|
||||||
|
}
|
||||||
|
|
||||||
val boundReceiver = callBuilder.original.selectBoundReceiver()
|
irAdapterFun.valueParameters += ktExpectedParameterTypes.mapIndexed { index, ktExpectedParameterType ->
|
||||||
if (boundReceiver != null) {
|
createAdapterParameter(startOffset, endOffset, Name.identifier("p$index"), index, ktExpectedParameterType)
|
||||||
irAdapterFun.extensionReceiverParameter =
|
|
||||||
createAdapterParameter(startOffset, endOffset, Name.identifier("receiver"), -1, boundReceiver.type)
|
|
||||||
} else {
|
|
||||||
irAdapterFun.extensionReceiverParameter = null
|
|
||||||
}
|
|
||||||
|
|
||||||
irAdapterFun.valueParameters += ktExpectedParameterTypes.mapIndexed { index, ktExpectedParameterType ->
|
|
||||||
createAdapterParameter(startOffset, endOffset, Name.identifier("p$index"), index, ktExpectedParameterType)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,24 +363,16 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createAdapterParameter(startOffset: Int, endOffset: Int, name: Name, index: Int, type: KotlinType): IrValueParameter {
|
private fun createAdapterParameter(startOffset: Int, endOffset: Int, name: Name, index: Int, type: KotlinType): IrValueParameter =
|
||||||
val descriptor = WrappedValueParameterDescriptor()
|
context.irFactory.createValueParameter(
|
||||||
return context.symbolTable.declareValueParameter(
|
startOffset, endOffset,
|
||||||
startOffset, endOffset, IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE, descriptor, type.toIrType()
|
IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE,
|
||||||
) { irAdapterParameterSymbol ->
|
IrValueParameterSymbolImpl(),
|
||||||
context.irFactory.createValueParameter(
|
name,
|
||||||
startOffset, endOffset,
|
index,
|
||||||
IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE,
|
type.toIrType(),
|
||||||
irAdapterParameterSymbol,
|
varargElementType = null, isCrossinline = false, isNoinline = false, isHidden = false, isAssignable = false
|
||||||
name,
|
)
|
||||||
index,
|
|
||||||
type.toIrType(),
|
|
||||||
varargElementType = null, isCrossinline = false, isNoinline = false, isHidden = false, isAssignable = false
|
|
||||||
).also { irAdapterValueParameter ->
|
|
||||||
descriptor.bind(irAdapterValueParameter)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun generateCallableReference(
|
fun generateCallableReference(
|
||||||
ktElement: KtElement,
|
ktElement: KtElement,
|
||||||
|
|||||||
+5
-2
@@ -22,15 +22,18 @@ import org.jetbrains.kotlin.ir.declarations.IrFactory
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration
|
import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration
|
||||||
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
class IrErrorDeclarationImpl(
|
class IrErrorDeclarationImpl(
|
||||||
override val startOffset: Int,
|
override val startOffset: Int,
|
||||||
override val endOffset: Int,
|
override val endOffset: Int,
|
||||||
override val descriptor: DeclarationDescriptor
|
private val _descriptor: DeclarationDescriptor?
|
||||||
) : IrErrorDeclaration() {
|
) : IrErrorDeclaration() {
|
||||||
|
override val descriptor: DeclarationDescriptor
|
||||||
|
get() = _descriptor ?: this.toIrBasedDescriptor()
|
||||||
|
|
||||||
override var origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED
|
override var origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED
|
||||||
|
|
||||||
override val factory: IrFactory
|
override val factory: IrFactory
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ object IrFactoryImpl : IrFactory {
|
|||||||
override fun createErrorDeclaration(
|
override fun createErrorDeclaration(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
descriptor: DeclarationDescriptor,
|
descriptor: DeclarationDescriptor?,
|
||||||
): IrErrorDeclaration =
|
): IrErrorDeclaration =
|
||||||
IrErrorDeclarationImpl(startOffset, endOffset, descriptor)
|
IrErrorDeclarationImpl(startOffset, endOffset, descriptor)
|
||||||
|
|
||||||
|
|||||||
-2
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
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.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
@@ -138,7 +137,6 @@ class IrFakeOverrideFunctionImpl(
|
|||||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||||
_symbol = symbol
|
_symbol = symbol
|
||||||
symbol.bind(this)
|
symbol.bind(this)
|
||||||
(symbol.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||||
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.descriptors.WrappedPropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
@@ -122,7 +121,6 @@ class IrFakeOverridePropertyImpl(
|
|||||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||||
_symbol = symbol
|
_symbol = symbol
|
||||||
symbol.bind(this)
|
symbol.bind(this)
|
||||||
(symbol.descriptor as? WrappedPropertyDescriptor)?.bind(this)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -24,14 +24,18 @@ import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration
|
|||||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ErrorCarrier
|
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ErrorCarrier
|
||||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||||
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
internal class PersistentIrErrorDeclaration(
|
internal class PersistentIrErrorDeclaration(
|
||||||
override val startOffset: Int,
|
override val startOffset: Int,
|
||||||
override val endOffset: Int,
|
override val endOffset: Int,
|
||||||
override val descriptor: DeclarationDescriptor
|
private val _descriptor: DeclarationDescriptor?
|
||||||
) : PersistentIrDeclarationBase<ErrorCarrier>, IrErrorDeclaration(), ErrorCarrier {
|
) : PersistentIrDeclarationBase<ErrorCarrier>, IrErrorDeclaration(), ErrorCarrier {
|
||||||
|
override val descriptor: DeclarationDescriptor
|
||||||
|
get() = _descriptor ?: this.toIrBasedDescriptor()
|
||||||
|
|
||||||
override var lastModified: Int = stageController.currentStage
|
override var lastModified: Int = stageController.currentStage
|
||||||
override var loweredUpTo: Int = stageController.currentStage
|
override var loweredUpTo: Int = stageController.currentStage
|
||||||
override var values: Array<Carrier>? = null
|
override var values: Array<Carrier>? = null
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ object PersistentIrFactory : IrFactory {
|
|||||||
override fun createErrorDeclaration(
|
override fun createErrorDeclaration(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
descriptor: DeclarationDescriptor,
|
descriptor: DeclarationDescriptor?,
|
||||||
): IrErrorDeclaration =
|
): IrErrorDeclaration =
|
||||||
PersistentIrErrorDeclaration(startOffset, endOffset, descriptor)
|
PersistentIrErrorDeclaration(startOffset, endOffset, descriptor)
|
||||||
|
|
||||||
|
|||||||
-3
@@ -12,8 +12,6 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier
|
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBasedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
@@ -245,7 +243,6 @@ internal class PersistentIrFakeOverrideFunction(
|
|||||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||||
_symbol = symbol
|
_symbol = symbol
|
||||||
symbol.bind(this)
|
symbol.bind(this)
|
||||||
(symbol.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier
|
||||||
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.PropertyCarrier
|
import org.jetbrains.kotlin.ir.declarations.persistent.carriers.PropertyCarrier
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
@@ -173,7 +172,6 @@ internal class PersistentIrFakeOverrideProperty(
|
|||||||
assert(_symbol == null) { "$this already has symbol _symbol" }
|
assert(_symbol == null) { "$this already has symbol _symbol" }
|
||||||
_symbol = symbol
|
_symbol = symbol
|
||||||
symbol.bind(this)
|
symbol.bind(this)
|
||||||
(symbol.descriptor as? WrappedPropertyDescriptor)?.bind(this)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,15 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.builders
|
package org.jetbrains.kotlin.ir.builders
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
|
||||||
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.IrDeclaration
|
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedVariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.*
|
import org.jetbrains.kotlin.ir.symbols.impl.*
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ interface IrFactory {
|
|||||||
fun createErrorDeclaration(
|
fun createErrorDeclaration(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
descriptor: DeclarationDescriptor,
|
descriptor: DeclarationDescriptor? = null,
|
||||||
): IrErrorDeclaration
|
): IrErrorDeclaration
|
||||||
|
|
||||||
fun createField(
|
fun createField(
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
|
|
||||||
/* Descriptors that serve purely as a view into IR structures.
|
/* Descriptors that serve purely as a view into IR structures.
|
||||||
@@ -112,6 +113,7 @@ fun IrDeclaration.toIrBasedDescriptor(): DeclarationDescriptor = when (this) {
|
|||||||
is IrProperty -> toIrBasedDescriptor()
|
is IrProperty -> toIrBasedDescriptor()
|
||||||
is IrField -> toIrBasedDescriptor()
|
is IrField -> toIrBasedDescriptor()
|
||||||
is IrTypeAlias -> toIrBasedDescriptor()
|
is IrTypeAlias -> toIrBasedDescriptor()
|
||||||
|
is IrErrorDeclaration -> toIrBasedDescriptor()
|
||||||
else -> error("Unknown declaration kind")
|
else -> error("Unknown declaration kind")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,6 +660,27 @@ open class IrBasedClassDescriptor(owner: IrClass) : ClassDescriptor, IrBasedDecl
|
|||||||
|
|
||||||
fun IrClass.toIrBasedDescriptor() = IrBasedClassDescriptor(this)
|
fun IrClass.toIrBasedDescriptor() = IrBasedClassDescriptor(this)
|
||||||
|
|
||||||
|
class LazyTypeConstructor(
|
||||||
|
val classDescriptor: ClassDescriptor,
|
||||||
|
val parametersBuilder: () -> List<TypeParameterDescriptor>,
|
||||||
|
val superTypesBuilder: () -> List<KotlinType>,
|
||||||
|
storageManager: StorageManager
|
||||||
|
) : AbstractClassTypeConstructor(storageManager) {
|
||||||
|
val parameters_ by lazy { parametersBuilder() }
|
||||||
|
val superTypes_ by lazy { superTypesBuilder() }
|
||||||
|
|
||||||
|
override fun getParameters() = parameters_
|
||||||
|
|
||||||
|
override fun computeSupertypes() = superTypes_
|
||||||
|
|
||||||
|
override fun isDenotable() = true
|
||||||
|
|
||||||
|
override fun getDeclarationDescriptor() = classDescriptor
|
||||||
|
|
||||||
|
override val supertypeLoopChecker: SupertypeLoopChecker
|
||||||
|
get() = SupertypeLoopChecker.EMPTY
|
||||||
|
}
|
||||||
|
|
||||||
open class IrBasedEnumEntryDescriptor(owner: IrEnumEntry) : ClassDescriptor, IrBasedDeclarationDescriptor<IrEnumEntry>(owner) {
|
open class IrBasedEnumEntryDescriptor(owner: IrEnumEntry) : ClassDescriptor, IrBasedDeclarationDescriptor<IrEnumEntry>(owner) {
|
||||||
override fun getName() = owner.name
|
override fun getName() = owner.name
|
||||||
|
|
||||||
@@ -1037,6 +1060,25 @@ open class IrBasedFieldDescriptor(owner: IrField) : PropertyDescriptor, IrBasedD
|
|||||||
|
|
||||||
fun IrField.toIrBasedDescriptor() = IrBasedFieldDescriptor(this)
|
fun IrField.toIrBasedDescriptor() = IrBasedFieldDescriptor(this)
|
||||||
|
|
||||||
|
class IrBasedErrorDescriptor(owner: IrErrorDeclaration) : IrBasedDeclarationDescriptor<IrErrorDeclaration>(owner) {
|
||||||
|
override fun getName(): Name = error("IrBasedErrorDescriptor.getName: Should not be reached")
|
||||||
|
|
||||||
|
override fun getOriginal(): DeclarationDescriptorWithSource =
|
||||||
|
error("IrBasedErrorDescriptor.getOriginal: Should not be reached")
|
||||||
|
|
||||||
|
override fun getContainingDeclaration(): DeclarationDescriptor =
|
||||||
|
error("IrBasedErrorDescriptor.getContainingDeclaration: Should not be reached")
|
||||||
|
|
||||||
|
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>?, data: D): R {
|
||||||
|
error("IrBasedErrorDescriptor.accept: Should not be reached")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun acceptVoid(visitor: DeclarationDescriptorVisitor<Void, Void>?) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun IrErrorDeclaration.toIrBasedDescriptor() = IrBasedErrorDescriptor(this)
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
private fun getContainingDeclaration(declaration: IrDeclaration): DeclarationDescriptor {
|
private fun getContainingDeclaration(declaration: IrDeclaration): DeclarationDescriptor {
|
||||||
val parent = declaration.parent
|
val parent = declaration.parent
|
||||||
|
|||||||
@@ -273,8 +273,6 @@ class IrFunctionFactory(private val irBuiltIns: IrBuiltIns, private val symbolTa
|
|||||||
isAssignable = false
|
isAssignable = false
|
||||||
)
|
)
|
||||||
|
|
||||||
if (vDescriptor is WrappedReceiverParameterDescriptor) vDescriptor.bind(vDeclaration)
|
|
||||||
|
|
||||||
return vDeclaration
|
return vDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,7 +337,6 @@ class IrFunctionFactory(private val irBuiltIns: IrBuiltIns, private val symbolTa
|
|||||||
isAssignable = false
|
isAssignable = false
|
||||||
)
|
)
|
||||||
vDeclaration.parent = fDeclaration
|
vDeclaration.parent = fDeclaration
|
||||||
if (vDescriptor is WrappedValueParameterDescriptor) vDescriptor.bind(vDeclaration)
|
|
||||||
fDeclaration.valueParameters += vDeclaration
|
fDeclaration.valueParameters += vDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.ir.symbols.impl
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
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.descriptors.WrappedDeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
|
import org.jetbrains.kotlin.ir.expressions.IrReturnableBlock
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
@@ -52,8 +51,8 @@ abstract class IrBindableSymbolBase<out D : DeclarationDescriptor, B : IrSymbolO
|
|||||||
assert(descriptor == null || isOriginalDescriptor(descriptor)) {
|
assert(descriptor == null || isOriginalDescriptor(descriptor)) {
|
||||||
"Substituted descriptor $descriptor for ${descriptor!!.original}"
|
"Substituted descriptor $descriptor for ${descriptor!!.original}"
|
||||||
}
|
}
|
||||||
if (descriptor !is WrappedDeclarationDescriptor<*>) {
|
if (descriptor != null) {
|
||||||
val containingDeclaration = descriptor?.containingDeclaration
|
val containingDeclaration = descriptor.containingDeclaration
|
||||||
assert(containingDeclaration == null || isOriginalDescriptor(containingDeclaration)) {
|
assert(containingDeclaration == null || isOriginalDescriptor(containingDeclaration)) {
|
||||||
"Substituted containing declaration: $containingDeclaration\nfor descriptor: $descriptor"
|
"Substituted containing declaration: $containingDeclaration\nfor descriptor: $descriptor"
|
||||||
}
|
}
|
||||||
@@ -61,9 +60,8 @@ abstract class IrBindableSymbolBase<out D : DeclarationDescriptor, B : IrSymbolO
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isOriginalDescriptor(descriptor: DeclarationDescriptor): Boolean =
|
private fun isOriginalDescriptor(descriptor: DeclarationDescriptor): Boolean =
|
||||||
descriptor is WrappedDeclarationDescriptor<*> ||
|
// TODO fix declaring/referencing value parameters: compute proper original descriptor
|
||||||
// TODO fix declaring/referencing value parameters: compute proper original descriptor
|
descriptor is ValueParameterDescriptor && isOriginalDescriptor(descriptor.containingDeclaration) ||
|
||||||
descriptor is ValueParameterDescriptor && isOriginalDescriptor(descriptor.containingDeclaration) ||
|
|
||||||
descriptor == descriptor.original
|
descriptor == descriptor.original
|
||||||
|
|
||||||
private var _owner: B? = null
|
private var _owner: B? = null
|
||||||
@@ -132,7 +130,7 @@ class IrConstructorSymbolImpl(descriptor: ClassConstructorDescriptor? = null) :
|
|||||||
IrBindableSymbolBase<ClassConstructorDescriptor, IrConstructor>(descriptor),
|
IrBindableSymbolBase<ClassConstructorDescriptor, IrConstructor>(descriptor),
|
||||||
IrConstructorSymbol
|
IrConstructorSymbol
|
||||||
|
|
||||||
class IrReturnableBlockSymbolImpl(descriptor: FunctionDescriptor) :
|
class IrReturnableBlockSymbolImpl(descriptor: FunctionDescriptor? = null) :
|
||||||
IrBindableSymbolBase<FunctionDescriptor, IrReturnableBlock>(descriptor),
|
IrBindableSymbolBase<FunctionDescriptor, IrReturnableBlock>(descriptor),
|
||||||
IrReturnableBlockSymbol
|
IrReturnableBlockSymbol
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.ir.symbols.impl
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
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.descriptors.WrappedDeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
@@ -44,15 +43,13 @@ abstract class IrBindablePublicSymbolBase<out D : DeclarationDescriptor, B : IrS
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isOriginalDescriptor(descriptor: DeclarationDescriptor): Boolean =
|
private fun isOriginalDescriptor(descriptor: DeclarationDescriptor): Boolean =
|
||||||
descriptor is WrappedDeclarationDescriptor<*> ||
|
// TODO fix declaring/referencing value parameters: compute proper original descriptor
|
||||||
// TODO fix declaring/referencing value parameters: compute proper original descriptor
|
descriptor is ValueParameterDescriptor && isOriginalDescriptor(descriptor.containingDeclaration) ||
|
||||||
descriptor is ValueParameterDescriptor && isOriginalDescriptor(descriptor.containingDeclaration) ||
|
|
||||||
descriptor == descriptor.original
|
descriptor == descriptor.original
|
||||||
|
|
||||||
private var _owner: B? = null
|
private var _owner: B? = null
|
||||||
override val owner: B
|
override val owner: B
|
||||||
get() = _owner ?:
|
get() = _owner ?: throw IllegalStateException("Symbol for $signature is unbound")
|
||||||
throw IllegalStateException("Symbol for $signature is unbound")
|
|
||||||
|
|
||||||
override fun bind(owner: B) {
|
override fun bind(owner: B) {
|
||||||
if (_owner == null) {
|
if (_owner == null) {
|
||||||
|
|||||||
@@ -74,10 +74,12 @@ class DeclarationStubGenerator(
|
|||||||
|
|
||||||
override fun getDeclaration(symbol: IrSymbol): IrDeclaration? {
|
override fun getDeclaration(symbol: IrSymbol): IrDeclaration? {
|
||||||
// Special case: generating field for an already generated property.
|
// Special case: generating field for an already generated property.
|
||||||
if (symbol is IrFieldSymbol && (symbol.descriptor as? WrappedPropertyDescriptor)?.isBound() == true) {
|
// -- this used to be done via a trick (ab)using WrappedDescriptors. Not clear if this code should ever be invoked,
|
||||||
return generateStubBySymbol(symbol, symbol.descriptor)
|
// and if so, how it can be reproduced without them.
|
||||||
}
|
// if (symbol is IrFieldSymbol && (symbol.descriptor as? WrappedPropertyDescriptor)?.isBound() == true) {
|
||||||
val descriptor = if (!symbol.hasDescriptor || symbol.descriptor is WrappedDeclarationDescriptor<*>)
|
// return generateStubBySymbol(symbol, symbol.descriptor)
|
||||||
|
// }
|
||||||
|
val descriptor = if (!symbol.hasDescriptor)
|
||||||
findDescriptorBySignature(
|
findDescriptorBySignature(
|
||||||
symbol.signature
|
symbol.signature
|
||||||
?: error("Symbol is not public API. Expected signature for symbol: ${symbol.descriptor}")
|
?: error("Symbol is not public API. Expected signature for symbol: ${symbol.descriptor}")
|
||||||
@@ -85,9 +87,7 @@ class DeclarationStubGenerator(
|
|||||||
else
|
else
|
||||||
symbol.descriptor
|
symbol.descriptor
|
||||||
if (descriptor == null) return null
|
if (descriptor == null) return null
|
||||||
return generateStubBySymbol(symbol, descriptor).also {
|
return generateStubBySymbol(symbol, descriptor)
|
||||||
symbol.descriptor.bind(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateOrGetEmptyExternalPackageFragmentStub(descriptor: PackageFragmentDescriptor): IrExternalPackageFragment {
|
fun generateOrGetEmptyExternalPackageFragmentStub(descriptor: PackageFragmentDescriptor): IrExternalPackageFragment {
|
||||||
@@ -377,22 +377,4 @@ class DeclarationStubGenerator(
|
|||||||
}
|
}
|
||||||
return candidates.firstOrNull { symbolTable.signaturer.composeSignature(it) == signature }
|
return candidates.firstOrNull { symbolTable.signaturer.composeSignature(it) == signature }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun DeclarationDescriptor.bind(declaration: IrDeclaration) {
|
|
||||||
when (this) {
|
|
||||||
is WrappedValueParameterDescriptor -> bind(declaration as IrValueParameter)
|
|
||||||
is WrappedReceiverParameterDescriptor -> bind(declaration as IrValueParameter)
|
|
||||||
is WrappedTypeParameterDescriptor -> bind(declaration as IrTypeParameter)
|
|
||||||
is WrappedVariableDescriptor -> bind(declaration as IrVariable)
|
|
||||||
is WrappedVariableDescriptorWithAccessor -> bind(declaration as IrLocalDelegatedProperty)
|
|
||||||
is WrappedSimpleFunctionDescriptor -> bind(declaration as IrSimpleFunction)
|
|
||||||
is WrappedClassConstructorDescriptor -> bind(declaration as IrConstructor)
|
|
||||||
is WrappedClassDescriptor -> bind(declaration as IrClass)
|
|
||||||
is WrappedEnumEntryDescriptor -> bind(declaration as IrEnumEntry)
|
|
||||||
is WrappedPropertyDescriptor -> (declaration as? IrProperty)?.let { bind(it) }
|
|
||||||
is WrappedTypeAliasDescriptor -> bind(declaration as IrTypeAlias)
|
|
||||||
is WrappedFieldDescriptor -> bind(declaration as IrField)
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.util
|
package org.jetbrains.kotlin.ir.util
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
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
|
||||||
@@ -15,7 +14,6 @@ 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.IrAnonymousInitializerSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrScriptSymbolImpl
|
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ open class DeepCopySymbolRemapper(
|
|||||||
override fun visitBlock(expression: IrBlock) {
|
override fun visitBlock(expression: IrBlock) {
|
||||||
if (expression is IrReturnableBlock) {
|
if (expression is IrReturnableBlock) {
|
||||||
remapSymbol(returnableBlocks, expression) {
|
remapSymbol(returnableBlocks, expression) {
|
||||||
IrReturnableBlockSymbolImpl(expression.descriptor)
|
IrReturnableBlockSymbolImpl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expression.acceptChildrenVoid(this)
|
expression.acceptChildrenVoid(this)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrScriptImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrScriptImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazySymbolTable
|
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazySymbolTable
|
||||||
import org.jetbrains.kotlin.ir.descriptors.*
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
@@ -20,7 +19,6 @@ import org.jetbrains.kotlin.ir.symbols.impl.*
|
|||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
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
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
|
|
||||||
|
|
||||||
interface ReferenceSymbolTable {
|
interface ReferenceSymbolTable {
|
||||||
fun referenceClass(descriptor: ClassDescriptor): IrClassSymbol
|
fun referenceClass(descriptor: ClassDescriptor): IrClassSymbol
|
||||||
@@ -184,20 +182,11 @@ class SymbolTable(
|
|||||||
protected open fun signature(descriptor: D): IdSignature? = signaturer.composeSignature(descriptor)
|
protected open fun signature(descriptor: D): IdSignature? = signaturer.composeSignature(descriptor)
|
||||||
|
|
||||||
override fun get(d: D): S? {
|
override fun get(d: D): S? {
|
||||||
return if (d !is WrappedDeclarationDescriptor<*>) {
|
val sig = signature(d)
|
||||||
val sig = signature(d)
|
return if (sig != null) {
|
||||||
if (sig != null) {
|
idSigToSymbol[sig]
|
||||||
idSigToSymbol[sig]
|
|
||||||
} else {
|
|
||||||
descriptorToSymbol[d]
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (d.isBound()) {
|
descriptorToSymbol[d]
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
d.owner.symbol as S
|
|
||||||
} else {
|
|
||||||
descriptorToSymbol[d]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +225,9 @@ class SymbolTable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(d: D): S? {
|
operator fun get(d: D): S? {
|
||||||
return if (d !is WrappedDeclarationDescriptor<*>) {
|
val sig = signaturer.composeSignature(d)
|
||||||
val sig = signaturer.composeSignature(d)
|
return if (sig != null) {
|
||||||
if (sig != null) {
|
getByIdSignature(sig)
|
||||||
getByIdSignature(sig)
|
|
||||||
} else {
|
|
||||||
getByDescriptor(d)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
getByDescriptor(d)
|
getByDescriptor(d)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBasedTypeParameterDescriptor
|
import org.jetbrains.kotlin.ir.descriptors.IrBasedTypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
|
|
||||||
|
|
||||||
val TypeParameterDescriptor.originalTypeParameter: TypeParameterDescriptor
|
val TypeParameterDescriptor.originalTypeParameter: TypeParameterDescriptor
|
||||||
get() =
|
get() =
|
||||||
if (this is WrappedTypeParameterDescriptor || this is IrBasedTypeParameterDescriptor) {
|
if (this is IrBasedTypeParameterDescriptor) {
|
||||||
original
|
original
|
||||||
} else {
|
} else {
|
||||||
when (val container = containingDeclaration.original) {
|
when (val container = containingDeclaration.original) {
|
||||||
|
|||||||
+1
-20
@@ -1046,9 +1046,6 @@ abstract class IrFileDeserializer(
|
|||||||
).apply {
|
).apply {
|
||||||
if (proto.hasDefaultValue())
|
if (proto.hasDefaultValue())
|
||||||
defaultValue = irFactory.createExpressionBody(deserializeExpressionBody(proto.defaultValue))
|
defaultValue = irFactory.createExpressionBody(deserializeExpressionBody(proto.defaultValue))
|
||||||
|
|
||||||
(descriptor as? WrappedValueParameterDescriptor)?.bind(this)
|
|
||||||
(descriptor as? WrappedReceiverParameterDescriptor)?.bind(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1110,9 +1107,7 @@ abstract class IrFileDeserializer(
|
|||||||
private fun deserializeErrorDeclaration(proto: ProtoErrorDeclaration): IrErrorDeclaration {
|
private fun deserializeErrorDeclaration(proto: ProtoErrorDeclaration): IrErrorDeclaration {
|
||||||
require(allowErrorNodes) { "IrErrorDeclaration found but error code is not allowed" }
|
require(allowErrorNodes) { "IrErrorDeclaration found but error code is not allowed" }
|
||||||
val coordinates = BinaryCoordinates.decode(proto.coordinates)
|
val coordinates = BinaryCoordinates.decode(proto.coordinates)
|
||||||
val descriptor = WrappedErrorDescriptor()
|
return irFactory.createErrorDeclaration(coordinates.startOffset, coordinates.endOffset).also {
|
||||||
return irFactory.createErrorDeclaration(coordinates.startOffset, coordinates.endOffset, descriptor).also {
|
|
||||||
descriptor.bind(it)
|
|
||||||
it.parent = parentsStack.peek()!!
|
it.parent = parentsStack.peek()!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1241,8 +1236,6 @@ abstract class IrFileDeserializer(
|
|||||||
)
|
)
|
||||||
}.apply {
|
}.apply {
|
||||||
overriddenSymbols = proto.overriddenList.map { deserializeIrSymbolAndRemap(it) as IrSimpleFunctionSymbol }
|
overriddenSymbols = proto.overriddenList.map { deserializeIrSymbolAndRemap(it) as IrSimpleFunctionSymbol }
|
||||||
|
|
||||||
(descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1262,8 +1255,6 @@ abstract class IrFileDeserializer(
|
|||||||
).apply {
|
).apply {
|
||||||
if (proto.hasInitializer())
|
if (proto.hasInitializer())
|
||||||
initializer = deserializeExpression(proto.initializer)
|
initializer = deserializeExpression(proto.initializer)
|
||||||
|
|
||||||
(descriptor as? WrappedVariableDescriptor)?.bind(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1350,8 +1341,6 @@ abstract class IrFileDeserializer(
|
|||||||
getter = deserializeIrFunction(proto.getter)
|
getter = deserializeIrFunction(proto.getter)
|
||||||
if (proto.hasSetter())
|
if (proto.hasSetter())
|
||||||
setter = deserializeIrFunction(proto.setter)
|
setter = deserializeIrFunction(proto.setter)
|
||||||
|
|
||||||
(descriptor as? WrappedVariableDescriptorWithAccessor)?.bind(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1387,17 +1376,9 @@ abstract class IrFileDeserializer(
|
|||||||
}
|
}
|
||||||
if (proto.hasBackingField()) {
|
if (proto.hasBackingField()) {
|
||||||
backingField = deserializeIrField(proto.backingField).also {
|
backingField = deserializeIrField(proto.backingField).also {
|
||||||
// A property symbol and its field symbol share the same descriptor.
|
|
||||||
// Unfortunately symbol deserialization doesn't know anything about that.
|
|
||||||
// So we can end up with two wrapped property descriptors for property and its field.
|
|
||||||
// In that case we need to bind the field's one here.
|
|
||||||
if (descriptor != it.descriptor)
|
|
||||||
(it.descriptor as? WrappedPropertyDescriptor)?.bind(this)
|
|
||||||
it.correspondingPropertySymbol = symbol
|
it.correspondingPropertySymbol = symbol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(descriptor as? WrappedPropertyDescriptor)?.bind(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrAbstractFunctionFactory
|
import org.jetbrains.kotlin.ir.descriptors.IrAbstractFunctionFactory
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedDeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
import org.jetbrains.kotlin.library.IrLibrary
|
import org.jetbrains.kotlin.library.IrLibrary
|
||||||
@@ -42,7 +41,7 @@ abstract class IrModuleDeserializer(val moduleDescriptor: ModuleDescriptor) {
|
|||||||
open fun declareIrSymbol(symbol: IrSymbol) {
|
open fun declareIrSymbol(symbol: IrSymbol) {
|
||||||
val signature = symbol.signature
|
val signature = symbol.signature
|
||||||
require(signature != null) { "Symbol is not public API: ${symbol.descriptor}" }
|
require(signature != null) { "Symbol is not public API: ${symbol.descriptor}" }
|
||||||
assert(symbol.descriptor !is WrappedDeclarationDescriptor<*>)
|
assert(symbol.hasDescriptor)
|
||||||
deserializeIrSymbol(signature, symbol.kind())
|
deserializeIrSymbol(signature, symbol.kind())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ abstract class IrModuleDeserializer(val moduleDescriptor: ModuleDescriptor) {
|
|||||||
|
|
||||||
// Used to resolve built in symbols like `kotlin.ir.internal.*` or `kotlin.FunctionN`
|
// Used to resolve built in symbols like `kotlin.ir.internal.*` or `kotlin.FunctionN`
|
||||||
class IrModuleDeserializerWithBuiltIns(
|
class IrModuleDeserializerWithBuiltIns(
|
||||||
private val builtIns: IrBuiltIns,
|
builtIns: IrBuiltIns,
|
||||||
private val functionFactory: IrAbstractFunctionFactory,
|
private val functionFactory: IrAbstractFunctionFactory,
|
||||||
private val delegate: IrModuleDeserializer
|
private val delegate: IrModuleDeserializer
|
||||||
) : IrModuleDeserializer(delegate.moduleDescriptor) {
|
) : IrModuleDeserializer(delegate.moduleDescriptor) {
|
||||||
|
|||||||
-3
@@ -556,8 +556,6 @@ abstract class KotlinIrLinker(
|
|||||||
if (!symbol.hasDescriptor) return null
|
if (!symbol.hasDescriptor) return null
|
||||||
|
|
||||||
val descriptor = symbol.descriptor
|
val descriptor = symbol.descriptor
|
||||||
|
|
||||||
if (descriptor is WrappedDeclarationDescriptor<*>) return null
|
|
||||||
if (descriptor is CallableMemberDescriptor) {
|
if (descriptor is CallableMemberDescriptor) {
|
||||||
if (descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
if (descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||||
// skip fake overrides
|
// skip fake overrides
|
||||||
@@ -578,7 +576,6 @@ abstract class KotlinIrLinker(
|
|||||||
|
|
||||||
if (!symbol.isPublicApi) {
|
if (!symbol.isPublicApi) {
|
||||||
val descriptor = symbol.descriptor
|
val descriptor = symbol.descriptor
|
||||||
if (descriptor is WrappedDeclarationDescriptor<*>) return null
|
|
||||||
if (!platformSpecificSymbol(symbol)) {
|
if (!platformSpecificSymbol(symbol)) {
|
||||||
if (descriptor.module !== currentModule) return null
|
if (descriptor.module !== currentModule) return null
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.backend.common.serialization.signature
|
package org.jetbrains.kotlin.backend.common.serialization.signature
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.descriptors.WrappedDeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.ir.util.IdSignature
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignatureComposer
|
import org.jetbrains.kotlin.ir.util.IdSignatureComposer
|
||||||
import org.jetbrains.kotlin.ir.util.KotlinMangler
|
import org.jetbrains.kotlin.ir.util.KotlinMangler
|
||||||
@@ -109,14 +108,12 @@ open class IdSignatureDescriptor(private val mangler: KotlinMangler.DescriptorMa
|
|||||||
private val composer by lazy { createSignatureBuilder() }
|
private val composer by lazy { createSignatureBuilder() }
|
||||||
|
|
||||||
override fun composeSignature(descriptor: DeclarationDescriptor): IdSignature? {
|
override fun composeSignature(descriptor: DeclarationDescriptor): IdSignature? {
|
||||||
if (descriptor is WrappedDeclarationDescriptor<*>) return null
|
|
||||||
return if (mangler.run { descriptor.isExported() }) {
|
return if (mangler.run { descriptor.isExported() }) {
|
||||||
composer.buildSignature(descriptor)
|
composer.buildSignature(descriptor)
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun composeEnumEntrySignature(descriptor: ClassDescriptor): IdSignature? {
|
override fun composeEnumEntrySignature(descriptor: ClassDescriptor): IdSignature? {
|
||||||
if (descriptor is WrappedDeclarationDescriptor<*>) return null
|
|
||||||
return if (mangler.run { descriptor.isExportEnumEntry() }) {
|
return if (mangler.run { descriptor.isExportEnumEntry() }) {
|
||||||
composer.buildSignature(descriptor)
|
composer.buildSignature(descriptor)
|
||||||
} else null
|
} else null
|
||||||
|
|||||||
+1
-4
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
|||||||
import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||||
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.descriptors.WrappedValueParameterDescriptor
|
|
||||||
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.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
@@ -149,12 +148,11 @@ class ComposeLikeDefaultArgumentRewriter(
|
|||||||
declaration.valueParameters.forEach { param ->
|
declaration.valueParameters.forEach { param ->
|
||||||
newParameters.add(
|
newParameters.add(
|
||||||
if (param.defaultValue != null) {
|
if (param.defaultValue != null) {
|
||||||
val descriptor = WrappedValueParameterDescriptor()
|
|
||||||
val result = IrValueParameterImpl(
|
val result = IrValueParameterImpl(
|
||||||
param.startOffset,
|
param.startOffset,
|
||||||
param.endOffset,
|
param.endOffset,
|
||||||
param.origin,
|
param.origin,
|
||||||
IrValueParameterSymbolImpl(descriptor),
|
IrValueParameterSymbolImpl(),
|
||||||
param.name,
|
param.name,
|
||||||
index = param.index,
|
index = param.index,
|
||||||
type = defaultParameterType(param),
|
type = defaultParameterType(param),
|
||||||
@@ -167,7 +165,6 @@ class ComposeLikeDefaultArgumentRewriter(
|
|||||||
it.defaultValue = param.defaultValue
|
it.defaultValue = param.defaultValue
|
||||||
it.parent = declaration
|
it.parent = declaration
|
||||||
}
|
}
|
||||||
descriptor.bind(result)
|
|
||||||
parameterMapping[param] = result
|
parameterMapping[param] = result
|
||||||
result
|
result
|
||||||
} else param
|
} else param
|
||||||
|
|||||||
Reference in New Issue
Block a user