K2: report PRE_RELEASE_CLASS on JVM

Note that 3 tests are still muted, but for another reason: for FIR
versions of the tests, we need to compile the "pre-release library" with
the next language version which is 2.1. But since currently
LanguageVersion.LATEST_STABLE is 1.9, the compiler refuses to read
metadata of version 2.1, regardless of its own language version. Which
is correct, but it leads to irrelevant errors in the test output -- the
ones about the incompatible metadata version, NOT about the
prereleaseness.

These 3 tests can be unmuted once the default language version is
switched to 2.0.

 #KT-60780 Fixed
This commit is contained in:
Alexander Udalov
2023-08-12 00:06:48 +02:00
committed by Space Team
parent 8738ffb84f
commit fec2d063c1
14 changed files with 96 additions and 10 deletions
@@ -122,6 +122,7 @@ object FirJvmErrors {
val JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE by error0<PsiElement>()
val NO_REFLECTION_IN_CLASS_PATH by warning0<PsiElement>()
val INCOMPATIBLE_CLASS by error2<PsiElement, String, IncompatibleVersionErrorData<*>>()
val PRE_RELEASE_CLASS by error1<PsiElement, String>()
init {
RootDiagnosticRendererFactory.registerFactory(FirJvmErrorsDefaultMessages)
@@ -64,6 +64,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERLOADS_
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERRIDE_CANNOT_BE_STATIC
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.PRE_RELEASE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.REDUNDANT_REPEATABLE_ANNOTATION
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER
@@ -279,5 +280,10 @@ object FirJvmErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
"The class is loaded from ${FileUtil.toSystemIndependentName(incompatibility.filePath)}"
}
)
map.put(
PRE_RELEASE_CLASS,
"{0} is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler",
STRING
)
}
}
@@ -50,5 +50,8 @@ object FirIncompatibleClassExpressionChecker : FirQualifiedAccessExpressionCheck
if (incompatibility != null) {
reporter.reportOn(element.source, FirJvmErrors.INCOMPATIBLE_CLASS, source.presentableString, incompatibility, context)
}
if (source.isPreReleaseInvisible) {
reporter.reportOn(element.source, FirJvmErrors.PRE_RELEASE_CLASS, source.presentableString, context)
}
}
}