[FE] Add ability to set compatibility of plugin with K2 in ComponentRegistrar

This commit is contained in:
Dmitriy Novozhilov
2022-05-13 16:43:14 +03:00
committed by teamcity
parent 67589b1b09
commit 4003ca0691
4 changed files with 20 additions and 7 deletions
@@ -87,13 +87,17 @@ object FirKotlinToJvmBytecodeCompiler {
)
projectConfiguration.get(ComponentRegistrar.PLUGIN_COMPONENT_REGISTRARS)?.let { pluginComponentRegistrars ->
val nonScriptPlugins = pluginComponentRegistrars.filter {
it::class.java.canonicalName != CLICompiler.SCRIPT_PLUGIN_REGISTRAR_NAME
val notSupportedPlugins = pluginComponentRegistrars.filter {
!it.supportsK2 || it::class.java.canonicalName != CLICompiler.SCRIPT_PLUGIN_REGISTRAR_NAME
}
if (nonScriptPlugins.isNotEmpty()) {
if (notSupportedPlugins.isNotEmpty()) {
messageCollector.report(
CompilerMessageSeverity.ERROR,
"Compiler plugins are enabled with K2 compiler.\n K2 does not support plugins yet, so please remove -Xuse-k2 flag"
"""
|There are some plugins incompatible with K2 compiler:
|${notSupportedPlugins.joinToString(separator = "\n|") { " ${it::class.qualifiedName}" }}
|Please remove -Xuse-k2
""".trimMargin()
)
return false
}