Fir2Ir: adjust FirBasedSignatureComposer for constructors

Consatructor's name in the signature should be '<init>', not the
name of the constructed class.
This commit is contained in:
Georgy Bronnikov
2021-12-13 18:50:20 +03:00
committed by Alexander Udalov
parent af123d1daf
commit 829b2822c6
3 changed files with 21 additions and 3 deletions
@@ -17,13 +17,13 @@ import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.resolve.providers.firProvider
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.signaturer.irName
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.visitors.FirVisitor
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
@@ -127,7 +127,7 @@ open class FirJvmMangleComputer(
return
}
val name = (this as? FirSimpleFunction)?.name ?: SpecialNames.ANONYMOUS
val name = this.irName
builder.append(name.asString())
platformSpecificSuffix()?.let {
@@ -93,7 +93,7 @@ class FirBasedSignatureComposer(private val mangler: FirMangler) : Fir2IrSignatu
val classId = containingClassId ?: declaration.containingClass()?.classId
val packageName = classId?.packageFqName ?: declaration.symbol.callableId.packageName
val callableName = declaration.symbol.callableId.callableName
val callableName = declaration.irName
IdSignature.CommonSignature(
packageName.asString(),
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2021 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.fir.signaturer
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
val FirCallableDeclaration.irName: Name
get() = when (this) {
is FirConstructor -> SpecialNames.INIT
is FirSimpleFunction -> this.name
is FirVariable -> this.name
else -> SpecialNames.ANONYMOUS
}