Fixes in IR lowerings:
DeepCopyIrTree: typo fix. Default arguments: made proper overridden descriptor selection. Local declarations: made proper determination whether a function is locally defined.
This commit is contained in:
+5
-5
@@ -108,7 +108,7 @@ open class DefaultArgumentStubGenerator constructor(val context: CommonBackendCo
|
||||
val expressionBody = getDefaultParameterExpressionBody(irFunction, valueParameter)
|
||||
|
||||
/* Use previously calculated values in next expression. */
|
||||
expressionBody.transformChildrenVoid(object:IrElementTransformerVoid() {
|
||||
expressionBody.transformChildrenVoid(object: IrElementTransformerVoid() {
|
||||
override fun visitGetValue(expression: IrGetValue): IrExpression {
|
||||
log { "GetValue: ${expression.descriptor}" }
|
||||
val valueSymbol = variables[expression.descriptor] ?: return expression
|
||||
@@ -200,7 +200,7 @@ private fun Scope.createTemporaryVariable(symbol: IrVariableSymbol, initializer:
|
||||
this.initializer = initializer
|
||||
}
|
||||
|
||||
private fun getDefaultParameterExpressionBody(irFunction: IrFunction, valueParameter: ValueParameterDescriptor):IrExpressionBody {
|
||||
private fun getDefaultParameterExpressionBody(irFunction: IrFunction, valueParameter: ValueParameterDescriptor): IrExpressionBody {
|
||||
return irFunction.getDefault(valueParameter) ?: TODO("FIXME!!!")
|
||||
}
|
||||
|
||||
@@ -292,14 +292,14 @@ class DefaultParameterInjector constructor(val context: CommonBackendContext): B
|
||||
private fun parametersForCall(expression: IrMemberAccessExpression): Pair<IrFunctionSymbol, List<Pair<ValueParameterDescriptor, IrExpression?>>> {
|
||||
val descriptor = expression.descriptor as FunctionDescriptor
|
||||
val keyDescriptor = if (DescriptorUtils.isOverride(descriptor))
|
||||
DescriptorUtils.getAllOverriddenDescriptors(descriptor).first()
|
||||
DescriptorUtils.getAllOverriddenDescriptors(descriptor).first { it.needsDefaultArgumentsLowering }
|
||||
else
|
||||
descriptor.original
|
||||
val realFunction = keyDescriptor.generateDefaultsFunction(context)
|
||||
val realDescriptor = realFunction.descriptor
|
||||
|
||||
log { "$descriptor -> $realDescriptor" }
|
||||
val maskValues = Array((descriptor.valueParameters.size + 31) / 32, {0})
|
||||
val maskValues = Array((descriptor.valueParameters.size + 31) / 32, { 0 })
|
||||
val params = mutableListOf<Pair<ValueParameterDescriptor, IrExpression?>>()
|
||||
params.addAll(descriptor.valueParameters.mapIndexed { i, _ ->
|
||||
val valueArgument = expression.getValueArgument(i)
|
||||
@@ -447,7 +447,7 @@ private fun FunctionDescriptor.generateDefaultsFunction(context: CommonBackendCo
|
||||
object DECLARATION_ORIGIN_FUNCTION_FOR_DEFAULT_PARAMETER :
|
||||
IrDeclarationOriginImpl("DEFAULT_PARAMETER_EXTENT")
|
||||
|
||||
private fun valueParameter(descriptor: FunctionDescriptor, index: Int, name: Name, type: KotlinType):ValueParameterDescriptor {
|
||||
private fun valueParameter(descriptor: FunctionDescriptor, index: Int, name: Name, type: KotlinType): ValueParameterDescriptor {
|
||||
return ValueParameterDescriptorImpl(
|
||||
containingDeclaration = descriptor,
|
||||
original = null,
|
||||
|
||||
+3
-3
@@ -682,7 +682,7 @@ class LocalDeclarationsLowering(val context: BackendContext, val localNameProvid
|
||||
element.acceptChildrenVoid(this)
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.declaredInFunction() = when (this.containingDeclaration) {
|
||||
private fun ClassDescriptor.declaredInFunction() = when (this.containingDeclaration) {
|
||||
is CallableDescriptor -> true
|
||||
is ClassDescriptor -> false
|
||||
is PackageFragmentDescriptor -> false
|
||||
@@ -694,7 +694,7 @@ class LocalDeclarationsLowering(val context: BackendContext, val localNameProvid
|
||||
|
||||
val descriptor = declaration.descriptor
|
||||
|
||||
if (descriptor.declaredInFunction()) {
|
||||
if (descriptor.visibility == Visibilities.LOCAL) {
|
||||
val localFunctionContext = LocalFunctionContext(declaration)
|
||||
|
||||
localFunctions[descriptor] = localFunctionContext
|
||||
@@ -710,7 +710,7 @@ class LocalDeclarationsLowering(val context: BackendContext, val localNameProvid
|
||||
declaration.acceptChildrenVoid(this)
|
||||
|
||||
val descriptor = declaration.descriptor
|
||||
assert(!descriptor.declaredInFunction())
|
||||
assert(descriptor.visibility != Visibilities.LOCAL)
|
||||
|
||||
if (descriptor.constructedClass.isInner) return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user