Fix some compiler warnings in FIR modules

This commit is contained in:
Alexander Udalov
2020-08-14 12:37:13 +02:00
parent ced151f3af
commit 549ee84687
24 changed files with 71 additions and 78 deletions
@@ -66,7 +66,7 @@ enum class ProcessorAction {
}
}
@Suppress("NOTHING_TO_INLINE")
inline fun FirScope.processClassifiersByName(
name: Name,
noinline processor: (FirClassifierSymbol<*>) -> Unit
@@ -7,36 +7,38 @@ package org.jetbrains.kotlin.fir.visitors
import org.jetbrains.kotlin.fir.FirElement
sealed class CompositeTransformResult<out T : Any>() {
sealed class CompositeTransformResult<out T : Any> {
class Single<out T : Any>(val _single: T) : CompositeTransformResult<T>()
class Multiple<out T : Any>(val _list: List<T>) : CompositeTransformResult<T>()
companion object {
fun <T : Any> empty() = CompositeTransformResult.Multiple<T>(emptyList<T>())
fun <T : Any> single(t: T) = CompositeTransformResult.Single(t)
fun <T : Any> many(l: List<T>) = CompositeTransformResult.Multiple(l)
fun <T : Any> empty() = Multiple(emptyList<T>())
fun <T : Any> single(t: T) = Single(t)
fun <T : Any> many(l: List<T>) = Multiple(l)
}
@Suppress("UNCHECKED_CAST")
val list: List<T>
get() = when (this) {
is CompositeTransformResult.Multiple<*> -> _list as List<T>
is Multiple<*> -> _list as List<T>
else -> error("!")
}
@Suppress("UNCHECKED_CAST")
val single: T
get() = when (this) {
is CompositeTransformResult.Single<*> -> _single as T
is Single<*> -> _single as T
else -> error("!")
}
val isSingle
get() = this is CompositeTransformResult.Single<*>
get() = this is Single<*>
val isEmpty
get() = this is CompositeTransformResult.Multiple<*> && this.list.isEmpty()
get() = this is Multiple<*> && this.list.isEmpty()
}
@Suppress("NOTHING_TO_INLINE")
@@ -69,7 +69,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
}
println("(")
withIndent {
fieldsWithoutDefault.forEachIndexed { i, field ->
fieldsWithoutDefault.forEachIndexed { _, field ->
printField(field, isImplementation = true, override = true, end = ",")
}
}
@@ -52,9 +52,11 @@ private fun updateKinds(solution: List<Boolean>, elementMapping: ElementMapping)
val element = elementMapping[index * 2].origin
val existingKind = element.kind
if (isClass) {
when (existingKind) {
Implementation.Kind.Interface -> throw IllegalStateException(element.toString())
null -> element.kind = when (element) {
if (existingKind == Implementation.Kind.Interface)
throw IllegalStateException(element.toString())
if (existingKind == null) {
element.kind = when (element) {
is Implementation -> {
if (elementMapping.hasInheritors(element))
Implementation.Kind.AbstractClass