From 86836e69e936ebcae971133ae5dcddb8807e4449 Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Wed, 7 Jun 2023 16:16:36 +0200 Subject: [PATCH] [FIR2IR] Unwrap call-site substitution overrides Generating IR declarations for use-site substitution overrides leads to IR that is different from K1 as well as problems in signature generation which relies on mangling. Use-site substitutions can contain references to type parameters from the call-site which aren't handled in mangling. #KT-57022 Fixed --- .../kotlin/fir/backend/ConversionUtils.kt | 13 +- .../org/jetbrains/kotlin/fir/ClassMembers.kt | 14 +- .../genericAnnotationClasses.sig.kt.txt | 10 +- ...reComputationComplexJavaGeneric.fir.ir.txt | 42 ------ ...reComputationComplexJavaGeneric.fir.kt.txt | 16 --- ...natureComputationComplexJavaGeneric.ir.txt | 122 ++++++++++++++---- .../SignatureComputationComplexJavaGeneric.kt | 40 +++++- ...natureComputationComplexJavaGeneric.kt.txt | 36 +++++- ...reComputationComplexJavaGeneric.sig.kt.txt | 68 ++++++++-- .../genericClassInDifferentModule.sig.kt.txt | 8 +- 10 files changed, 248 insertions(+), 121 deletions(-) delete mode 100644 compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.kt.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 548cd63aea2..896fb63d97c 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -173,17 +173,24 @@ fun FirReference.toSymbolForCall( explicitReceiver: FirExpression?, preferGetter: Boolean = true, isDelegate: Boolean = false, - isReference: Boolean = false + isReference: Boolean = false, ): IrSymbol? { return when (this) { - is FirResolvedNamedReference -> - resolvedSymbol.toSymbolForCall( + is FirResolvedNamedReference -> { + var symbol = resolvedSymbol + + if (symbol is FirCallableSymbol<*> && symbol.origin == FirDeclarationOrigin.SubstitutionOverride.CallSite) { + symbol = symbol.fir.unwrapUseSiteSubstitutionOverrides().symbol + } + + symbol.toSymbolForCall( dispatchReceiver, preferGetter, explicitReceiver, isDelegate, isReference ) + } is FirThisReference -> { when (val boundSymbol = boundSymbol) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt index 7c2e9e1a2aa..09bd5a1de65 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt @@ -67,11 +67,11 @@ private object IsNewPlaceForBodyGeneration : FirDeclarationDataKey() var FirRegularClass.isNewPlaceForBodyGeneration: Boolean? by FirDeclarationDataRegistry.data(IsNewPlaceForBodyGeneration) val FirCallableDeclaration.isIntersectionOverride: Boolean get() = origin == FirDeclarationOrigin.IntersectionOverride -val FirCallableDeclaration.isSubstitutionOverride: Boolean get() = origin == FirDeclarationOrigin.SubstitutionOverride +val FirCallableDeclaration.isSubstitutionOverride: Boolean get() = origin is FirDeclarationOrigin.SubstitutionOverride val FirCallableDeclaration.isSubstitutionOrIntersectionOverride: Boolean get() = isSubstitutionOverride || isIntersectionOverride val FirCallableSymbol<*>.isIntersectionOverride: Boolean get() = origin == FirDeclarationOrigin.IntersectionOverride -val FirCallableSymbol<*>.isSubstitutionOverride: Boolean get() = origin == FirDeclarationOrigin.SubstitutionOverride +val FirCallableSymbol<*>.isSubstitutionOverride: Boolean get() = origin is FirDeclarationOrigin.SubstitutionOverride val FirCallableSymbol<*>.isSubstitutionOrIntersectionOverride: Boolean get() = isSubstitutionOverride || isIntersectionOverride inline val D.originalForSubstitutionOverride: D? @@ -132,6 +132,16 @@ inline fun D.unwrapSubstitutionOverrides(): } while (true) } +inline fun D.unwrapUseSiteSubstitutionOverrides(): D { + var current = this + + do { + if (current.origin != FirDeclarationOrigin.SubstitutionOverride.CallSite) return current + val next = current.originalForSubstitutionOverride ?: return current + current = next + } while (true) +} + inline fun > S.unwrapFakeOverrides(): S = fir.unwrapFakeOverrides().symbol as S inline fun > S.unwrapSubstitutionOverrides(): S = fir.unwrapSubstitutionOverrides().symbol as S diff --git a/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.sig.kt.txt b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.sig.kt.txt index 1a12437c9a9..fe8fc8bdd4f 100644 --- a/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.sig.kt.txt +++ b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.sig.kt.txt @@ -11,7 +11,7 @@ open annotation class Test1 : Annotation { // CHECK JVM_IR: // Mangled name: ann.Test1#(){}kotlin.Int // Public signature: ann/Test1.x.|4966956098150895696[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: ann.Test1#(){} // Public signature: ann/Test1.x.|1482705010654679335[0] get @@ -34,7 +34,7 @@ open annotation class Test2 : Annotation { // CHECK JVM_IR: // Mangled name: ann.Test2#(){}kotlin.Int // Public signature: ann/Test2.x.|4966956098150895696[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: ann.Test2#(){} // Public signature: ann/Test2.x.|1482705010654679335[0] get @@ -57,7 +57,7 @@ open annotation class Test3> : Annotation { // CHECK JVM_IR: // Mangled name: ann.Test3#(){}ann.Test1> // Public signature: ann/Test3.x.|-476605448158023096[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: ann.Test3#(){} // Public signature: ann/Test3.x.|1482705010654679335[0] get @@ -80,7 +80,7 @@ open annotation class Test4 : Annotation { // CHECK JVM_IR: // Mangled name: ann.Test4#(){}kotlin.Array>> // Public signature: ann/Test4.x.|-4754126975303916738[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: ann.Test4#(){} // Public signature: ann/Test4.x.|1482705010654679335[0] get @@ -103,7 +103,7 @@ open annotation class Test5 : Annotation { // CHECK JVM_IR: // Mangled name: ann.Test5#(){}kotlin.Array>> // Public signature: ann/Test5.xs.|-4480240150602494549[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: ann.Test5#(){} // Public signature: ann/Test5.xs.|-6958094100501701183[0] get diff --git a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.ir.txt b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.ir.txt deleted file mode 100644 index 577c6e139de..00000000000 --- a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.ir.txt +++ /dev/null @@ -1,42 +0,0 @@ -FILE fqName: fileName:/test.kt - CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J.Test>] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test.Test> - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - CONSTRUCTOR visibility:public <> (x:T of .Test) returnType:.Test.Test> [primary] - VALUE_PARAMETER name:x index:0 type:T of .Test - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .J' - : T of .Test - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J.Test>]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: T of .Test declared in .Test.' type=T of .Test origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test.Test>) returnType:T of .Test - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test.Test> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): T of .Test declared in .Test' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test visibility:private [final]' type=T of .Test origin=null - receiver: GET_VAR ': .Test.Test> declared in .Test.' type=.Test.Test> origin=null - FUN name:test visibility:public modality:FINAL <> ($this:.Test.Test>, b:.J.B.Test>) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Test.Test> - VALUE_PARAMETER name:b index:0 type:.J.B.Test> - BLOCK_BODY - CALL 'public open fun output (x: @[EnhancedNullability] T of .Test): kotlin.Unit declared in .J.B' type=kotlin.Unit origin=null - $this: GET_VAR 'b: .J.B.Test> declared in .Test.test' type=.J.B.Test> origin=null - x: CALL 'public final fun (): T of .Test declared in .Test' type=T of .Test origin=GET_PROPERTY - $this: GET_VAR ': .Test.Test> declared in .Test.test' type=.Test.Test> origin=null - 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 declared in .J - $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 .J - $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 .J - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.kt.txt b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.kt.txt deleted file mode 100644 index ffa97e0147f..00000000000 --- a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.fir.kt.txt +++ /dev/null @@ -1,16 +0,0 @@ -class Test : J { - constructor(x: T) /* primary */ { - super/*J*/() - /* () */ - - } - - val x: T - field = x - get - - fun test(b: B) { - b.output(x = .()) - } - -} diff --git a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.ir.txt b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.ir.txt index 41e8901068a..1307e7f20fd 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.ir.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.ir.txt @@ -1,42 +1,114 @@ FILE fqName: fileName:/test.kt - CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J.Test>] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test.Test> + CLASS CLASS name:Inv modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Inv.Inv> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - CONSTRUCTOR visibility:public <> (x:T of .Test) returnType:.Test.Test> [primary] - VALUE_PARAMETER name:x index:0 type:T of .Test + CONSTRUCTOR visibility:public <> (x:T of .Inv) returnType:.Inv.Inv> [primary] + VALUE_PARAMETER name:x index:0 type:T of .Inv BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .J' - : T of .Test - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J.Test>]' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inv modality:FINAL visibility:public superTypes:[kotlin.Any]' PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test visibility:private [final] + FIELD PROPERTY_BACKING_FIELD name:x type:T of .Inv visibility:private [final] EXPRESSION_BODY - GET_VAR 'x: T of .Test declared in .Test.' type=T of .Test origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test.Test>) returnType:T of .Test + GET_VAR 'x: T of .Inv declared in .Inv.' type=T of .Inv origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Inv.Inv>) returnType:T of .Inv correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test.Test> + $this: VALUE_PARAMETER name: type:.Inv.Inv> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): T of .Test declared in .Test' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test visibility:private [final]' type=T of .Test origin=null - receiver: GET_VAR ': .Test.Test> declared in .Test.' type=.Test.Test> origin=null - FUN name:test visibility:public modality:FINAL <> ($this:.Test.Test>, b:.J.B.Test>) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Test.Test> - VALUE_PARAMETER name:b index:0 type:.J.B.Test> - BLOCK_BODY - CALL 'public open fun output (x: @[EnhancedNullability] T of .J): kotlin.Unit declared in .J.B' type=kotlin.Unit origin=null - $this: GET_VAR 'b: .J.B.Test> declared in .Test.test' type=.J.B.Test> origin=null - x: CALL 'public final fun (): T of .Test declared in .Test' type=T of .Test origin=GET_PROPERTY - $this: GET_VAR ': .Test.Test> declared in .Test.test' type=.Test.Test> origin=null + RETURN type=kotlin.Nothing from='public final fun (): T of .Inv declared in .Inv' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Inv visibility:private [final]' type=T of .Inv origin=null + receiver: GET_VAR ': .Inv.Inv> declared in .Inv.' type=.Inv.Inv> origin=null 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 declared in .J + public open fun equals (other: kotlin.Any?): kotlin.Boolean 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 .J + 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 .J + public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Test_1 modality:FINAL visibility:public superTypes:[.JavaClass1.Test_1>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test_1.Test_1> + TYPE_PARAMETER name:TT index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> (x:TT of .Test_1) returnType:.Test_1.Test_1> [primary] + VALUE_PARAMETER name:x index:0 type:TT of .Test_1 + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .JavaClass1' + : TT of .Test_1 + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test_1 modality:FINAL visibility:public superTypes:[.JavaClass1.Test_1>]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:TT of .Test_1 visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: TT of .Test_1 declared in .Test_1.' type=TT of .Test_1 origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test_1.Test_1>) returnType:TT of .Test_1 + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Test_1.Test_1> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): TT of .Test_1 declared in .Test_1' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:TT of .Test_1 visibility:private [final]' type=TT of .Test_1 origin=null + receiver: GET_VAR ': .Test_1.Test_1> declared in .Test_1.' type=.Test_1.Test_1> origin=null + FUN name:test visibility:public modality:FINAL <> ($this:.Test_1.Test_1>, b:.JavaClass1.B.Test_1>) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.Test_1.Test_1> + VALUE_PARAMETER name:b index:0 type:.JavaClass1.B.Test_1> + BLOCK_BODY + CALL 'public open fun output (x: @[EnhancedNullability] T of .JavaClass1): kotlin.Unit declared in .JavaClass1.B' type=kotlin.Unit origin=null + $this: GET_VAR 'b: .JavaClass1.B.Test_1> declared in .Test_1.test' type=.JavaClass1.B.Test_1> origin=null + x: CALL 'public final fun (): TT of .Test_1 declared in .Test_1' type=TT of .Test_1 origin=GET_PROPERTY + $this: GET_VAR ': .Test_1.Test_1> declared in .Test_1.test' type=.Test_1.Test_1> origin=null + 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 declared in .JavaClass1 + $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 .JavaClass1 + $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 .JavaClass1 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Test_2 modality:FINAL visibility:public superTypes:[.JavaClass2.Test_2, .Inv.Test_2>>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test_2.Test_2> + TYPE_PARAMETER name:TT index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> () returnType:.Test_2.Test_2> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .JavaClass2' + : TT of .Test_2 + : .Inv.Test_2> + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test_2 modality:FINAL visibility:public superTypes:[.JavaClass2.Test_2, .Inv.Test_2>>]' + FUN name:process visibility:public modality:FINAL <> ($this:.Test_2.Test_2>, b:.JavaClass2.B.Test_2, .Inv.Test_2>>) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.Test_2.Test_2> + VALUE_PARAMETER name:b index:0 type:.JavaClass2.B.Test_2, .Inv.Test_2>> + BLOCK_BODY + CALL 'public abstract fun output (output: @[EnhancedNullability] R of .JavaClass2): kotlin.Unit declared in .JavaClass2.B' type=kotlin.Unit origin=null + $this: GET_VAR 'b: .JavaClass2.B.Test_2, .Inv.Test_2>> declared in .Test_2.process' type=.JavaClass2.B.Test_2, .Inv.Test_2>> origin=null + output: CONSTRUCTOR_CALL 'public constructor (x: T of .Inv) declared in .Inv' type=.Inv.Test_2> origin=null + : TT of .Test_2 + x: CALL 'public abstract fun element (): @[EnhancedNullability] T of .JavaClass2 declared in .JavaClass2.B' type=@[EnhancedNullability] TT of .Test_2 origin=null + $this: GET_VAR 'b: .JavaClass2.B.Test_2, .Inv.Test_2>> declared in .Test_2.process' type=.JavaClass2.B.Test_2, .Inv.Test_2>> origin=null + 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 declared in .JavaClass2 + $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 .JavaClass2 + $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 .JavaClass2 + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test_3 visibility:public modality:FINAL (jb:.JavaClass1.B.test_3>, r:R of .test_3) returnType:kotlin.Unit + TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?] reified:false + VALUE_PARAMETER name:jb index:0 type:.JavaClass1.B.test_3> + VALUE_PARAMETER name:r index:1 type:R of .test_3 + BLOCK_BODY + CALL 'public open fun output (x: @[EnhancedNullability] T of .JavaClass1): kotlin.Unit declared in .JavaClass1.B' type=kotlin.Unit origin=null + $this: GET_VAR 'jb: .JavaClass1.B.test_3> declared in .test_3' type=.JavaClass1.B.test_3> origin=null + x: GET_VAR 'r: R of .test_3 declared in .test_3' type=R of .test_3 origin=null diff --git a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt index 4748f89c3c9..5f5980251dd 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt +++ b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt @@ -1,21 +1,47 @@ +// FIR_IDENTICAL // TARGET_BACKEND: JVM_IR +// ISSUE: KT-57022 -// MUTE_SIGNATURE_COMPARISON_K2: ANY -// ^ KT-57022 - -// FILE: J.java +// FILE: JavaClass1.java import org.jetbrains.annotations.Nullable; -public class J { +public class JavaClass1 { public class A { public void output(T x) {} } - public class B extends A {} + public class B extends A { + } +} + +// FILE: JavaClass2.java +import org.jetbrains.annotations.Nullable; + +public abstract class JavaClass2 { + + public abstract class A { + public abstract void output(R output); + } + + public abstract class B extends A { + public abstract T element(); + } } // FILE: test.kt -class Test(val x: T) : J() { +class Inv(val x: T) + +class Test_1(val x: TT) : JavaClass1() { fun test(b: B) { b.output(x) } } + +class Test_2 : JavaClass2>() { + fun process(b: B) { + b.output(Inv(b.element())) + } +} + +fun test_3(jb: JavaClass1.B, r: R) { + jb.output(r) +} diff --git a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt.txt b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt.txt index ffa97e0147f..689de653e47 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.kt.txt @@ -1,6 +1,6 @@ -class Test : J { +class Inv { constructor(x: T) /* primary */ { - super/*J*/() + super/*Any*/() /* () */ } @@ -9,8 +9,38 @@ class Test : J { field = x get - fun test(b: B) { +} + +class Test_1 : JavaClass1 { + constructor(x: TT) /* primary */ { + super/*JavaClass1*/() + /* () */ + + } + + val x: TT + field = x + get + + fun test(b: B) { b.output(x = .()) } } + +class Test_2 : JavaClass2> { + constructor() /* primary */ { + super/*JavaClass2*/>() + /* () */ + + } + + fun process(b: B>) { + b.output(output = Inv(x = b.element())) + } + +} + +fun test_3(jb: B, r: R) { + jb.output(x = r) +} diff --git a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.sig.kt.txt b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.sig.kt.txt index 726b31447a1..95cf0d25f6e 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.sig.kt.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureComputationComplexJavaGeneric.sig.kt.txt @@ -1,25 +1,65 @@ // CHECK: -// Mangled name: Test -// Public signature: /Test|null[0] -class Test : J { +// Mangled name: Inv +// Public signature: /Inv|null[0] +class Inv { // CHECK: - // Mangled name: Test{}x - // Public signature: /Test.x|-8060530855978347579[0] + // Mangled name: Inv{}x + // Public signature: /Inv.x|-8060530855978347579[0] val x: T // CHECK JVM_IR: - // Mangled name: Test#(){}1:0 - // Public signature: /Test.x.|-8893883356128097563[0] + // Mangled name: Inv#(){}1:0 + // Public signature: /Inv.x.|-8893883356128097563[0] get // CHECK: - // Mangled name: Test#(1:0){} - // Public signature: /Test.|-8731461708390519279[0] + // Mangled name: Inv#(1:0){} + // Public signature: /Inv.|-8731461708390519279[0] constructor(x: T) /* primary */ - // CHECK: - // Mangled name: Test#test(J.B<1:0>){} - // Public signature: /Test.test|7386642793853999047[0] - fun test(b: B): Unit - } +// CHECK: +// Mangled name: Test_1 +// Public signature: /Test_1|null[0] +class Test_1 : JavaClass1 { + // CHECK: + // Mangled name: Test_1{}x + // Public signature: /Test_1.x|-8060530855978347579[0] + val x: TT + // CHECK JVM_IR: + // Mangled name: Test_1#(){}1:0 + // Public signature: /Test_1.x.|-8893883356128097563[0] + get + + // CHECK: + // Mangled name: Test_1#(1:0){} + // Public signature: /Test_1.|-8731461708390519279[0] + constructor(x: TT) /* primary */ + + // CHECK: + // Mangled name: Test_1#test(JavaClass1.B<1:0>){} + // Public signature: /Test_1.test|-4347685660863074857[0] + fun test(b: B): Unit + +} + +// CHECK: +// Mangled name: Test_2 +// Public signature: /Test_2|null[0] +class Test_2 : JavaClass2> { + // CHECK: + // Mangled name: Test_2#(){} + // Public signature: /Test_2.|-5645683436151566731[0] + constructor() /* primary */ + + // CHECK: + // Mangled name: Test_2#process(JavaClass2.B<1:0,Inv<1:0>>){} + // Public signature: /Test_2.process|4196267472785317094[0] + fun process(b: B>): Unit + +} + +// CHECK: +// Mangled name: #test_3(JavaClass1.B<0:0>;0:0){0§} +// Public signature: /test_3|8017402258673595148[0] +fun test_3(jb: B, r: R): Unit diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.sig.kt.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.sig.kt.txt index 04ed4919407..f9283fd8f56 100644 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.sig.kt.txt +++ b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.sig.kt.txt @@ -78,7 +78,7 @@ class Derived1 : Base { // CHECK JVM_IR: // Mangled name: Derived1#(){}1:0 // Public signature: /Derived1.bar.|7899956589744407340[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: Derived1#(){} // Public signature: /Derived1.bar.|6880642144337645699[0] override get @@ -95,7 +95,7 @@ class Derived1 : Base { // CHECK JVM_IR: // Mangled name: Derived1#foo(0:0){0§}1:0 // Public signature: /Derived1.foo|8673945311830780726[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: Derived1#foo(0:0){0§} // Public signature: /Derived1.foo|-6838606926256314363[0] override fun foo(y: Y): T @@ -107,7 +107,7 @@ class Derived1 : Base { // CHECK JVM_IR: // Mangled name: Derived1#(){}1:0 // Public signature: /Derived1.x.|-8893883356128097563[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: Derived1#(){} // Public signature: /Derived1.x.|1482705010654679335[0] /* fake */ override get(): T @@ -119,7 +119,7 @@ class Derived1 : Base { // CHECK JVM_IR: // Mangled name: Derived1#@0:0(){0§}1:0 // Public signature: /Derived1.exn.|6217753676739394662[0] - // CHECK JS_IR: + // CHECK JS_IR NATIVE: // Mangled name: Derived1#@0:0(){0§} // Public signature: /Derived1.exn.|-202876889853335253[0] override get(): T