diff --git a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt index 0264487c503..8e3bdf6c496 100644 --- a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt +++ b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmMangleComputer.kt @@ -14,8 +14,10 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.firSymbolProvider +import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.toSymbol 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 @@ -199,6 +201,10 @@ open class FirJvmMangleComputer( when (type) { is ConeLookupTagBasedType -> { when (val symbol = type.lookupTag.toSymbol(session)) { + is FirTypeAliasSymbol -> { + mangleType(tBuilder, type.fullyExpandedType(session)) + return + } is FirClassSymbol -> symbol.fir.accept(copy(MangleMode.FQNAME), false) is FirTypeParameterSymbol -> tBuilder.mangleTypeParameterReference(symbol.fir) } diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index bfb801447b4..fbefead8115 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1772,6 +1772,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/firProblems/putIfAbsent.kt"); } + @TestMetadata("SignatureClash.kt") + public void testSignatureClash() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/SignatureClash.kt"); + } + @TestMetadata("V8ArrayToList.kt") public void testV8ArrayToList() throws Exception { runTest("compiler/testData/ir/irText/firProblems/V8ArrayToList.kt"); diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt new file mode 100644 index 00000000000..522dd3209d5 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt @@ -0,0 +1,34 @@ +FILE fqName: fileName:/SignatureClash.kt + TYPEALIAS name:Some visibility:public expandedType:kotlin.Function1 + CLASS OBJECT name:Factory modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Factory + CONSTRUCTOR visibility:private <> () returnType:.Factory [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Factory modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:foo visibility:public modality:FINAL <> ($this:.Factory, a:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Factory + VALUE_PARAMETER name:a index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (a: kotlin.String): kotlin.String declared in .Factory' + CONST String type=kotlin.String value="Alpha" + FUN name:foo visibility:public modality:FINAL <> ($this:.Factory, a:kotlin.String, f:kotlin.Function1) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Factory + VALUE_PARAMETER name:a index:0 type:kotlin.String + VALUE_PARAMETER name:f index:1 type:kotlin.Function1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (a: kotlin.String, f: kotlin.Function1): kotlin.String declared in .Factory' + CONST String type=kotlin.String value="Omega" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.kt b/compiler/testData/ir/irText/firProblems/SignatureClash.kt new file mode 100644 index 00000000000..e5aa52ada06 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.kt @@ -0,0 +1,12 @@ +typealias Some = (Any) -> String? + +object Factory { + fun foo( + a: String, + ): String = "Alpha" + + fun foo( + a: String, + f: Some + ): String = "Omega" +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.txt new file mode 100644 index 00000000000..9e9979489b1 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.txt @@ -0,0 +1,34 @@ +FILE fqName: fileName:/SignatureClash.kt + TYPEALIAS name:Some visibility:public expandedType:kotlin.Function1 + CLASS OBJECT name:Factory modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Factory + CONSTRUCTOR visibility:private <> () returnType:.Factory [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Factory modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:foo visibility:public modality:FINAL <> ($this:.Factory, a:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Factory + VALUE_PARAMETER name:a index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (a: kotlin.String): kotlin.String declared in .Factory' + CONST String type=kotlin.String value="Alpha" + FUN name:foo visibility:public modality:FINAL <> ($this:.Factory, a:kotlin.String, f:kotlin.Function1{ .Some }) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Factory + VALUE_PARAMETER name:a index:0 type:kotlin.String + VALUE_PARAMETER name:f index:1 type:kotlin.Function1{ .Some } + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (a: kotlin.String, f: kotlin.Function1{ .Some }): kotlin.String declared in .Factory' + CONST String type=kotlin.String value="Omega" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index cb862131311..7d84e9e0fd9 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1771,6 +1771,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/firProblems/putIfAbsent.kt"); } + @TestMetadata("SignatureClash.kt") + public void testSignatureClash() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/SignatureClash.kt"); + } + @TestMetadata("V8ArrayToList.kt") public void testV8ArrayToList() throws Exception { runTest("compiler/testData/ir/irText/firProblems/V8ArrayToList.kt");