From 686a3d631ca556fe46b8bfb4756b0abbb9091329 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Fri, 22 Jun 2018 20:45:27 +0300 Subject: [PATCH] IR BE common: provide type arguments count explicitly for ir calls to reduce dependency on descriptors (cherry picked from commit af76ae2) --- .../lower/DefaultArgumentStubGenerator.kt | 21 ++++++------------- .../common/lower/LocalDeclarationsLowering.kt | 4 +++- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt index 41c51e4b9ab..1551c6d9ead 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2018 JetBrains s.r.o. 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.backend.common.lower @@ -134,7 +123,8 @@ open class DefaultArgumentStubGenerator constructor(val context: CommonBackendCo startOffset = irFunction.startOffset, endOffset = irFunction.endOffset, type = context.irBuiltIns.unitType, - symbol = irFunction.symbol, descriptor = irFunction.symbol.descriptor + symbol = irFunction.symbol, descriptor = irFunction.symbol.descriptor, + typeArgumentsCount = irFunction.typeParameters.size ).apply { params.forEachIndexed { i, variable -> putValueArgument(i, irGet(variable)) @@ -215,7 +205,8 @@ class DefaultParameterInjector constructor(val context: CommonBackendContext, pr endOffset = expression.endOffset, type = context.irBuiltIns.unitType, symbol = symbolForCall, - descriptor = symbolForCall.descriptor + descriptor = symbolForCall.descriptor, + typeArgumentsCount = symbolForCall.owner.typeParameters.size ) .apply { params.forEach { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt index 08b5669832a..3a8e70ded66 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt @@ -289,7 +289,8 @@ class LocalDeclarationsLowering(val context: BackendContext, val localNameProvid expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee.symbol, - newCallee.descriptor + newCallee.descriptor, + expression.typeArgumentsCount ).also { it.fillArguments(expression) it.copyTypeArgumentsFrom(expression) @@ -440,6 +441,7 @@ class LocalDeclarationsLowering(val context: BackendContext, val localNameProvid newCallee.returnType, newCallee.symbol, newCallee.descriptor, + oldCall.typeArgumentsCount, oldCall.origin, oldCall.superQualifierSymbol ).also { it.copyTypeArgumentsFrom(oldCall)