[FE] Add language feature for context receivers
This commit is contained in:
committed by
TeamCityServer
parent
369c86ebb0
commit
910660a083
+10
@@ -376,6 +376,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
)
|
)
|
||||||
var selfUpperBoundInference: Boolean by FreezableVar(false)
|
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<AnalysisFlag<*>, Any> {
|
open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> {
|
||||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||||
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||||
@@ -433,6 +439,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
put(LanguageFeature.DisableCompatibilityModeForNewInference, LanguageFeature.State.ENABLED)
|
put(LanguageFeature.DisableCompatibilityModeForNewInference, LanguageFeature.State.ENABLED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contextReceivers) {
|
||||||
|
put(LanguageFeature.ContextReceivers, LanguageFeature.State.ENABLED)
|
||||||
|
}
|
||||||
|
|
||||||
if (inlineClasses) {
|
if (inlineClasses) {
|
||||||
put(LanguageFeature.InlineClasses, LanguageFeature.State.ENABLED)
|
put(LanguageFeature.InlineClasses, LanguageFeature.State.ENABLED)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf(
|
|||||||
SealedInterfaceAllowedChecker,
|
SealedInterfaceAllowedChecker,
|
||||||
SuspendFunctionAsSupertypeChecker,
|
SuspendFunctionAsSupertypeChecker,
|
||||||
EnumCompanionInEnumConstructorCallChecker,
|
EnumCompanionInEnumConstructorCallChecker,
|
||||||
|
ContextualDeclarationChecker,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val DEFAULT_CALL_CHECKERS = listOf(
|
private val DEFAULT_CALL_CHECKERS = listOf(
|
||||||
|
|||||||
+62
@@ -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<KtContextReceiverList>() ?: return
|
||||||
|
context.trace.report(
|
||||||
|
Errors.UNSUPPORTED_FEATURE.on(
|
||||||
|
contextReceiverList, LanguageFeature.ContextReceivers to context.languageVersionSettings
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val types = mutableListOf<KtTypeReference?>()
|
||||||
|
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
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -333,6 +333,15 @@ fun PsiElement.isExtensionDeclaration(): Boolean {
|
|||||||
return callable?.receiverTypeReference != null
|
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()
|
fun KtClassOrObject.isObjectLiteral(): Boolean = this is KtObjectDeclaration && isObjectLiteral()
|
||||||
|
|
||||||
//TODO: strange method, and not only Kotlin specific (also Java)
|
//TODO: strange method, and not only Kotlin specific (also Java)
|
||||||
|
|||||||
+1
@@ -49,6 +49,7 @@ where advanced options include:
|
|||||||
Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions
|
Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions
|
||||||
-Xcommon-sources=<path> Sources of the common module that need to be compiled together with this module in the multi-platform mode.
|
-Xcommon-sources=<path> 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
|
Should be a subset of sources passed as free arguments
|
||||||
|
-Xcontext-receivers Enable experimental context receivers
|
||||||
-Xdisable-default-scripting-plugin
|
-Xdisable-default-scripting-plugin
|
||||||
Do not enable scripting plugin by default
|
Do not enable scripting plugin by default
|
||||||
-Xdisable-phases Disable backend phases
|
-Xdisable-phases Disable backend phases
|
||||||
|
|||||||
+1
@@ -152,6 +152,7 @@ where advanced options include:
|
|||||||
Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions
|
Run sticky condition checks on subsequent phases as well. Implies -Xcheck-phase-conditions
|
||||||
-Xcommon-sources=<path> Sources of the common module that need to be compiled together with this module in the multi-platform mode.
|
-Xcommon-sources=<path> 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
|
Should be a subset of sources passed as free arguments
|
||||||
|
-Xcontext-receivers Enable experimental context receivers
|
||||||
-Xdisable-default-scripting-plugin
|
-Xdisable-default-scripting-plugin
|
||||||
Do not enable scripting plugin by default
|
Do not enable scripting plugin by default
|
||||||
-Xdisable-phases Disable backend phases
|
-Xdisable-phases Disable backend phases
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
compiler/testData/codegen/box/extensionFunctions/contextReceivers/fromKEEP/decimateEveryEvenThird.kt
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// TARGET_BACKEND: JVM_IR
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Common {
|
interface Common {
|
||||||
fun supertypeMember() {}
|
fun supertypeMember() {}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Common {
|
interface Common {
|
||||||
fun supertypeMember() {}
|
fun supertypeMember() {}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,4 +1,6 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
class File(name: String)
|
class File(name: String)
|
||||||
interface InputStream
|
interface InputStream
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
interface Canvas
|
interface Canvas
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
class Button
|
class Button
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
data class Pair<A, B>(val first: A, val second: B)
|
data class Pair<A, B>(val first: A, val second: B)
|
||||||
|
|
||||||
context(Comparator<T>)
|
context(Comparator<T>)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
data class Pair<A, B>(val first: A, val second: B)
|
data class Pair<A, B>(val first: A, val second: B)
|
||||||
|
|
||||||
context(Comparator<T>)
|
context(Comparator<T>)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class View
|
class View
|
||||||
|
|
||||||
context(View) val Int.dp get() = 42 * this
|
context(View) val Int.dp get() = 42 * this
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class View
|
class View
|
||||||
|
|
||||||
context(View) val Int.dp get() = 42 * this
|
context(View) val Int.dp get() = 42 * this
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
|
// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
|
||||||
|
|
||||||
class Context
|
class Context
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
typealias IterableClass<C, T> = (C) -> Iterator<T>
|
typealias IterableClass<C, T> = (C) -> Iterator<T>
|
||||||
|
|
||||||
context(IterableClass<C, T>)
|
context(IterableClass<C, T>)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
typealias IterableClass<C, T> = (C) -> Iterator<T>
|
typealias IterableClass<C, T> = (C) -> Iterator<T>
|
||||||
|
|
||||||
context(IterableClass<C, T>)
|
context(IterableClass<C, T>)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class JSONObject {
|
class JSONObject {
|
||||||
fun build(): JSONObject = TODO()
|
fun build(): JSONObject = TODO()
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class JSONObject {
|
class JSONObject {
|
||||||
fun build(): JSONObject = TODO()
|
fun build(): JSONObject = TODO()
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Params
|
interface Params
|
||||||
interface Logger {
|
interface Logger {
|
||||||
fun info(message: String)
|
fun info(message: String)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Params
|
interface Params
|
||||||
interface Logger {
|
interface Logger {
|
||||||
fun info(message: String)
|
fun info(message: String)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Semigroup<T> {
|
interface Semigroup<T> {
|
||||||
infix fun T.combine(other: T): T
|
infix fun T.combine(other: T): T
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Semigroup<T> {
|
interface Semigroup<T> {
|
||||||
infix fun T.combine(other: T): T
|
infix fun T.combine(other: T): T
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Session(var lastAccess: Any?)
|
class Session(var lastAccess: Any?)
|
||||||
interface Transaction {
|
interface Transaction {
|
||||||
fun loadSession(): Session
|
fun loadSession(): Session
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Session(var lastAccess: Any?)
|
class Session(var lastAccess: Any?)
|
||||||
interface Transaction {
|
interface Transaction {
|
||||||
fun loadSession(): Session
|
fun loadSession(): Session
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Storage<T> {
|
class Storage<T> {
|
||||||
inner class Info
|
inner class Info
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Storage<T> {
|
class Storage<T> {
|
||||||
inner class Info
|
inner class Info
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Param
|
class Param
|
||||||
class C {
|
class C {
|
||||||
val c = 42
|
val c = 42
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Param
|
class Param
|
||||||
class C {
|
class C {
|
||||||
val c = 42
|
val c = 42
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
context(T) class A<T>
|
context(T) class A<T>
|
||||||
|
|
||||||
context(Collection<P>) class B<P>
|
context(Collection<P>) class B<P>
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
context(T) class A<T>
|
context(T) class A<T>
|
||||||
|
|
||||||
context(Collection<P>) class B<P>
|
context(Collection<P>) class B<P>
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
fun h1() {}
|
fun h1() {}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
fun h1() {}
|
fun h1() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Lazy<T>
|
interface Lazy<T>
|
||||||
|
|
||||||
context(Lazy<Int>, Lazy<CharSequence>)
|
context(Lazy<Int>, Lazy<CharSequence>)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Lazy<T>
|
interface Lazy<T>
|
||||||
|
|
||||||
context(Lazy<Int>, Lazy<CharSequence>)
|
context(Lazy<Int>, Lazy<CharSequence>)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface A {
|
interface A {
|
||||||
fun f() {}
|
fun f() {}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface A {
|
interface A {
|
||||||
fun f() {}
|
fun f() {}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
val a = 1
|
val a = 1
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
val a = 1
|
val a = 1
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface A {
|
interface A {
|
||||||
fun a(): Int
|
fun a(): Int
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface A {
|
interface A {
|
||||||
fun a(): Int
|
fun a(): Int
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
|
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers
|
||||||
|
|
||||||
class A
|
class A
|
||||||
|
|
||||||
|
|||||||
compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
|
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +ContextReceivers
|
||||||
|
|
||||||
class A
|
class A
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
class A
|
class A
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class Outer {
|
class Outer {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class Outer {
|
class Outer {
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Context
|
class Context
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS!>context(Context)
|
<!CONFLICTING_OVERLOADS!>context(Context)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class Context
|
class Context
|
||||||
|
|
||||||
context(Context)
|
context(Context)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Context {
|
interface Context {
|
||||||
fun h() {}
|
fun h() {}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
interface Context {
|
interface Context {
|
||||||
fun h() {}
|
fun h() {}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,4 +1,6 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
context(
|
context(
|
||||||
<!SYNTAX!><!>fun foo() {
|
<!SYNTAX!><!>fun foo() {
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A(val a: String?)
|
class A(val a: String?)
|
||||||
|
|
||||||
context(A) fun f() {
|
context(A) fun f() {
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A(val a: String?)
|
class A(val a: String?)
|
||||||
|
|
||||||
context(A) fun f() {
|
context(A) fun f() {
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A<T>(val a: T)
|
class A<T>(val a: T)
|
||||||
class B(val b: Any)
|
class B(val b: Any)
|
||||||
class C(val c: Any)
|
class C(val c: Any)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A<T>(val a: T)
|
class A<T>(val a: T)
|
||||||
class B(val b: Any)
|
class B(val b: Any)
|
||||||
class C(val c: Any)
|
class C(val c: Any)
|
||||||
|
|||||||
compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.fir.kt
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
val x = 1
|
val x = 1
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
val x = 1
|
val x = 1
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A<T>(val a: T)
|
class A<T>(val a: T)
|
||||||
class B(val b: Any)
|
class B(val b: Any)
|
||||||
class C(val c: Any)
|
class C(val c: Any)
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A<T>(val a: T)
|
class A<T>(val a: T)
|
||||||
class B(val b: Any)
|
class B(val b: Any)
|
||||||
class C(val c: Any)
|
class C(val c: Any)
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A<T>(val a: T)
|
class A<T>(val a: T)
|
||||||
class B(val b: Any)
|
class B(val b: Any)
|
||||||
class C(val c: Any)
|
class C(val c: Any)
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A<T>(val a: T)
|
class A<T>(val a: T)
|
||||||
class B(val b: Any)
|
class B(val b: Any)
|
||||||
class C(val c: Any)
|
class C(val c: Any)
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class A
|
class A
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class A
|
class A
|
||||||
|
|||||||
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
fun <T> listOf(vararg e: T): List<T> = null!!
|
fun <T> listOf(vararg e: T): List<T> = null!!
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
fun <T> listOf(vararg e: T): List<T> = null!!
|
fun <T> listOf(vararg e: T): List<T> = null!!
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
open class A
|
open class A
|
||||||
class B
|
class B
|
||||||
class C: A()
|
class C: A()
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
open class A
|
open class A
|
||||||
class B
|
class B
|
||||||
class C: A()
|
class C: A()
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A
|
class A
|
||||||
class B
|
class B
|
||||||
class C
|
class C
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
|
||||||
class A
|
class A
|
||||||
class B
|
class B
|
||||||
class C
|
class C
|
||||||
|
|||||||
@@ -268,7 +268,8 @@ enum class LanguageFeature(
|
|||||||
ExplicitBackingFields(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE),
|
ExplicitBackingFields(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE),
|
||||||
FunctionalTypeWithExtensionAsSupertype(sinceVersion = KOTLIN_1_6, defaultState = State.DISABLED),
|
FunctionalTypeWithExtensionAsSupertype(sinceVersion = KOTLIN_1_6, defaultState = State.DISABLED),
|
||||||
JsAllowInvalidCharsIdentifiersEscaping(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE),
|
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),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user