Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler spec type mismatch #4800

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal fun CliArgs.createSpec(output: Appendable, error: Appendable): Processi
}

compiler {
jvmTarget = args.jvmTarget.toString()
jvmTarget = args.jvmTarget
languageVersion = args.languageVersion?.versionString
classpath = args.classpath?.trim()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import io.github.detekt.tooling.api.spec.ProjectSpec
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.com.intellij.openapi.Disposable
import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageVersion
import java.io.Closeable
import java.io.File
Expand All @@ -33,7 +32,7 @@ internal class EnvironmentFacade(
projectSpec.inputPaths.toList(),
classpath,
compilerSpec.parseLanguageVersion(),
compilerSpec.parseJvmTarget()
compilerSpec.jvmTarget,
)
createKotlinCoreEnvironment(compilerConfiguration, disposable)
}
Expand All @@ -53,7 +52,3 @@ internal fun CompilerSpec.parseLanguageVersion(): LanguageVersion? {
}
return languageVersion?.let(::parse)
}

internal fun CompilerSpec.parseJvmTarget(): JvmTarget {
return checkNotNull(JvmTarget.fromString(jvmTarget)) { "Invalid value passed to --jvm-target" }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.detekt.tooling.api.spec

import org.jetbrains.kotlin.config.JvmTarget

/**
* All these properties are based down to the Kotlin compiler for type- and symbol resolution.
*/
Expand All @@ -8,7 +10,7 @@ interface CompilerSpec {
/**
* Target version for the generated JVM bytecode (e.g. 1.8, 9, 10, 11 ...).
*/
val jvmTarget: String
val jvmTarget: JvmTarget

/**
* Kotlin language version (e.g. 1.0, 1.1, 1.2, 1.3 ...).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package io.github.detekt.tooling.dsl

import io.github.detekt.tooling.api.spec.CompilerSpec
import org.jetbrains.kotlin.config.JvmTarget

@ProcessingModelDsl
class CompilerSpecBuilder : Builder<CompilerSpec> {

var jvmTarget: String = "1.8"
var jvmTarget: JvmTarget = JvmTarget.JVM_1_8
var languageVersion: String? = null
var classpath: String? = null

override fun build(): CompilerSpec = CompilerModel(jvmTarget, languageVersion, classpath)
}

private data class CompilerModel(
override val jvmTarget: String,
override val jvmTarget: JvmTarget,
override val languageVersion: String?,
override val classpath: String?
) : CompilerSpec