[K2] Disappeared UNSUPPORTED
Forbid callable reference to coroutineContext ^KT-59881
This commit is contained in:
committed by
Space Team
parent
daac8603d0
commit
7787b53b4a
+17
-1
@@ -44,7 +44,12 @@ object FirSuspendCallChecker : FirQualifiedAccessExpressionChecker() {
|
||||
) {
|
||||
checkSuspendModifierForm(expression, reference, symbol, context, reporter)
|
||||
}
|
||||
if (reference is FirResolvedCallableReference) return
|
||||
|
||||
if (reference is FirResolvedCallableReference) {
|
||||
checkCallableReference(expression, symbol, reporter, context)
|
||||
return
|
||||
}
|
||||
|
||||
when (symbol) {
|
||||
is FirNamedFunctionSymbol -> if (!symbol.isSuspend) return
|
||||
is FirPropertySymbol -> if (symbol.callableId != StandardClassIds.Callables.coroutineContext) return
|
||||
@@ -260,6 +265,17 @@ object FirSuspendCallChecker : FirQualifiedAccessExpressionChecker() {
|
||||
calledDeclarationSymbol.resolvedReceiverTypeRef?.coneType,
|
||||
)
|
||||
}
|
||||
|
||||
private fun checkCallableReference(
|
||||
expression: FirQualifiedAccessExpression,
|
||||
symbol: FirCallableSymbol<*>,
|
||||
reporter: DiagnosticReporter,
|
||||
context: CheckerContext,
|
||||
) {
|
||||
if (symbol.callableId == StandardClassIds.Callables.coroutineContext) {
|
||||
reporter.reportOn(expression.calleeReference.source, FirErrors.UNSUPPORTED, "Callable reference to suspend property", context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum class SuspendCallArgumentKind {
|
||||
|
||||
Reference in New Issue
Block a user