From 98106d300cbceb0e5c60992cc5d388f6b227617e Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 27 Feb 2020 17:36:00 +0300 Subject: [PATCH] Don't show IR_COMPILED_CLASS error in IJ when it arises in module with backend IR enabled The problem here is that library resolver uses global project compiler settings instead of the module ones. That behaviour is caused by more global problem described in #KT-21246 As a temporary solution we just do not show IR_COMPILED_CLASS error in IDE if it arises in a module which have -XuseIR or -Xallow-jvm-ir-dependencies option provided #KT-36907 fixed Original commit: 97e320b57f15c6b8e6c5e835127bfd423c22a3b9 --- .../kotlin/config/KotlinFacetSettings.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt index 93df5bc43ad..c11fbd99dfa 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.config import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.cli.common.arguments.Argument import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.copyBean import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments @@ -18,6 +19,9 @@ import org.jetbrains.kotlin.platform.compat.toIdePlatform import org.jetbrains.kotlin.platform.isCommon import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.utils.DescriptionAware +import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import kotlin.reflect.KProperty1 +import kotlin.reflect.full.findAnnotation @Deprecated("Use IdePlatformKind instead.", level = DeprecationLevel.ERROR) sealed class TargetPlatformKind( @@ -188,6 +192,20 @@ class KotlinFacetSettings { updateMergedArguments() } + /* + This function is needed as some setting values may not be present in compilerArguments + but present in additional arguments instead, so we have to check both cases manually + */ + inline fun isCompilerSettingPresent(settingReference: KProperty1): Boolean { + val isEnabledByCompilerArgument = compilerArguments?.safeAs()?.let(settingReference::get) + if (isEnabledByCompilerArgument == true) return true + val isEnabledByAdditionalSettings = run { + val stringArgumentName = settingReference.findAnnotation()?.value ?: return@run null + compilerSettings?.additionalArguments?.contains(stringArgumentName, ignoreCase = true) + } + return isEnabledByAdditionalSettings ?: false + } + var languageLevel: LanguageVersion? get() = compilerArguments?.languageVersion?.let { LanguageVersion.fromFullVersionString(it) } set(value) {