Minor, make Services#get return type nullable

This commit is contained in:
Alexander Udalov
2016-05-27 15:11:37 +03:00
parent 57849c9dfd
commit a95568eedf
2 changed files with 5 additions and 6 deletions
@@ -222,7 +222,6 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
) {
if (IncrementalCompilation.isEnabled()) {
val components = services.get(IncrementalCompilationComponents::class.java)
@Suppress("SENSELESS_COMPARISON")
if (components != null) {
configuration.put(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS, components)
}
@@ -16,20 +16,20 @@
package org.jetbrains.kotlin.config
import java.util.HashMap
import java.util.*
class Services private constructor(private val map: Map<Class<*>, Any>) {
companion object {
@JvmField val EMPTY: Services = Builder().build()
@JvmField
val EMPTY: Services = Builder().build()
}
fun <T> get(interfaceClass: Class<T>): T {
fun <T> get(interfaceClass: Class<T>): T? {
@Suppress("UNCHECKED_CAST")
return map.get(interfaceClass) as T
return map[interfaceClass] as T?
}
class Builder {
private val map = HashMap<Class<*>, Any>()
fun <T : Any> register(interfaceClass: Class<T>, implementation: T): Builder {