Extract diagnostics about 'suspend test' to a separate one

^KT-59152
This commit is contained in:
Mikhail Zarechenskiy
2023-06-07 14:52:16 +02:00
committed by Space Team
parent 2dfdd8dcf6
commit 9cf40f8c2f
4 changed files with 5 additions and 3 deletions
@@ -80,6 +80,7 @@ public interface Errors {
DiagnosticFactory1<PsiElement, String> UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_WHEN = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_FUN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> UNSUPPORTED_SUSPEND_TEST = DiagnosticFactory0.create(ERROR);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -828,6 +828,7 @@ public class DefaultErrorMessages {
MAP.put(UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION, "Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': {0} is unsupported", STRING);
MAP.put(UNSUPPORTED_SEALED_WHEN, "'sealed' in front of 'when' is reserved");
MAP.put(UNSUPPORTED_SEALED_FUN_INTERFACE, "'sealed fun interface' is unsupported");
MAP.put(UNSUPPORTED_SUSPEND_TEST, "'suspend' functions annotated with @kotlin.test.Test are unsupported");
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
@@ -46,7 +46,7 @@ object SuspendLimitationsChecker : DeclarationChecker {
if (descriptor.annotations.any(AnnotationDescriptor::isKotlinTestAnnotation)) {
declaration.modifierList?.getModifier(KtTokens.SUSPEND_KEYWORD)?.let {
context.trace.report(Errors.UNSUPPORTED.on(it, "suspend test functions"))
context.trace.report(Errors.UNSUPPORTED_SUSPEND_TEST.on(it))
}
}
}
@@ -14,8 +14,8 @@ import kotlin.test.Test
class A {
@Test
<!UNSUPPORTED!>suspend<!> fun test() {}
<!UNSUPPORTED_SUSPEND_TEST!>suspend<!> fun test() {}
}
@Test
<!UNSUPPORTED!>suspend<!> fun test() {}
<!UNSUPPORTED_SUSPEND_TEST!>suspend<!> fun test() {}