diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 5a0c49442a1..f83fff962e5 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -62,7 +62,9 @@ class Fir2IrTypeConverter( // TODO: yet we take more general type. Not quite sure it's Ok upperBound.toIrType(typeContext) } - is ConeCapturedType -> TODO() + is ConeCapturedType -> { + lowerType?.toIrType(typeContext) ?: constructor.supertypes!!.first().toIrType(typeContext) + } is ConeDefinitelyNotNullType -> { original.toIrType(typeContext.definitelyNotNull()) } 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 389d8fb73d7..663ccad3f00 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1872,6 +1872,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt"); } + @TestMetadata("genericFunWithStar.kt") + public void testGenericFunWithStar() throws Exception { + runTest("compiler/testData/ir/irText/types/genericFunWithStar.kt"); + } + @TestMetadata("genericPropertyReferenceType.kt") public void testGenericPropertyReferenceType() throws Exception { runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt"); diff --git a/compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt b/compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt index bcc049fc766..f14ecd2a694 100644 --- a/compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt +++ b/compiler/testData/codegen/box/regressions/dontCaptureTypesWithTypeVariables.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun test(i: Inv) { foo(i.superclass()) } diff --git a/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt b/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt new file mode 100644 index 00000000000..109a47d9ca8 --- /dev/null +++ b/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt @@ -0,0 +1,97 @@ +FILE fqName: fileName:/genericFunWithStar.kt + CLASS INTERFACE name:IBase modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBase + 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 + CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[.IBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo + 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 + CLASS INTERFACE name:IBar modality:ABSTRACT visibility:public superTypes:[.IBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBar + 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 + CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.I.I> + TYPE_PARAMETER name:G index:0 variance: superTypes:[.IFoo; .IBar] + 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 + CLASS CLASS name:Box modality:ABSTRACT visibility:public superTypes:[.IFoo; .IBar] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Box.Box> + TYPE_PARAMETER name:T index:0 variance: superTypes:[.IFoo; .IBar] + CONSTRUCTOR visibility:public <> () returnType:.Box.Box> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Box modality:ABSTRACT visibility:public superTypes:[.IFoo; .IBar]' + FUN name:foo visibility:public modality:ABSTRACT ($this:.Box.Box>, tSerializer:.I.Box.foo>) returnType:.I<.Box.Box.foo>> + TYPE_PARAMETER name:F index:0 variance: superTypes:[.IFoo; .IBar] + $this: VALUE_PARAMETER name: type:.Box.Box> + VALUE_PARAMETER name:tSerializer index:0 type:.I.Box.foo> + FUN name:bar visibility:public modality:FINAL <> ($this:.Box.Box>, serializers:kotlin.Array.I<*>>) returnType:.I<*> + $this: VALUE_PARAMETER name: type:.Box.Box> + VALUE_PARAMETER name:serializers index:0 type:kotlin.Array.I<*>> varargElementType:.I<*> [vararg] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun bar (vararg serializers: .I<*>): .I<*> declared in .Box' + CALL 'public abstract fun foo (tSerializer: .I.Box.foo>): .I<.Box.Box.foo>> declared in .Box' type=.I.Box.IFoo>> origin=null + : .IFoo + $this: GET_VAR ': .Box.Box> declared in .Box.bar' type=.Box.Box> origin=null + tSerializer: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=.I<*> origin=null + $this: GET_VAR 'serializers: kotlin.Array.I<*>> [vararg] declared in .Box.bar' type=kotlin.Array.I<*>> origin=null + index: CONST Int type=kotlin.Int value=0 + 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/types/genericFunWithStar.kt b/compiler/testData/ir/irText/types/genericFunWithStar.kt new file mode 100644 index 00000000000..173071599a2 --- /dev/null +++ b/compiler/testData/ir/irText/types/genericFunWithStar.kt @@ -0,0 +1,15 @@ +interface IBase +interface IFoo : IBase +interface IBar : IBase + +interface I where G : IFoo, G : IBar {} + +abstract class Box : IFoo, IBar where T : IFoo, T : IBar { + + abstract fun foo(tSerializer: I): I> where F : IFoo, F : IBar + + fun bar(vararg serializers: I<*>): I<*> { + return foo(serializers[0]) + } +} + diff --git a/compiler/testData/ir/irText/types/genericFunWithStar.txt b/compiler/testData/ir/irText/types/genericFunWithStar.txt new file mode 100644 index 00000000000..7e8f692dfed --- /dev/null +++ b/compiler/testData/ir/irText/types/genericFunWithStar.txt @@ -0,0 +1,100 @@ +FILE fqName: fileName:/genericFunWithStar.kt + CLASS INTERFACE name:IBase modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBase + 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 + CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[.IBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo + 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 [fake_override,operator] declared in .IBase + $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 [fake_override] declared in .IBase + $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 [fake_override] declared in .IBase + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IBar modality:ABSTRACT visibility:public superTypes:[.IBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBar + 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 [fake_override,operator] declared in .IBase + $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 [fake_override] declared in .IBase + $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 [fake_override] declared in .IBase + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.I.I> + TYPE_PARAMETER name:G index:0 variance: superTypes:[.IFoo; .IBar] + 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 + CLASS CLASS name:Box modality:ABSTRACT visibility:public superTypes:[.IFoo; .IBar] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Box.Box> + TYPE_PARAMETER name:T index:0 variance: superTypes:[.IFoo; .IBar] + CONSTRUCTOR visibility:public <> () returnType:.Box.Box> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Box modality:ABSTRACT visibility:public superTypes:[.IFoo; .IBar]' + FUN name:foo visibility:public modality:ABSTRACT ($this:.Box.Box>, tSerializer:.I.Box.foo>) returnType:.I<.Box.Box.foo>> + TYPE_PARAMETER name:F index:0 variance: superTypes:[.IFoo; .IBar] + $this: VALUE_PARAMETER name: type:.Box.Box> + VALUE_PARAMETER name:tSerializer index:0 type:.I.Box.foo> + FUN name:bar visibility:public modality:FINAL <> ($this:.Box.Box>, serializers:kotlin.Array.I<*>>) returnType:.I<*> + $this: VALUE_PARAMETER name: type:.Box.Box> + VALUE_PARAMETER name:serializers index:0 type:kotlin.Array.I<*>> varargElementType:.I<*> [vararg] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun bar (vararg serializers: .I<*>): .I<*> declared in .Box' + CALL 'public abstract fun foo (tSerializer: .I.Box.foo>): .I<.Box.Box.foo>> declared in .Box' type=.I.Box<*>> origin=null + : .IBase + $this: GET_VAR ': .Box.Box> declared in .Box.bar' type=.Box.Box> origin=null + tSerializer: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=.I<*> origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'serializers: kotlin.Array.I<*>> [vararg] declared in .Box.bar' type=kotlin.Array.I<*>> origin=null + index: CONST Int type=kotlin.Int value=0 + 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 [fake_override,operator] declared in .IFoo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBar + $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 [fake_override] declared in .IFoo + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBar + $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 [fake_override] declared in .IFoo + public open fun toString (): kotlin.String [fake_override] declared in .IBar + $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 00b98f55481..ac2c3c568af 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1871,6 +1871,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt"); } + @TestMetadata("genericFunWithStar.kt") + public void testGenericFunWithStar() throws Exception { + runTest("compiler/testData/ir/irText/types/genericFunWithStar.kt"); + } + @TestMetadata("genericPropertyReferenceType.kt") public void testGenericPropertyReferenceType() throws Exception { runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt");