Add new metadata flag for class files compiled with FIR

Report a separate error when class files compiled with FIR are in
dependencies, in addition to the one for class files compiled with FE
1.0 + JVM IR.

 #KT-43592
This commit is contained in:
Alexander Udalov
2020-12-07 21:26:23 +01:00
parent cbd90c3af5
commit 3f517d7e8d
16 changed files with 74 additions and 37 deletions
@@ -192,7 +192,7 @@ private class ElementAnnotator(
val factory = diagnostic.factory
// hack till the root cause #KT-21246 is fixed
if (isIrCompileClassDiagnosticForModulesWithEnabledIR(diagnostic)) return
if (isUnstableAbiClassDiagnosticForModulesWithEnabledUnstableAbi(diagnostic)) return
assert(diagnostics.all { it.psiElement == element && it.factory == factory })
@@ -272,16 +272,18 @@ private class ElementAnnotator(
data.processDiagnostics(holder, diagnostics, fixesMap)
}
private fun isIrCompileClassDiagnosticForModulesWithEnabledIR(diagnostic: Diagnostic): Boolean {
if (diagnostic.factory != Errors.IR_COMPILED_CLASS) return false
private fun isUnstableAbiClassDiagnosticForModulesWithEnabledUnstableAbi(diagnostic: Diagnostic): Boolean {
val setting = when (diagnostic.factory) {
Errors.IR_COMPILED_CLASS -> K2JVMCompilerArguments::useIR
Errors.FIR_COMPILED_CLASS -> K2JVMCompilerArguments::useFir
else -> return false
}
val module = element.module ?: return false
val moduleFacetSettings = KotlinFacetSettingsProvider.getInstance(element.project)?.getSettings(module) ?: return false
return moduleFacetSettings.isCompilerSettingPresent(K2JVMCompilerArguments::useIR)
|| moduleFacetSettings.isCompilerSettingPresent(K2JVMCompilerArguments::allowJvmIrDependencies)
return moduleFacetSettings.isCompilerSettingPresent(setting)
}
companion object {
val LOG = Logger.getInstance(ElementAnnotator::class.java)
}
}