Freezable.{frozen, unfrozen} refactoring: add type safety
This commit is contained in:
@@ -40,8 +40,10 @@ abstract class Freezable {
|
|||||||
|
|
||||||
private var frozen: Boolean = false
|
private var frozen: Boolean = false
|
||||||
|
|
||||||
private fun getInstanceWithFreezeStatus(value: Boolean) = if (value == frozen) this else copyBean(this).apply { frozen = value }
|
internal fun getInstanceWithFreezeStatus(value: Boolean) = if (value == frozen) this else copyBean(this).apply { frozen = value }
|
||||||
|
|
||||||
fun frozen() = getInstanceWithFreezeStatus(true)
|
|
||||||
fun unfrozen() = getInstanceWithFreezeStatus(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun <T : Freezable> T.frozen(): T = getInstanceWithFreezeStatus(true) as T
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun <T : Freezable> T.unfrozen(): T = getInstanceWithFreezeStatus(false) as T
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.config
|
|||||||
|
|
||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.Argument
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.copyBean
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
|
||||||
import org.jetbrains.kotlin.platform.IdePlatformKind
|
import org.jetbrains.kotlin.platform.IdePlatformKind
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
||||||
@@ -184,13 +181,13 @@ class KotlinFacetSettings {
|
|||||||
|
|
||||||
var compilerArguments: CommonCompilerArguments? = null
|
var compilerArguments: CommonCompilerArguments? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value?.unfrozen() as CommonCompilerArguments?
|
field = value?.unfrozen()
|
||||||
updateMergedArguments()
|
updateMergedArguments()
|
||||||
}
|
}
|
||||||
|
|
||||||
var compilerSettings: CompilerSettings? = null
|
var compilerSettings: CompilerSettings? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value?.unfrozen() as CompilerSettings?
|
field = value?.unfrozen()
|
||||||
updateMergedArguments()
|
updateMergedArguments()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user