Light classes: use JVM target from the module

Using "JVM_1_8" always resulted in incorrect mapping of Kotlin
annotation targets to Java element types.

The change in AbstractKotlinRenderLogTest is needed because while
CliTraceHolder.module is technically a descriptor leak, it was never
detected by this test accidentally, because of the depth cutoff equal to
10, which started to not be enough after the minor refactoring of
replacing `Delegates.notNull` with `lateinit`.
This commit is contained in:
Alexander Udalov
2021-01-25 18:59:38 +01:00
parent 64e97225b8
commit adfa8c788c
24 changed files with 234 additions and 92 deletions
@@ -25,6 +25,7 @@ import com.intellij.psi.impl.java.stubs.PsiJavaFileStub
import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtFile
@@ -53,6 +54,7 @@ fun buildLightClass(
context.languageVersionSettings?.let {
CompilerConfiguration().apply {
languageVersionSettings = it
put(JVMConfigurationKeys.JVM_TARGET, context.jvmTarget)
isReadOnly = true
}
} ?: CompilerConfiguration.EMPTY
@@ -16,12 +16,14 @@
package org.jetbrains.kotlin.asJava.builder
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.resolve.BindingContext
open class LightClassConstructionContext(
val bindingContext: BindingContext,
val module: ModuleDescriptor,
val languageVersionSettings: LanguageVersionSettings? = null
)
val bindingContext: BindingContext,
val module: ModuleDescriptor,
val languageVersionSettings: LanguageVersionSettings?,
val jvmTarget: JvmTarget,
)