K2: report IR_WITH_UNSTABLE_ABI_COMPILED_CLASS
Also, remove setting the value of allowUnstableDependencies to true if K2 is used because we want K2 to report errors (as K1 does) on unstable-ABI dependencies. #KT-61598 Fixed
This commit is contained in:
committed by
Space Team
parent
6a1c210cd1
commit
4f96171716
+7
@@ -4938,6 +4938,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS) { firDiagnostic ->
|
||||
IrWithUnstableAbiCompiledClassImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJvmErrors.OVERRIDE_CANNOT_BE_STATIC) { firDiagnostic ->
|
||||
OverrideCannotBeStaticImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
|
||||
+5
@@ -3438,6 +3438,11 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
val presentableString: String
|
||||
}
|
||||
|
||||
interface IrWithUnstableAbiCompiledClass : KtFirDiagnostic<PsiElement> {
|
||||
override val diagnosticClass get() = IrWithUnstableAbiCompiledClass::class
|
||||
val presentableString: String
|
||||
}
|
||||
|
||||
interface OverrideCannotBeStatic : KtFirDiagnostic<PsiElement> {
|
||||
override val diagnosticClass get() = OverrideCannotBeStatic::class
|
||||
}
|
||||
|
||||
+6
@@ -4146,6 +4146,12 @@ internal class PreReleaseClassImpl(
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.PreReleaseClass
|
||||
|
||||
internal class IrWithUnstableAbiCompiledClassImpl(
|
||||
override val presentableString: String,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.IrWithUnstableAbiCompiledClass
|
||||
|
||||
internal class OverrideCannotBeStaticImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
|
||||
+1
-1
@@ -876,7 +876,7 @@ Also sets `-jvm-target` value equal to the selected JDK version"""
|
||||
result[JvmAnalysisFlags.sanitizeParentheses] = sanitizeParentheses
|
||||
result[JvmAnalysisFlags.suppressMissingBuiltinsError] = suppressMissingBuiltinsError
|
||||
result[JvmAnalysisFlags.enableJvmPreview] = enableJvmPreview
|
||||
result[AnalysisFlags.allowUnstableDependencies] = allowUnstableDependencies || useK2 || languageVersion.usesK2
|
||||
result[AnalysisFlags.allowUnstableDependencies] = allowUnstableDependencies
|
||||
result[JvmAnalysisFlags.disableUltraLightClasses] = disableUltraLightClasses
|
||||
result[JvmAnalysisFlags.useIR] = !useOldBackend
|
||||
return result
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ object FirDiagnosticsCompilerResultsReporter {
|
||||
AnalyzerWithCompilerReport.reportSpecialErrors(
|
||||
diagnosticsCollector.diagnostics.any { it.factory == FirErrors.INCOMPATIBLE_CLASS },
|
||||
diagnosticsCollector.diagnostics.any { it.factory == FirErrors.PRE_RELEASE_CLASS },
|
||||
hasUnstableClasses = false, // TODO (KT-61598): report IR_WITH_UNSTABLE_ABI_COMPILED_CLASS
|
||||
diagnosticsCollector.diagnostics.any { it.factory == FirErrors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS },
|
||||
messageCollector,
|
||||
)
|
||||
}
|
||||
|
||||
+3
-1
@@ -1751,8 +1751,10 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
||||
val PRE_RELEASE_CLASS by error<PsiElement> {
|
||||
parameter<String>("presentableString")
|
||||
}
|
||||
val IR_WITH_UNSTABLE_ABI_COMPILED_CLASS by error<PsiElement> {
|
||||
parameter<String>("presentableString")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private val exposedVisibilityDiagnosticInit: DiagnosticBuilder.() -> Unit = {
|
||||
|
||||
@@ -867,6 +867,7 @@ object FirErrors {
|
||||
// Compatibility issues
|
||||
val INCOMPATIBLE_CLASS by error2<PsiElement, String, IncompatibleVersionErrorData<*>>()
|
||||
val PRE_RELEASE_CLASS by error1<PsiElement, String>()
|
||||
val IR_WITH_UNSTABLE_ABI_COMPILED_CLASS by error1<PsiElement, String>()
|
||||
|
||||
init {
|
||||
RootDiagnosticRendererFactory.registerFactory(FirErrorsDefaultMessages)
|
||||
|
||||
+1
@@ -569,6 +569,7 @@ val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set<String> = setOf(
|
||||
"MIXING_FUNCTIONAL_KINDS_IN_SUPERTYPES",
|
||||
"INCOMPATIBLE_CLASS",
|
||||
"PRE_RELEASE_CLASS",
|
||||
"IR_WITH_UNSTABLE_ABI_COMPILED_CLASS",
|
||||
"OVERRIDE_CANNOT_BE_STATIC",
|
||||
"JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION",
|
||||
"JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION",
|
||||
|
||||
+4
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.types.toRegularClassSymbol
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerAbiStability
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
object FirIncompatibleClassExpressionChecker : FirQualifiedAccessExpressionChecker() {
|
||||
@@ -52,5 +53,8 @@ object FirIncompatibleClassExpressionChecker : FirQualifiedAccessExpressionCheck
|
||||
if (source.isPreReleaseInvisible) {
|
||||
reporter.reportOn(element.source, FirErrors.PRE_RELEASE_CLASS, source.presentableString, context)
|
||||
}
|
||||
if (source.abiStability == DeserializedContainerAbiStability.UNSTABLE) {
|
||||
reporter.reportOn(element.source, FirErrors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS, source.presentableString, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -343,6 +343,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVALID_TYPE_OF_A
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVISIBLE_REFERENCE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVISIBLE_SETTER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.IS_ENUM_ENTRY
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ITERATOR_AMBIGUITY
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ITERATOR_MISSING
|
||||
@@ -2546,7 +2547,10 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
"{0} is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler",
|
||||
STRING
|
||||
)
|
||||
map.put(
|
||||
IR_WITH_UNSTABLE_ABI_COMPILED_CLASS,
|
||||
"{0} is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler.",
|
||||
STRING
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+8
-1
@@ -1 +1,8 @@
|
||||
OK
|
||||
error: classes compiled by an unstable version of the Kotlin compiler were found in dependencies. Remove them from the classpath or use '-Xallow-unstable-dependencies' to suppress errors
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/source.kt:4:5: error: class 'lib.AKt' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler.
|
||||
get { Box("OK").value }
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/againstFirWithUnstableAbi/source.kt:4:11: error: class 'lib.Box' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler.
|
||||
get { Box("OK").value }
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
+8
-1
@@ -1 +1,8 @@
|
||||
OK
|
||||
error: classes compiled by an unstable version of the Kotlin compiler were found in dependencies. Remove them from the classpath or use '-Xallow-unstable-dependencies' to suppress errors
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/source.kt:4:5: error: class 'lib.AKt' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler.
|
||||
get { Box("OK").value }
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/againstUnstable/source.kt:4:11: error: class 'lib.Box' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler.
|
||||
get { Box("OK").value }
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
Reference in New Issue
Block a user