From d8faa9686d7bbd9ada4cf0621dcc8b13606868a7 Mon Sep 17 00:00:00 2001 From: Anastasiya Shadrina Date: Mon, 6 Sep 2021 18:43:33 +0700 Subject: [PATCH] [Tests] Test samples from KEEP --- ...CompilerTestFE10TestdataTestGenerated.java | 72 +++++++++++++++++-- ...irOldFrontendDiagnosticsTestGenerated.java | 72 +++++++++++++++++-- ...DiagnosticsWithLightTreeTestGenerated.java | 72 +++++++++++++++++-- .../FirBlackBoxCodegenTestGenerated.java | 46 ++++++++++-- .../calls/tower/ResolvedAtomCompleter.kt | 16 ++++- .../resolve/calls/model/ResolutionAtoms.kt | 1 + .../contextReceivers/fromKEEP/canvas.kt | 22 ++++++ .../contextReceivers/fromKEEP/compareTo.kt | 19 +++++ .../fromKEEP/decimateEveryEvenThird.kt | 17 +++++ .../contextReceivers/{ => fromKEEP}/dp.kt | 0 .../contextReceivers/fromKEEP/monoidSum.kt | 31 ++++++++ .../fromKEEP/autoCloseScope.kt | 33 +++++++++ .../fromKEEP/autoCloseScope.txt | 35 +++++++++ .../contextReceivers/fromKEEP/canvas.kt | 17 +++++ .../contextReceivers/fromKEEP/canvas.txt | 31 ++++++++ .../fromKEEP/compareTo.fir.kt | 16 +++++ .../contextReceivers/fromKEEP/compareTo.kt | 16 +++++ .../contextReceivers/fromKEEP/compareTo.txt | 17 +++++ .../fromKEEP/decimateEveryEvenThird.fir.kt | 11 +++ .../fromKEEP/decimateEveryEvenThird.kt | 11 +++ .../fromKEEP/decimateEveryEvenThird.txt | 3 + .../contextReceivers/{ => fromKEEP}/dp.fir.kt | 0 .../contextReceivers/{ => fromKEEP}/dp.kt | 0 .../contextReceivers/{ => fromKEEP}/dp.txt | 0 .../fromKEEP/iterableClass.fir.kt | 16 +++++ .../fromKEEP/iterableClass.kt | 16 +++++ .../fromKEEP/iterableClass.txt | 6 ++ .../contextReceivers/fromKEEP/json.fir.kt | 24 +++++++ .../contextReceivers/fromKEEP/json.kt | 24 +++++++ .../contextReceivers/fromKEEP/json.txt | 15 ++++ .../fromKEEP/loggingContext.fir.kt | 12 ++++ .../fromKEEP/loggingContext.kt | 12 ++++ .../fromKEEP/loggingContext.txt | 23 ++++++ .../fromKEEP/monoidSum.fir.kt | 32 +++++++++ .../contextReceivers/fromKEEP/monoidSum.kt | 32 +++++++++ .../contextReceivers/fromKEEP/monoidSum.txt | 39 ++++++++++ .../fromKEEP/transaction.fir.kt | 14 ++++ .../contextReceivers/fromKEEP/transaction.kt | 14 ++++ .../contextReceivers/fromKEEP/transaction.txt | 20 ++++++ .../fromKEEP/userStorage.fir.kt | 15 ++++ .../contextReceivers/fromKEEP/userStorage.kt | 15 ++++ .../contextReceivers/fromKEEP/userStorage.txt | 33 +++++++++ .../test/runners/DiagnosticTestGenerated.java | 72 +++++++++++++++++-- .../codegen/BlackBoxCodegenTestGenerated.java | 10 +++ .../IrBlackBoxCodegenTestGenerated.java | 46 ++++++++++-- .../LightAnalysisModeTestGenerated.java | 13 ++++ .../VisualizerBlackBoxTestGenerated.java | 13 ++++ .../js/test/JsCodegenBoxTestGenerated.java | 28 ++++---- .../test/ir/IrJsCodegenBoxTestGenerated.java | 13 ++++ .../IrCodegenBoxWasmTestGenerated.java | 13 ++++ 50 files changed, 1077 insertions(+), 51 deletions(-) create mode 100644 compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt create mode 100644 compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt create mode 100644 compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt rename compiler/testData/codegen/box/extensionFunctions/contextReceivers/{ => fromKEEP}/dp.kt (100%) create mode 100644 compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.txt rename compiler/testData/diagnostics/tests/extensions/contextReceivers/{ => fromKEEP}/dp.fir.kt (100%) rename compiler/testData/diagnostics/tests/extensions/contextReceivers/{ => fromKEEP}/dp.kt (100%) rename compiler/testData/diagnostics/tests/extensions/contextReceivers/{ => fromKEEP}/dp.txt (100%) create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.txt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt create mode 100644 compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 36e4b1b246b..4469cc9f015 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -10582,12 +10582,6 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt"); } - @Test - @TestMetadata("dp.kt") - public void testDp() throws Exception { - runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.kt"); - } - @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { @@ -10735,17 +10729,83 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("autoCloseScope.kt") + public void testAutoCloseScope() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt"); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt"); + } + @Test @TestMetadata("clickHandler.kt") public void testClickHandler() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt"); } + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("decimateEveryEvenThird.kt") + public void testDecimateEveryEvenThird() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt"); + } + @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt"); } + + @Test + @TestMetadata("iterableClass.kt") + public void testIterableClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt"); + } + + @Test + @TestMetadata("json.kt") + public void testJson() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt"); + } + + @Test + @TestMetadata("loggingContext.kt") + public void testLoggingContext() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt"); + } + + @Test + @TestMetadata("transaction.kt") + public void testTransaction() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt"); + } + + @Test + @TestMetadata("userStorage.kt") + public void testUserStorage() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt"); + } } } } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 5bf699ff33e..eb18b3526a1 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -10582,12 +10582,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt"); } - @Test - @TestMetadata("dp.kt") - public void testDp() throws Exception { - runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.kt"); - } - @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { @@ -10735,17 +10729,83 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("autoCloseScope.kt") + public void testAutoCloseScope() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt"); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt"); + } + @Test @TestMetadata("clickHandler.kt") public void testClickHandler() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt"); } + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("decimateEveryEvenThird.kt") + public void testDecimateEveryEvenThird() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt"); + } + @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt"); } + + @Test + @TestMetadata("iterableClass.kt") + public void testIterableClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt"); + } + + @Test + @TestMetadata("json.kt") + public void testJson() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt"); + } + + @Test + @TestMetadata("loggingContext.kt") + public void testLoggingContext() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt"); + } + + @Test + @TestMetadata("transaction.kt") + public void testTransaction() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt"); + } + + @Test + @TestMetadata("userStorage.kt") + public void testUserStorage() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt"); + } } } } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index a75f13b7ac0..c1d60e817dd 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -10582,12 +10582,6 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt"); } - @Test - @TestMetadata("dp.kt") - public void testDp() throws Exception { - runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.kt"); - } - @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { @@ -10735,17 +10729,83 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("autoCloseScope.kt") + public void testAutoCloseScope() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt"); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt"); + } + @Test @TestMetadata("clickHandler.kt") public void testClickHandler() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt"); } + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("decimateEveryEvenThird.kt") + public void testDecimateEveryEvenThird() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt"); + } + @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt"); } + + @Test + @TestMetadata("iterableClass.kt") + public void testIterableClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt"); + } + + @Test + @TestMetadata("json.kt") + public void testJson() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt"); + } + + @Test + @TestMetadata("loggingContext.kt") + public void testLoggingContext() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt"); + } + + @Test + @TestMetadata("transaction.kt") + public void testTransaction() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt"); + } + + @Test + @TestMetadata("userStorage.kt") + public void testUserStorage() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt"); + } } } } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 1dfa6d6d6da..b625561d6dd 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -16163,12 +16163,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/contextAndExtensionSameName.kt"); } - @Test - @TestMetadata("dp.kt") - public void testDp() throws Exception { - runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/dp.kt"); - } - @Test @TestMetadata("inferGenericPropertyType.kt") public void testInferGenericPropertyType() throws Exception { @@ -16210,6 +16204,46 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testThis() throws Exception { runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/this.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + public class FromKEEP { + @Test + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt"); + } + + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("decimateEveryEvenThird.kt") + public void testDecimateEveryEvenThird() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt"); + } + } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt index 625a8d866d5..1428ce73b39 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt @@ -273,6 +273,7 @@ class ResolvedAtomCompleter( val returnType = (if (resolvedAtom?.isCoercedToUnit == true) builtIns.unitType else resolvedAtom?.returnType) ?: descriptor.returnType val extensionReceiverType = resolvedAtom?.receiver ?: descriptor.extensionReceiverParameter?.type + val contextReceiversTypes = resolvedAtom?.contextReceivers ?: descriptor.contextReceiverParameters.map { it.type } val dispatchReceiverType = descriptor.dispatchReceiverParameter?.type val valueParameterTypes = resolvedAtom?.parameters ?: descriptor.valueParameters.map { it.type } @@ -289,6 +290,14 @@ class ResolvedAtomCompleter( } } + val substitutedContextReceiversTypes = descriptor.contextReceiverParameters.mapIndexedNotNull { i, contextReceiver -> + contextReceiversTypes.getOrNull(i)?.substituteAndApproximate(substitutor)?.also { + if (contextReceiver is ReceiverParameterDescriptorImpl && contextReceiver.type.shouldBeUpdated()) { + contextReceiver.setOutType(it.approximatedType) + } + } + } + val dispatchReceiverFromDescriptor = descriptor.dispatchReceiverParameter dispatchReceiverType?.substituteAndApproximate(substitutor)?.also { if (dispatchReceiverFromDescriptor is ReceiverParameterDescriptorImpl && dispatchReceiverFromDescriptor.type.shouldBeUpdated()) { @@ -304,7 +313,7 @@ class ResolvedAtomCompleter( } } - return FunctionLiteralTypes(substitutedReturnType, substitutedValueParameterTypes, substitutedReceiverType) + return FunctionLiteralTypes(substitutedReturnType, substitutedValueParameterTypes, substitutedReceiverType, substitutedContextReceiversTypes) } private fun completeLambda(resolvedAtom: ResolvedLambdaAtom) { @@ -334,7 +343,7 @@ class ResolvedAtomCompleter( builtIns, existingLambdaType.annotations, substitutedLambdaTypes.receiverType?.substitutedType, - emptyList(), + substitutedLambdaTypes.contextReceiverTypes.map { it.substitutedType }, substitutedLambdaTypes.parameterTypes.map { it.substitutedType }, null, // parameter names transforms to special annotations, so they are already taken from parameter types substitutedLambdaTypes.returnType.substitutedType, @@ -641,7 +650,8 @@ class ResolvedAtomCompleter( class FunctionLiteralTypes( val returnType: ProcessedType, val parameterTypes: List, - val receiverType: ProcessedType? + val receiverType: ProcessedType?, + val contextReceiverTypes: List ) { class ProcessedType(val substitutedType: KotlinType, val approximatedType: KotlinType) } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/ResolutionAtoms.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/ResolutionAtoms.kt index 98c422093b8..35cd989794d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/ResolutionAtoms.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/ResolutionAtoms.kt @@ -150,6 +150,7 @@ class ResolvedLambdaAtom( override val atom: LambdaKotlinCallArgument, val isSuspend: Boolean, val receiver: UnwrappedType?, + val contextReceivers: List, val parameters: List, val returnType: UnwrappedType, val typeVariableForLambdaReturnType: TypeVariableForLambdaReturnType?, diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt new file mode 100644 index 00000000000..00d408eb3b2 --- /dev/null +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt @@ -0,0 +1,22 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR + +interface Canvas { + val suffix: String +} + +interface Shape { + context(Canvas) + fun draw(): String +} + +class Circle : Shape { + context(Canvas) + override fun draw() = "OK" + suffix +} + +object MyCanvas : Canvas { + override val suffix = "" +} + +fun box() = with(MyCanvas) { Circle().draw() } \ No newline at end of file diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt new file mode 100644 index 00000000000..53e29e1512b --- /dev/null +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR + +data class Pair(val first: A, val second: B) + +context(Comparator) +infix operator fun T.compareTo(other: T) = compare(this, other) + +context(Comparator) +val Pair.min get() = if (first < second) first else second + +fun box(): String { + val comparator = Comparator { a, b -> + if (a == null || b == null) 0 else a.length.compareTo(b.length) + } + return with(comparator) { + Pair("OK", "fail").min + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt new file mode 100644 index 00000000000..bd429e53956 --- /dev/null +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt @@ -0,0 +1,17 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// WITH_RUNTIME + +fun List.decimateEveryEvenThird() = sequence { + var counter = 1 + for (e in this@List) { + if (e % 2 == 0 && counter % 3 == 0) { + yield(e) + } + counter += 1 + } +} + +fun box() = with(listOf(0, 1, 2).decimateEveryEvenThird()) { + if (toList() == listOf(2)) "OK" else "fail" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/dp.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt similarity index 100% rename from compiler/testData/codegen/box/extensionFunctions/contextReceivers/dp.kt rename to compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt new file mode 100644 index 00000000000..798370f9232 --- /dev/null +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt @@ -0,0 +1,31 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// WITH_RUNTIME + +interface Semigroup { + infix fun T.combine(other: T): T +} + +interface Monoid : Semigroup { + val unit: T +} +object IntMonoid : Monoid { + override fun Int.combine(other: Int): Int = this + other + override val unit: Int = 0 +} +object StringMonoid : Monoid { + override fun String.combine(other: String): String = this + other + override val unit: String = "" +} + +context(Monoid) +fun List.sum(): T = fold(unit) { acc, e -> acc.combine(e) } + +fun box(): String { + with(IntMonoid) { + listOf(1, 2, 3).sum() + } + return with(StringMonoid) { + listOf("O", "K").sum() + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt new file mode 100644 index 00000000000..4ba8a2086b1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt @@ -0,0 +1,33 @@ +// FIR_IDENTICAL +class File(name: String) +interface InputStream + +interface AutoCloseScope { + fun defer(closeBlock: () -> Unit) + fun close() +} +class AutoCloseScopeImpl : AutoCloseScope { + override fun defer(closeBlock: () -> Unit) = TODO() + override fun close() = TODO() +} + +context(AutoCloseScope) +fun File.open(): InputStream = TODO() + +fun withAutoClose(block: context(AutoCloseScope) () -> Unit) { + val scope = AutoCloseScopeImpl() // Not shown here + try { + with(scope) { block() } + } finally { + scope.close() + } +} + +fun test() { + withAutoClose { + val input = File("input.txt").open() + val config = File("config.txt").open() + // Work + // All files are closed at the end + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.txt new file mode 100644 index 00000000000..1b08c399033 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.txt @@ -0,0 +1,35 @@ +package + +public fun test(): kotlin.Unit +public fun withAutoClose(/*0*/ block: @kotlin.ContextFunctionTypeParams(count = 1) () -> kotlin.Unit): kotlin.Unit +public fun File.open(): InputStream + +public interface AutoCloseScope { + public abstract fun close(): kotlin.Unit + public abstract fun defer(/*0*/ closeBlock: () -> kotlin.Unit): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class AutoCloseScopeImpl : AutoCloseScope { + public constructor AutoCloseScopeImpl() + public open override /*1*/ fun close(): kotlin.Nothing + public open override /*1*/ fun defer(/*0*/ closeBlock: () -> kotlin.Unit): kotlin.Nothing + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class File { + public constructor File(/*0*/ name: kotlin.String) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface InputStream { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt new file mode 100644 index 00000000000..944e34f365a --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt @@ -0,0 +1,17 @@ +// FIR_IDENTICAL + +interface Canvas + +interface Shape { + context(Canvas) + fun draw(): Unit +} + +class Circle : Shape { + context(Canvas) + override fun draw() {} +} + +object MyCanvas : Canvas + +fun test() = with(MyCanvas) { Circle().draw() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.txt new file mode 100644 index 00000000000..11b4d2dab9b --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.txt @@ -0,0 +1,31 @@ +package + +public fun test(): kotlin.Unit + +public interface Canvas { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Circle : Shape { + public constructor Circle() + public open override /*1*/ fun draw(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object MyCanvas : Canvas { + private constructor MyCanvas() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Shape { + public abstract fun draw(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt new file mode 100644 index 00000000000..c1bce127135 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt @@ -0,0 +1,16 @@ +data class Pair(val first: A, val second: B) + +context(Comparator) +infix operator fun T.compareTo(other: T) = compare(this, other) + +context(Comparator) +val Pair.max get() = if (first > second) first else second + +fun test() { + val comparator = Comparator { a, b -> + if (a == null || b == null) 0 else a.length.compareTo(b.length) + } + with(comparator) { + Pair("OK", "fail").max + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt new file mode 100644 index 00000000000..e60ba05131c --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt @@ -0,0 +1,16 @@ +data class Pair(val first: A, val second: B) + +context(Comparator) +infix operator fun T.compareTo(other: T) = compare(this, other) + +context(Comparator) +val Pair.max get() = if (first > second) first else second + +fun test() { + val comparator = Comparator { a, b -> + if (a == null || b == null) 0 else a.length.compareTo(b.length) + } + with(comparator) { + Pair("OK", "fail").max + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.txt new file mode 100644 index 00000000000..98ae4788e73 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.txt @@ -0,0 +1,17 @@ +package + +public val Pair.max: T +public fun test(): kotlin.Unit +public infix operator fun T.compareTo(/*0*/ other: T): kotlin.Int + +public final data class Pair { + public constructor Pair(/*0*/ first: A, /*1*/ second: B) + public final val first: A + public final val second: B + public final operator /*synthesized*/ fun component1(): A + public final operator /*synthesized*/ fun component2(): B + public final /*synthesized*/ fun copy(/*0*/ first: A = ..., /*1*/ second: B = ...): Pair + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.fir.kt new file mode 100644 index 00000000000..af2a1e3cc74 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.fir.kt @@ -0,0 +1,11 @@ +// WITH_RUNTIME + +fun List.decimateEveryEvenThird() = sequence { + var counter = 1 + for (e in this@List) { + if (e % 2 == 0 && counter % 3 == 0) { + yield(e) + } + counter += 1 + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt new file mode 100644 index 00000000000..a21ed5116f9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt @@ -0,0 +1,11 @@ +// WITH_RUNTIME + +fun List.decimateEveryEvenThird() = sequence { + var counter = 1 + for (e in this@List) { + if (e % 2 == 0 && counter % 3 == 0) { + yield(e) + } + counter += 1 + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.txt new file mode 100644 index 00000000000..d9d2e504570 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.txt @@ -0,0 +1,3 @@ +package + +public fun kotlin.collections.List.decimateEveryEvenThird(): kotlin.sequences.Sequence diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.fir.kt similarity index 100% rename from compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.fir.kt rename to compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.fir.kt diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt similarity index 100% rename from compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.kt rename to compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.txt similarity index 100% rename from compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.txt rename to compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.txt diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt new file mode 100644 index 00000000000..9e382ffc1b5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt @@ -0,0 +1,16 @@ +typealias IterableClass = (C) -> Iterator + +context(IterableClass) +fun C.iterator(any: Any?): Iterator = this@IterableClass.invoke(this) + +fun listOf(vararg items: T): List = null!! + +fun test() { + val f: IterableClass, Int> = { + it.listIterator() + } + with(f) { + listOf(1, 2, 3).iterator(null) + } + listOf(1, 2, 3).iterator(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt new file mode 100644 index 00000000000..00eac4482e1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt @@ -0,0 +1,16 @@ +typealias IterableClass = (C) -> Iterator + +context(IterableClass) +fun C.iterator(any: Any?): Iterator = this@IterableClass.invoke(this) + +fun listOf(vararg items: T): List = null!! + +fun test() { + val f: IterableClass, Int> = { + it.listIterator() + } + with(f) { + listOf(1, 2, 3).iterator(null) + } + listOf(1, 2, 3).iterator(null) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.txt new file mode 100644 index 00000000000..e920c355098 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.txt @@ -0,0 +1,6 @@ +package + +public fun listOf(/*0*/ vararg items: T /*kotlin.Array*/): kotlin.collections.List +public fun test(): kotlin.Unit +public fun C.iterator(/*0*/ any: kotlin.Any?): kotlin.collections.Iterator +public typealias IterableClass = (C) -> kotlin.collections.Iterator diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt new file mode 100644 index 00000000000..eae8208bec0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt @@ -0,0 +1,24 @@ +class JSONObject { + fun build(): JSONObject = TODO() + + fun put(key: String, any: Any): Unit = TODO() +} + +fun json(build: JSONObject.() -> Unit) = JSONObject().apply { build() } + +context(JSONObject) +infix fun String.by(build: JSONObject.() -> Unit) = put(this, JSONObject().build()) + +context(JSONObject) +infix fun String.by(value: Any) = put(this, value) + +fun test() { + val json = json { + "name" by "Kotlin" + "age" by 10 + "creator" by { + "name" by "JetBrains" + "age" by "21" + } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt new file mode 100644 index 00000000000..1b46c61b9e8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt @@ -0,0 +1,24 @@ +class JSONObject { + fun build(): JSONObject = TODO() + + fun put(key: String, any: Any): Unit = TODO() +} + +fun json(build: JSONObject.() -> Unit) = JSONObject().apply { build() } + +context(JSONObject) +infix fun String.by(build: JSONObject.() -> Unit) = put(this, JSONObject().build()) + +context(JSONObject) +infix fun String.by(value: Any) = put(this, value) + +fun test() { + val json = json { + "name" by "Kotlin" + "age" by 10 + "creator" by { + "name" by "JetBrains" + "age" by "21" + } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.txt new file mode 100644 index 00000000000..f625fa28a58 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.txt @@ -0,0 +1,15 @@ +package + +public fun json(/*0*/ build: JSONObject.() -> kotlin.Unit): JSONObject +public fun test(): kotlin.Unit +public infix fun kotlin.String.by(/*0*/ build: JSONObject.() -> kotlin.Unit): kotlin.Unit +public infix fun kotlin.String.by(/*0*/ value: kotlin.Any): kotlin.Unit + +public final class JSONObject { + public constructor JSONObject() + public final fun build(): JSONObject + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun put(/*0*/ key: kotlin.String, /*1*/ any: kotlin.Any): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt new file mode 100644 index 00000000000..9e50f65d4d6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt @@ -0,0 +1,12 @@ +interface Params +interface Logger { + fun info(message: String) +} +interface LoggingContext { + val log: Logger // this context provides reference to logger +} + +context(LoggingContext) +fun performSomeBusinessOperation(withParams: Params) { + log.info("Operation has started") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt new file mode 100644 index 00000000000..5c161e3111c --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt @@ -0,0 +1,12 @@ +interface Params +interface Logger { + fun info(message: String) +} +interface LoggingContext { + val log: Logger // this context provides reference to logger +} + +context(LoggingContext) +fun performSomeBusinessOperation(withParams: Params) { + log.info("Operation has started") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.txt new file mode 100644 index 00000000000..6515c6caf7c --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.txt @@ -0,0 +1,23 @@ +package + +public fun performSomeBusinessOperation(/*0*/ withParams: Params): kotlin.Unit + +public interface Logger { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun info(/*0*/ message: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface LoggingContext { + public abstract val log: Logger + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Params { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.fir.kt new file mode 100644 index 00000000000..d5e8bbb9366 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.fir.kt @@ -0,0 +1,32 @@ +interface Semigroup { + infix fun T.combine(other: T): T +} + +interface Monoid : Semigroup { + val unit: T +} +object IntMonoid : Monoid { + override fun Int.combine(other: Int): Int = this + other + override val unit: Int = 0 +} +object StringMonoid : Monoid { + override fun String.combine(other: String): String = this + other + override val unit: String = "" +} + +public inline fun Iterable.fold(initial: R, operation: (acc: R, T) -> R): R = TODO() + +context(Monoid) +fun List.sum(): T = fold(unit) { acc, e -> acc.combine(e) } + +fun listOf(vararg items: T): List = null!! + +fun test() { + with(IntMonoid) { + listOf(1, 2, 3).sum() + } + with(StringMonoid) { + listOf(1, 2, 3).sum() + listOf("1", "2", "3").sum() + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt new file mode 100644 index 00000000000..425761e35e5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt @@ -0,0 +1,32 @@ +interface Semigroup { + infix fun T.combine(other: T): T +} + +interface Monoid : Semigroup { + val unit: T +} +object IntMonoid : Monoid { + override fun Int.combine(other: Int): Int = this + other + override val unit: Int = 0 +} +object StringMonoid : Monoid { + override fun String.combine(other: String): String = this + other + override val unit: String = "" +} + +public inline fun Iterable.fold(initial: R, operation: (acc: R, T) -> R): R = TODO() + +context(Monoid) +fun List.sum(): T = fold(unit) { acc, e -> acc.combine(e) } + +fun listOf(vararg items: T): List = null!! + +fun test() { + with(IntMonoid) { + listOf(1, 2, 3).sum() + } + with(StringMonoid) { + listOf(1, 2, 3).sum() + listOf("1", "2", "3").sum() + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.txt new file mode 100644 index 00000000000..83a8094fbb5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.txt @@ -0,0 +1,39 @@ +package + +public fun listOf(/*0*/ vararg items: T /*kotlin.Array*/): kotlin.collections.List +public fun test(): kotlin.Unit +public inline fun kotlin.collections.Iterable.fold(/*0*/ initial: R, /*1*/ operation: (acc: R, T) -> R): R +public fun kotlin.collections.List.sum(): T + +public object IntMonoid : Monoid { + private constructor IntMonoid() + public open override /*1*/ val unit: kotlin.Int = 0 + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public open override /*1*/ fun kotlin.Int.combine(/*0*/ other: kotlin.Int): kotlin.Int +} + +public interface Monoid : Semigroup { + public abstract val unit: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public abstract override /*1*/ /*fake_override*/ fun T.combine(/*0*/ other: T): T +} + +public interface Semigroup { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public abstract infix fun T.combine(/*0*/ other: T): T +} + +public object StringMonoid : Monoid { + private constructor StringMonoid() + public open override /*1*/ val unit: kotlin.String = "" + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public open override /*1*/ fun kotlin.String.combine(/*0*/ other: kotlin.String): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt new file mode 100644 index 00000000000..d08f5c3a1b3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt @@ -0,0 +1,14 @@ +class Session(var lastAccess: Any?) +interface Transaction { + fun loadSession(): Session + fun storeSession(session: Session) +} + +fun now(): Any? = null + +context(Transaction) +fun updateUserSession() { + val session = loadSession() + session.lastAccess = now() + storeSession(session) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt new file mode 100644 index 00000000000..7e80f045bb8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt @@ -0,0 +1,14 @@ +class Session(var lastAccess: Any?) +interface Transaction { + fun loadSession(): Session + fun storeSession(session: Session) +} + +fun now(): Any? = null + +context(Transaction) +fun updateUserSession() { + val session = loadSession() + session.lastAccess = now() + storeSession(session) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.txt new file mode 100644 index 00000000000..85b313cacec --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.txt @@ -0,0 +1,20 @@ +package + +public fun now(): kotlin.Any? +public fun updateUserSession(): kotlin.Unit + +public final class Session { + public constructor Session(/*0*/ lastAccess: kotlin.Any?) + public final var lastAccess: kotlin.Any? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Transaction { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun loadSession(): Session + public abstract fun storeSession(/*0*/ session: Session): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt new file mode 100644 index 00000000000..e8338dad487 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt @@ -0,0 +1,15 @@ +class Storage { + inner class Info + + fun info(name: String) = Info() +} +class User +class Logger { + fun info(message: String) {} +} + +context(Logger, Storage) +fun userInfo(name: String): Storage.Info? { + this@Logger.info("Retrieving info about $name") + return this@Storage.info(name) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt new file mode 100644 index 00000000000..d1d5ec9e4fe --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt @@ -0,0 +1,15 @@ +class Storage { + inner class Info + + fun info(name: String) = Info() +} +class User +class Logger { + fun info(message: String) {} +} + +context(Logger, Storage) +fun userInfo(name: String): Storage.Info? { + this@Logger.info("Retrieving info about $name") + return this@Storage.info(name) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.txt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.txt new file mode 100644 index 00000000000..bcec22293f4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.txt @@ -0,0 +1,33 @@ +package + +public fun userInfo(/*0*/ name: kotlin.String): Storage.Info? + +public final class Logger { + public constructor Logger() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun info(/*0*/ message: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Storage { + public constructor Storage() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun info(/*0*/ name: kotlin.String): Storage.Info + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final inner class Info /*captured type parameters: /*0*/ T*/ { + public constructor Info() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public final class User { + public constructor User() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 6404e5c2677..a74d1994ae2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -10588,12 +10588,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt"); } - @Test - @TestMetadata("dp.kt") - public void testDp() throws Exception { - runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.kt"); - } - @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { @@ -10741,17 +10735,83 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("autoCloseScope.kt") + public void testAutoCloseScope() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt"); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt"); + } + @Test @TestMetadata("clickHandler.kt") public void testClickHandler() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt"); } + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("decimateEveryEvenThird.kt") + public void testDecimateEveryEvenThird() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt"); + } + @Test @TestMetadata("functionalType.kt") public void testFunctionalType() throws Exception { runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt"); } + + @Test + @TestMetadata("iterableClass.kt") + public void testIterableClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt"); + } + + @Test + @TestMetadata("json.kt") + public void testJson() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt"); + } + + @Test + @TestMetadata("loggingContext.kt") + public void testLoggingContext() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt"); + } + + @Test + @TestMetadata("transaction.kt") + public void testTransaction() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt"); + } + + @Test + @TestMetadata("userStorage.kt") + public void testUserStorage() throws Exception { + runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt"); + } } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index dfe5c547645..acebe1ad929 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -16048,6 +16048,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testAllFilesPresentInContextReceivers() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + public class FromKEEP { + @Test + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index b1fb04bd91c..082f28dd48f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -16163,12 +16163,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/contextAndExtensionSameName.kt"); } - @Test - @TestMetadata("dp.kt") - public void testDp() throws Exception { - runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/dp.kt"); - } - @Test @TestMetadata("inferGenericPropertyType.kt") public void testInferGenericPropertyType() throws Exception { @@ -16210,6 +16204,46 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testThis() throws Exception { runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/this.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + public class FromKEEP { + @Test + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt"); + } + + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("decimateEveryEvenThird.kt") + public void testDecimateEveryEvenThird() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt"); + } + } } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d0f61a31d92..4cd6d8c05cb 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13217,6 +13217,19 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testAllFilesPresentInContextReceivers() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromKEEP extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + } } } diff --git a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/VisualizerBlackBoxTestGenerated.java b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/VisualizerBlackBoxTestGenerated.java index 16fbd93bed6..28f1255e9f2 100644 --- a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/VisualizerBlackBoxTestGenerated.java +++ b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/VisualizerBlackBoxTestGenerated.java @@ -14804,6 +14804,19 @@ public class VisualizerBlackBoxTestGenerated extends AbstractVisualizerBlackBoxT public void testAllFilesPresentInContextReceivers() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromKEEP extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 7b49f3b5b1a..70d16b981fc 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -12267,14 +12267,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @Nested @TestMetadata("compiler/testData/codegen/box/extensionClasses") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ExtensionClasses extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - + public class ExtensionClasses { + @Test public void testAllFilesPresentInExtensionClasses() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } @@ -12457,17 +12454,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/extensionFunctions/whenFail.kt"); } + @Nested @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ContextReceivers extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - + public class ContextReceivers { + @Test public void testAllFilesPresentInContextReceivers() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + public class FromKEEP { + @Test + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 9ad711679fe..85af58ef015 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -12511,6 +12511,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testAllFilesPresentInContextReceivers() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromKEEP extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index ef2213a161f..4e763cc285a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -10384,6 +10384,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest public void testAllFilesPresentInContextReceivers() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + + @TestMetadata("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromKEEP extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } } }