[K2] Disappeared UNSUPPORTED_FEATURE (1)
Added a check for the enabled context receivers feature flag for typeRef. ^KT-59913
This commit is contained in:
committed by
Space Team
parent
471f25abfc
commit
685c8e4fe7
+1
@@ -21,5 +21,6 @@ object CommonTypeCheckers : TypeCheckers() {
|
||||
FirDuplicateParameterNameInFunctionTypeChecker,
|
||||
FirOptionalExpectationTypeChecker,
|
||||
FirIncompatibleClassTypeChecker,
|
||||
FirContextReceiversTypeChecker,
|
||||
)
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.fir.analysis.checkers.type
|
||||
|
||||
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
|
||||
object FirContextReceiversTypeChecker : FirTypeRefChecker() {
|
||||
override fun check(typeRef: FirTypeRef, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.ContextReceivers)) return
|
||||
if (typeRef !is FirResolvedTypeRef) return
|
||||
val source = typeRef.source ?: return
|
||||
if (source.kind is KtFakeSourceElementKind) return
|
||||
|
||||
if (typeRef.coneType.hasContextReceivers) {
|
||||
reporter.reportOn(
|
||||
source,
|
||||
FirErrors.UNSUPPORTED_FEATURE,
|
||||
LanguageFeature.ContextReceivers to context.languageVersionSettings,
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// !DIAGNOSTICS: -UNCHECKED_CAST
|
||||
|
||||
context(Any)
|
||||
fun f(g: context(Any) () -> Unit, value: Any): context(A) () -> Unit {
|
||||
return value as (context(A) () -> Unit)
|
||||
fun f(g: <!UNSUPPORTED_FEATURE!>context(Any) () -> Unit<!>, value: Any): <!UNSUPPORTED_FEATURE!>context(A) () -> Unit<!> {
|
||||
return value as <!UNSUPPORTED_FEATURE!>(context(A) () -> Unit)<!>
|
||||
}
|
||||
|
||||
fun f(g: () -> Unit, value: Any) : () -> Unit {
|
||||
|
||||
Reference in New Issue
Block a user