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 f2216ebac8a..54a039f8d7d 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1718,6 +1718,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); } + @TestMetadata("AllCandidates.kt") + public void testAllCandidates() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/AllCandidates.kt"); + } + public void testAllFilesPresentInFirProblems() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); } diff --git a/compiler/testData/ir/irText/firProblems/AllCandidates.kt b/compiler/testData/ir/irText/firProblems/AllCandidates.kt new file mode 100644 index 00000000000..2be5a3b8e18 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AllCandidates.kt @@ -0,0 +1,33 @@ +// FILE: OverloadResolutionResultsImpl.java + +import java.util.*; + +public class OverloadResolutionResultsImpl { + public Collection> getAllCandidates() { + return Collections.emptyList(); + } + + public void setAllCandidates(Collection> allCandidates) { + } + + public static OverloadResolutionResultsImpl nameNotFound() { + OverloadResolutionResultsImpl results = new OverloadResolutionResultsImpl<>(); + results.setAllCandidates(Collections.emptyList()); + return results; + } +} + +// FILE: AllCandidates.kt +// WITH_RUNTIME +// FULL_JDK + +class ResolvedCall + +class MyCandidate(val resolvedCall: ResolvedCall<*>) + +private fun allCandidatesResult(allCandidates: Collection) = + OverloadResolutionResultsImpl.nameNotFound().apply { + this.allCandidates = allCandidates.map { + it.resolvedCall as ResolvedCall + } + } diff --git a/compiler/testData/ir/irText/firProblems/AllCandidates.txt b/compiler/testData/ir/irText/firProblems/AllCandidates.txt new file mode 100644 index 00000000000..f035da1e9a9 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AllCandidates.txt @@ -0,0 +1,81 @@ +FILE fqName: fileName:/AllCandidates.kt + CLASS CLASS name:ResolvedCall modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ResolvedCall.ResolvedCall> + TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.ResolvedCall.ResolvedCall> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ResolvedCall modality:FINAL visibility:public superTypes:[kotlin.Any]' + 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:MyCandidate modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyCandidate + CONSTRUCTOR visibility:public <> (resolvedCall:.ResolvedCall<*>) returnType:.MyCandidate [primary] + VALUE_PARAMETER name:resolvedCall index:0 type:.ResolvedCall<*> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyCandidate modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:resolvedCall visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.ResolvedCall<*> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'resolvedCall: .ResolvedCall<*> declared in .MyCandidate.' type=.ResolvedCall<*> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyCandidate) returnType:.ResolvedCall<*> + correspondingProperty: PROPERTY name:resolvedCall visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.MyCandidate + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .ResolvedCall<*> declared in .MyCandidate' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.ResolvedCall<*> visibility:private [final]' type=.ResolvedCall<*> origin=null + receiver: GET_VAR ': .MyCandidate declared in .MyCandidate.' type=.MyCandidate 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 [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 + FUN name:allCandidatesResult visibility:private modality:FINAL (allCandidates:kotlin.collections.Collection<.MyCandidate>) returnType:@[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? + TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:allCandidates index:0 type:kotlin.collections.Collection<.MyCandidate> + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun allCandidatesResult (allCandidates: kotlin.collections.Collection<.MyCandidate>): @[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? declared in ' + CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=@[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null + : @[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? + $receiver: CALL 'public open fun nameNotFound (): @[FlexibleNullability] .OverloadResolutionResultsImpl.OverloadResolutionResultsImpl.nameNotFound?>? declared in .OverloadResolutionResultsImpl' type=@[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null + : A of .allCandidatesResult? + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<@[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>?, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:@[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>?) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:@[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? + BLOCK_BODY + CALL 'public open fun setAllCandidates (allCandidates: @[FlexibleNullability] kotlin.collections.Collection<@[FlexibleNullability] .ResolvedCall.OverloadResolutionResultsImpl?>?>?): kotlin.Unit declared in .OverloadResolutionResultsImpl' type=kotlin.Unit origin=EQ + <1>: A of .allCandidatesResult? + $this: TYPE_OP type=.OverloadResolutionResultsImpl.allCandidatesResult?> origin=IMPLICIT_NOTNULL typeOperand=.OverloadResolutionResultsImpl.allCandidatesResult?> + GET_VAR ': @[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? declared in .allCandidatesResult.' type=@[FlexibleNullability] .OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null + allCandidates: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.ResolvedCall.allCandidatesResult>> origin=null + : .MyCandidate + : .ResolvedCall.allCandidatesResult> + $receiver: GET_VAR 'allCandidates: kotlin.collections.Collection<.MyCandidate> declared in .allCandidatesResult' type=kotlin.collections.Collection<.MyCandidate> origin=null + transform: FUN_EXPR type=kotlin.Function1<.MyCandidate, .ResolvedCall.allCandidatesResult>> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.MyCandidate) returnType:.ResolvedCall.allCandidatesResult> + VALUE_PARAMETER name:it index:0 type:.MyCandidate + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .MyCandidate): .ResolvedCall.allCandidatesResult> declared in .allCandidatesResult.' + TYPE_OP type=.ResolvedCall.allCandidatesResult> origin=CAST typeOperand=.ResolvedCall.allCandidatesResult> + CALL 'public final fun (): .ResolvedCall<*> declared in .MyCandidate' type=.ResolvedCall<*> origin=GET_PROPERTY + $this: GET_VAR 'it: .MyCandidate declared in .allCandidatesResult..' type=.MyCandidate origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index a5446ab9794..6bdb57edfdb 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1717,6 +1717,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("AllCandidates.kt") + public void testAllCandidates() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/AllCandidates.kt"); + } + public void testAllFilesPresentInFirProblems() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); }