From 910660a083c20bfce7178dbd790ad0e82c038049 Mon Sep 17 00:00:00 2001 From: Anastasiya Shadrina Date: Thu, 16 Sep 2021 17:13:13 +0700 Subject: [PATCH] [FE] Add language feature for context receivers --- .../arguments/CommonCompilerArguments.kt | 10 +++ .../resolve/PlatformConfiguratorBase.kt | 1 + .../checkers/ContextualDeclarationChecker.kt | 62 +++++++++++++++++++ .../jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt | 9 +++ compiler/testData/cli/js/jsExtraHelp.out | 1 + compiler/testData/cli/jvm/extraHelp.out | 1 + .../box/extensionClasses/constructors.kt | 1 + .../codegen/box/extensionClasses/edouble.kt | 1 + .../box/extensionClasses/genericCollection.kt | 1 + .../codegen/box/extensionClasses/generics.kt | 1 + .../codegen/box/extensionClasses/simple.kt | 1 + .../contextAndExtensionSameName.kt | 1 + .../contextReceivers/fromKEEP/canvas.kt | 1 + .../contextReceivers/fromKEEP/compareTo.kt | 1 + .../fromKEEP/decimateEveryEvenThird.kt | 1 + .../contextReceivers/fromKEEP/dp.kt | 1 + .../contextReceivers/fromKEEP/monoidSum.kt | 1 + .../inferGenericPropertyType.kt | 1 + .../contextReceivers/localDeclaration.kt | 1 + .../contextReceivers/overload.kt | 1 + .../contextReceivers/plusAssign.kt | 1 + .../contextReceivers/plusMatrix.kt | 1 + .../contextReceivers/simpleCall.kt | 1 + .../contextReceivers/this.kt | 1 + .../method/contextualFunctions/Signature.kt | 1 + .../contextReceivers/ambiguityInGroup.fir.kt | 2 + .../contextReceivers/ambiguityInGroup.kt | 2 + .../fromKEEP/autoCloseScope.kt | 2 + .../contextReceivers/fromKEEP/canvas.kt | 1 + .../contextReceivers/fromKEEP/clickHandler.kt | 1 + .../fromKEEP/compareTo.fir.kt | 2 + .../contextReceivers/fromKEEP/compareTo.kt | 2 + .../contextReceivers/fromKEEP/dp.fir.kt | 2 + .../contextReceivers/fromKEEP/dp.kt | 2 + .../fromKEEP/functionalType.kt | 1 + .../fromKEEP/iterableClass.fir.kt | 2 + .../fromKEEP/iterableClass.kt | 2 + .../contextReceivers/fromKEEP/json.fir.kt | 2 + .../contextReceivers/fromKEEP/json.kt | 2 + .../fromKEEP/loggingContext.fir.kt | 2 + .../fromKEEP/loggingContext.kt | 2 + .../fromKEEP/monoidSum.fir.kt | 2 + .../contextReceivers/fromKEEP/monoidSum.kt | 2 + .../fromKEEP/transaction.fir.kt | 2 + .../contextReceivers/fromKEEP/transaction.kt | 2 + .../fromKEEP/userStorage.fir.kt | 2 + .../contextReceivers/fromKEEP/userStorage.kt | 2 + .../contextReceivers/functionalType.fir.kt | 2 + .../contextReceivers/functionalType.kt | 2 + .../contextReceivers/genericOuterClass.fir.kt | 2 + .../contextReceivers/genericOuterClass.kt | 2 + .../contextReceivers/insideDeclaration.fir.kt | 2 + .../contextReceivers/insideDeclaration.kt | 2 + .../extensions/contextReceivers/lazy.fir.kt | 2 + .../tests/extensions/contextReceivers/lazy.kt | 2 + .../contextReceivers/localDeclaration.fir.kt | 2 + .../contextReceivers/localDeclaration.kt | 2 + .../contextReceivers/manyReceivers.fir.kt | 2 + .../contextReceivers/manyReceivers.kt | 2 + .../contextReceivers/noBackingField.fir.kt | 2 + .../contextReceivers/noBackingField.kt | 2 + .../noContextReceiversOnInlineClasses.fir.kt | 2 +- .../noContextReceiversOnInlineClasses.kt | 2 +- .../contextReceivers/noExplicitReceiver.kt | 1 + .../contextReceivers/outerClass.fir.kt | 1 + .../extensions/contextReceivers/outerClass.kt | 1 + .../contextReceivers/overloadPriority.fir.kt | 2 + .../contextReceivers/overloadPriority.kt | 2 + .../extensions/contextReceivers/plusMatrix.kt | 1 + .../contextReceivers/superWithContext.fir.kt | 2 + .../contextReceivers/superWithContext.kt | 2 + .../contextReceivers/syntaxError.kt | 2 + .../thisIdentifierInfo.fir.kt | 2 + .../contextReceivers/thisIdentifierInfo.kt | 2 + .../thisWithCustomLabel.fir.kt | 2 + .../contextReceivers/thisWithCustomLabel.kt | 2 + .../thisWithReceiverLabelsClasses.fir.kt | 2 + .../thisWithReceiverLabelsClasses.kt | 2 + .../thisWithReceiverLabelsFunctions.fir.kt | 2 + .../thisWithReceiverLabelsFunctions.kt | 2 + .../thisWithReceiverLabelsProperties.fir.kt | 2 + .../thisWithReceiverLabelsProperties.kt | 2 + .../contextReceivers/typeParameterized.fir.kt | 1 + .../contextReceivers/typeParameterized.kt | 1 + .../typeParameterizedList.fir.kt | 1 + .../contextReceivers/typeParameterizedList.kt | 1 + .../withExplicitReceiver.fir.kt | 2 + .../contextReceivers/withExplicitReceiver.kt | 2 + .../withExplicitReceiverError.fir.kt | 2 + .../withExplicitReceiverError.kt | 2 + .../kotlin/config/LanguageVersionSettings.kt | 3 +- 91 files changed, 222 insertions(+), 3 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ContextualDeclarationChecker.kt diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 0235da97880..09fc8d75d1f 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -376,6 +376,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() { ) var selfUpperBoundInference: Boolean by FreezableVar(false) + @Argument( + value = "-Xcontext-receivers", + description = "Enable experimental context receivers" + ) + var contextReceivers: Boolean by FreezableVar(false) + open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap, Any> { return HashMap, Any>().apply { put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck) @@ -433,6 +439,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() { put(LanguageFeature.DisableCompatibilityModeForNewInference, LanguageFeature.State.ENABLED) } + if (contextReceivers) { + put(LanguageFeature.ContextReceivers, LanguageFeature.State.ENABLED) + } + if (inlineClasses) { put(LanguageFeature.InlineClasses, LanguageFeature.State.ENABLED) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt index 23f5f63fb9c..5ac9c4f7a4f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt @@ -47,6 +47,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf( SealedInterfaceAllowedChecker, SuspendFunctionAsSupertypeChecker, EnumCompanionInEnumConstructorCallChecker, + ContextualDeclarationChecker, ) private val DEFAULT_CALL_CHECKERS = listOf( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ContextualDeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ContextualDeclarationChecker.kt new file mode 100644 index 00000000000..53a338fb69b --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ContextualDeclarationChecker.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve.checkers + +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType +import org.jetbrains.kotlin.psi.psiUtil.isContextualDeclaration + +object ContextualDeclarationChecker : DeclarationChecker { + override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { + if (context.languageVersionSettings.supportsFeature(LanguageFeature.ContextReceivers)) { + return + } + if (declaration.isContextualDeclaration()) { + val contextReceiverList = declaration.findDescendantOfType() ?: return + context.trace.report( + Errors.UNSUPPORTED_FEATURE.on( + contextReceiverList, LanguageFeature.ContextReceivers to context.languageVersionSettings + ) + ) + return + } + val types = mutableListOf() + when (declaration) { + is KtFunction -> { + types.addAll(declaration.valueParameters.mapNotNull { it.typeReference }) + types.add(declaration.receiverTypeReference) + types.add(declaration.typeReference) + } + is KtProperty -> { + types.add(declaration.receiverTypeReference) + types.add(declaration.typeReference) + } + is KtClass -> { + types.addAll(declaration.primaryConstructor?.valueParameters?.map { it.typeReference } ?: emptyList()) + } + is KtTypeAlias -> { + types.add(declaration.getTypeReference()) + } + } + + fun KtTypeReference.isOrHasContextualType(): Boolean { + val typeElement = typeElement as? KtFunctionType ?: return false + return !typeElement.contextReceiversTypeReferences.isNullOrEmpty() + || typeElement.typeArgumentsAsTypes.any(KtTypeReference::isOrHasContextualType) + } + + types.filterNotNull().filter { it.isOrHasContextualType() }.forEach { + context.trace.report( + Errors.UNSUPPORTED_FEATURE.on( + it, LanguageFeature.ContextReceivers to context.languageVersionSettings + ) + ) + } + } +} \ No newline at end of file diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt index e8d42329732..bdc606a6ac1 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt @@ -333,6 +333,15 @@ fun PsiElement.isExtensionDeclaration(): Boolean { return callable?.receiverTypeReference != null } +fun KtElement.isContextualDeclaration(): Boolean { + val contextReceivers = when (this) { + is KtCallableDeclaration -> contextReceivers + is KtClassOrObject -> contextReceivers + else -> emptyList() + } + return contextReceivers.isNotEmpty() +} + fun KtClassOrObject.isObjectLiteral(): Boolean = this is KtObjectDeclaration && isObjectLiteral() //TODO: strange method, and not only Kotlin specific (also Java) diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 24c50dbd337..2e6aa5253a8 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -49,6 +49,7 @@ where advanced options include: Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions -Xcommon-sources= Sources of the common module that need to be compiled together with this module in the multi-platform mode. Should be a subset of sources passed as free arguments + -Xcontext-receivers Enable experimental context receivers -Xdisable-default-scripting-plugin Do not enable scripting plugin by default -Xdisable-phases Disable backend phases diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 0f8fc2a1783..c41c70deda5 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -152,6 +152,7 @@ where advanced options include: Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions -Xcommon-sources= Sources of the common module that need to be compiled together with this module in the multi-platform mode. Should be a subset of sources passed as free arguments + -Xcontext-receivers Enable experimental context receivers -Xdisable-default-scripting-plugin Do not enable scripting plugin by default -Xdisable-phases Disable backend phases diff --git a/compiler/testData/codegen/box/extensionClasses/constructors.kt b/compiler/testData/codegen/box/extensionClasses/constructors.kt index 080892a87df..f65cc67a786 100644 --- a/compiler/testData/codegen/box/extensionClasses/constructors.kt +++ b/compiler/testData/codegen/box/extensionClasses/constructors.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/extensionClasses/edouble.kt b/compiler/testData/codegen/box/extensionClasses/edouble.kt index 4d3fc7fbee4..6d6293eaf74 100644 --- a/compiler/testData/codegen/box/extensionClasses/edouble.kt +++ b/compiler/testData/codegen/box/extensionClasses/edouble.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionClasses/genericCollection.kt b/compiler/testData/codegen/box/extensionClasses/genericCollection.kt index 2b29a400a0f..a2dd4a72f1b 100644 --- a/compiler/testData/codegen/box/extensionClasses/genericCollection.kt +++ b/compiler/testData/codegen/box/extensionClasses/genericCollection.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/extensionClasses/generics.kt b/compiler/testData/codegen/box/extensionClasses/generics.kt index 00da29539f5..1172f1614f2 100644 --- a/compiler/testData/codegen/box/extensionClasses/generics.kt +++ b/compiler/testData/codegen/box/extensionClasses/generics.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionClasses/simple.kt b/compiler/testData/codegen/box/extensionClasses/simple.kt index e23684ff291..8bcfd4e437a 100644 --- a/compiler/testData/codegen/box/extensionClasses/simple.kt +++ b/compiler/testData/codegen/box/extensionClasses/simple.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/contextAndExtensionSameName.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/contextAndExtensionSameName.kt index 4556b7e680b..7feb85fbaf0 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/contextAndExtensionSameName.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/contextAndExtensionSameName.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR class A { diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt index 00d408eb3b2..95f59cbcffa 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/canvas.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt index 53e29e1512b..eb7443d7e12 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/compareTo.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt index bd429e53956..9d2e63e4419 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt index 6dc0377731b..9973c7a317a 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/dp.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt index 798370f9232..6c3c3d3cd00 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/monoidSum.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/inferGenericPropertyType.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/inferGenericPropertyType.kt index 6e7d0d0d94c..b36ba173afc 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/inferGenericPropertyType.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/inferGenericPropertyType.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/localDeclaration.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/localDeclaration.kt index e64ea2c6c4a..37af174a7bd 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/localDeclaration.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/localDeclaration.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/overload.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/overload.kt index 209ed59c350..4541fd70781 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/overload.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/overload.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusAssign.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusAssign.kt index bec11d1bc4b..c336947f112 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusAssign.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusAssign.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusMatrix.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusMatrix.kt index 0d50c402f09..b55b9c9deab 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusMatrix.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/plusMatrix.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/simpleCall.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/simpleCall.kt index 7b3743decc2..d38e78ee083 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/simpleCall.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/simpleCall.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/this.kt b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/this.kt index ec5f00e5253..9cee73cb9a8 100644 --- a/compiler/testData/codegen/box/extensionFunctions/contextReceivers/this.kt +++ b/compiler/testData/codegen/box/extensionFunctions/contextReceivers/this.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/compileJavaAgainstKotlin/method/contextualFunctions/Signature.kt b/compiler/testData/compileJavaAgainstKotlin/method/contextualFunctions/Signature.kt index 66dc81a58d6..d54c1341464 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/contextualFunctions/Signature.kt +++ b/compiler/testData/compileJavaAgainstKotlin/method/contextualFunctions/Signature.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR package test diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.fir.kt index b0030b12c7c..fd64b983d42 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Common { fun supertypeMember() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt index be94f429277..a12ece4c055 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Common { fun supertypeMember() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt index c184a969edf..0c9e9bd397c 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/autoCloseScope.kt @@ -1,4 +1,6 @@ +// !LANGUAGE: +ContextReceivers // FIR_IDENTICAL + class File(name: String) interface InputStream diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt index 944e34f365a..d9d728cd9fe 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/canvas.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // FIR_IDENTICAL interface Canvas diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt index 4291b65acd2..47ddfc537c1 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/clickHandler.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // FIR_IDENTICAL class Button diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt index c1bce127135..73578e68610 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + data class Pair(val first: A, val second: B) context(Comparator) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt index e60ba05131c..2100f1b35f1 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/compareTo.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + data class Pair(val first: A, val second: B) context(Comparator) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.fir.kt index b899fb6fabc..de5176ce586 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class View context(View) val Int.dp get() = 42 * this diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt index 12459b03d00..5b67b8b4769 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/dp.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class View context(View) val Int.dp get() = 42 * this diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt index 24c52ed7e2d..9380d0c42d7 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/functionalType.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE class Context diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt index 9e382ffc1b5..e64f77dc887 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + typealias IterableClass = (C) -> Iterator context(IterableClass) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt index 00eac4482e1..ce54e66f7eb 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/iterableClass.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + typealias IterableClass = (C) -> Iterator context(IterableClass) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt index eae8208bec0..34687792205 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class JSONObject { fun build(): JSONObject = TODO() diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt index 1b46c61b9e8..fd7a91ccfe0 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/json.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class JSONObject { fun build(): JSONObject = TODO() diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt index 9e50f65d4d6..577fb8d1052 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Params interface Logger { fun info(message: String) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt index 5c161e3111c..985e3677f5f 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/loggingContext.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Params interface Logger { fun info(message: 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 index d5e8bbb9366..179176e19ba 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Semigroup { infix fun T.combine(other: T): T } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt index 425761e35e5..936b1ba1213 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/monoidSum.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Semigroup { infix fun T.combine(other: T): T } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt index d08f5c3a1b3..a7f271d1271 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Session(var lastAccess: Any?) interface Transaction { fun loadSession(): Session diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt index 7e80f045bb8..19af7d62403 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/transaction.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Session(var lastAccess: Any?) interface Transaction { fun loadSession(): Session diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt index e8338dad487..17cf4d280e8 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Storage { inner class Info diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt index d1d5ec9e4fe..99c66ed8ad2 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/fromKEEP/userStorage.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Storage { inner class Info diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.fir.kt index 4f60bdcfbe6..5708bd4e615 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Param class C { val c = 42 diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.kt index e86759ad624..c41f82d32b0 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/functionalType.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Param class C { val c = 42 diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.fir.kt index 86f0c08eda6..33b8cd71411 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + context(T) class A context(Collection

) class B

diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.kt index ecd9a03f1a7..08c2ef0a6ef 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + context(T) class A context(Collection

) class B

diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.fir.kt index 77005ab5757..63517d7de7d 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A { fun h1() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.kt index e597616d529..0c812dfa399 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A { fun h1() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.fir.kt index 72fb3faff08..3b3b3800f02 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Lazy context(Lazy, Lazy) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.kt index 4dbefeda667..a37f52e5fcd 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Lazy context(Lazy, Lazy) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.fir.kt index babf9028a87..8978b33cd44 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface A { fun f() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.kt index f45179f58c0..a8cc3e34185 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface A { fun f() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.fir.kt index fafd3248e0f..6721c8d7a05 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A { val a = 1 } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.kt index 9381c2a7945..2a674f33d4e 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A { val a = 1 } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.fir.kt index 673069b107e..d91e6f55f02 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface A { fun a(): Int } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.kt index 3957eac2560..31bff9ecd5f 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface A { fun a(): Int } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.fir.kt index e076b2f3d30..08f684ad182 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.fir.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses +// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers class A diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt index 258496c950e..9a7a98c1ab6 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses +// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers class A diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt index 6b8a441f2ad..0ef98f943e7 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // FIR_IDENTICAL class A diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.fir.kt index 9eb2522bd81..200a7626c35 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.fir.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // !DIAGNOSTICS: -UNUSED_PARAMETER class Outer { diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt index 3e3c8ece999..a5b4a4baafd 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // !DIAGNOSTICS: -UNUSED_PARAMETER class Outer { diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.fir.kt index 4b286695031..1e3df6e6802 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Context context(Context) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt index 16b9a8d96ed..a531659ec46 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class Context context(Context) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/plusMatrix.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/plusMatrix.kt index a477e99e434..1c250ee1b07 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/plusMatrix.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/plusMatrix.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.fir.kt index 6c7c4e3e8bc..3de9fd5a5f0 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Context { fun h() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.kt index 523d2b4d5a4..c24b69ae44b 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + interface Context { fun h() {} } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/syntaxError.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/syntaxError.kt index 530b05d5f04..34fca04f2ea 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/syntaxError.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/syntaxError.kt @@ -1,4 +1,6 @@ // FIR_IDENTICAL +// !LANGUAGE: +ContextReceivers + context( fun foo() { } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.fir.kt index 2c22138a9b1..e57b44c2246 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: String?) context(A) fun f() { diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.kt index 594eea357e1..ec96ef51dad 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: String?) context(A) fun f() { diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.fir.kt index f60db42652a..68e773638ef 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: T) class B(val b: Any) class C(val c: Any) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.kt index 9d1dad0c912..2f0ea3bc299 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: T) class B(val b: Any) class C(val c: Any) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.fir.kt index c131919fc61..8a135fa747d 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A { val x = 1 } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.kt index fa02a6267b0..8cbf90106a2 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A { val x = 1 } diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.fir.kt index 6dbf584fdf2..864f4e29cbf 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: T) class B(val b: Any) class C(val c: Any) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.kt index 92cd0197af3..05df251b007 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: T) class B(val b: Any) class C(val c: Any) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.fir.kt index 4e373d5c7da..283e4875f64 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: T) class B(val b: Any) class C(val c: Any) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt index 768ced6d82f..023997b2d6a 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A(val a: T) class B(val b: Any) class C(val c: Any) diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.fir.kt index 62b1f812bf7..99d7928d83a 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.fir.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // !DIAGNOSTICS: -UNUSED_PARAMETER class A diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.kt index 95bac5ac785..7db8d64e649 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // !DIAGNOSTICS: -UNUSED_PARAMETER class A diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.fir.kt index d66b071e38b..e45a458bac6 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.fir.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // !DIAGNOSTICS: -UNUSED_PARAMETER fun listOf(vararg e: T): List = null!! diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.kt index f844761f0a9..5c73ea97613 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ContextReceivers // !DIAGNOSTICS: -UNUSED_PARAMETER fun listOf(vararg e: T): List = null!! diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.fir.kt index 3f80e0896af..487ff5fd018 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + open class A class B class C: A() diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.kt index 52e77f6e02a..906d8be73c5 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + open class A class B class C: A() diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.fir.kt index 49ed65412e8..94124cdd290 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A class B class C diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.kt index f2316d19c09..42884bff50e 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +ContextReceivers + class A class B class C diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 6f0a310729c..67c20e9fe5e 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -268,7 +268,8 @@ enum class LanguageFeature( ExplicitBackingFields(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE), FunctionalTypeWithExtensionAsSupertype(sinceVersion = KOTLIN_1_6, defaultState = State.DISABLED), JsAllowInvalidCharsIdentifiersEscaping(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE), - JsAllowValueClassesInExternals(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE) + JsAllowValueClassesInExternals(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE), + ContextReceivers(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE), ;