JVM_IR KT-45853 include return type into Java method IdSignature

This is a hack required to accept [potentially] incorrect input
provided by the front-end; see KT-46042.
This commit is contained in:
Dmitry Petrov
2021-04-08 22:29:02 +03:00
committed by TeamCityServer
parent 5ce746f1ec
commit 7e03f8ea80
27 changed files with 299 additions and 70 deletions
@@ -80,6 +80,8 @@ abstract class DescriptorMangleComputer(protected val builder: StringBuilder, pr
protected open fun addReturnType(): Boolean = false
protected open fun addReturnTypeSpecialCase(functionDescriptor: FunctionDescriptor): Boolean = false
open fun FunctionDescriptor.specialValueParamPrefix(param: ValueParameterDescriptor): String = ""
private val CallableDescriptor.isRealStatic: Boolean
@@ -125,7 +127,7 @@ abstract class DescriptorMangleComputer(protected val builder: StringBuilder, pr
.collectForMangler(builder, MangleConstant.TYPE_PARAMETERS) { mangleTypeParameter(this, it) }
returnType?.run {
if (!isCtor && !isUnit() && addReturnType()) {
if (!isCtor && !isUnit() && (addReturnType() || addReturnTypeSpecialCase(this@mangleSignature))) {
mangleType(builder, this)
}
}
@@ -33,6 +33,8 @@ abstract class IrMangleComputer(protected val builder: StringBuilder, private va
open fun addReturnType(): Boolean = false
protected open fun addReturnTypeSpecialCase(irFunction: IrFunction): Boolean = false
abstract override fun copy(newMode: MangleMode): IrMangleComputer
private fun StringBuilder.appendName(s: String) {
@@ -121,7 +123,7 @@ abstract class IrMangleComputer(protected val builder: StringBuilder, private va
typeParameters.collectForMangler(builder, MangleConstant.TYPE_PARAMETERS) { mangleTypeParameter(this, it) }
if (!isCtor && !returnType.isUnit() && addReturnType()) {
if (!isCtor && !returnType.isUnit() && (addReturnType() || addReturnTypeSpecialCase(this))) {
mangleType(builder, returnType)
}
}