Add callee name to diagnostic about illegal suspension call
#KT-15938 Fixed
This commit is contained in:
@@ -911,7 +911,7 @@ public interface Errors {
|
||||
|
||||
|
||||
DiagnosticFactory0<PsiElement> NON_LOCAL_SUSPENSION_POINT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ILLEGAL_SUSPEND_FUNCTION_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_FUNCTION_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -905,7 +905,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(INLINE_CALL_CYCLE, "The ''{0}'' invocation is a part of inline cycle", NAME);
|
||||
MAP.put(NON_LOCAL_RETURN_IN_DISABLED_INLINE, "Non-local returns are not allowed with inlining disabled");
|
||||
MAP.put(NON_LOCAL_SUSPENSION_POINT, "Suspension functions can be called only within coroutine body");
|
||||
MAP.put(ILLEGAL_SUSPEND_FUNCTION_CALL, "Suspend functions are only allowed to be called from a coroutine or another suspend function");
|
||||
MAP.put(ILLEGAL_SUSPEND_FUNCTION_CALL, "Suspend function ''{0}'' should be called only from a coroutine or another suspend function", NAME);
|
||||
MAP.put(ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL, "Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope");
|
||||
|
||||
MAP.setImmutable();
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ object CoroutineSuspendCallChecker : CallChecker {
|
||||
checkRestrictsSuspension(enclosingSuspendFunction, resolvedCall, reportOn, context)
|
||||
}
|
||||
else -> {
|
||||
context.trace.report(Errors.ILLEGAL_SUSPEND_FUNCTION_CALL.on(reportOn))
|
||||
context.trace.report(Errors.ILLEGAL_SUSPEND_FUNCTION_CALL.on(reportOn, resolvedCall.candidateDescriptor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// !DIAGNOSTICS_NUMBER: 1
|
||||
// !DIAGNOSTICS: ILLEGAL_SUSPEND_FUNCTION_CALL
|
||||
suspend fun foo() {}
|
||||
|
||||
fun noSuspend() {
|
||||
foo()
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<!-- illegalSuspendCall1 -->
|
||||
Suspend function 'foo' should be called only from a coroutine or another suspend function
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// "Make bar suspend" "false"
|
||||
// ERROR: Suspend functions are only allowed to be called from a coroutine or another suspend function
|
||||
// ERROR: Suspend function 'foo' should be called only from a coroutine or another suspend function
|
||||
|
||||
suspend fun foo() {}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// "Make bar suspend" "false"
|
||||
// ACTION: Convert property initializer to getter
|
||||
// ERROR: Suspend functions are only allowed to be called from a coroutine or another suspend function
|
||||
// ERROR: Suspend function 'foo' should be called only from a coroutine or another suspend function
|
||||
|
||||
suspend fun foo() = 42
|
||||
val x = <caret>foo()
|
||||
|
||||
@@ -126,6 +126,12 @@ public class DiagnosticMessageTestGenerated extends AbstractDiagnosticMessageTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("illegalSuspendCall.kt")
|
||||
public void testIllegalSuspendCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/diagnosticMessage/illegalSuspendCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("invisibleMember.kt")
|
||||
public void testInvisibleMember() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/diagnosticMessage/invisibleMember.kt");
|
||||
|
||||
Reference in New Issue
Block a user