Collect unique subtypes from incremental compilation cache
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
2f3ff10204
commit
599c5dd474
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.flattenTo
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
import kotlin.collections.LinkedHashSet
|
||||
|
||||
const val DELETE_MODULE_FILE_PROPERTY = "kotlin.delete.module.file.after.build"
|
||||
|
||||
@@ -218,16 +219,18 @@ fun withSubtypes(
|
||||
typeFqName: FqName,
|
||||
caches: Iterable<IncrementalCacheCommon>
|
||||
): Set<FqName> {
|
||||
val types = LinkedList(listOf(typeFqName))
|
||||
val types = LinkedHashSet(listOf(typeFqName))
|
||||
val subtypes = hashSetOf<FqName>()
|
||||
|
||||
while (types.isNotEmpty()) {
|
||||
val unprocessedType = types.pollFirst()
|
||||
val iterator = types.iterator()
|
||||
val unprocessedType = iterator.next()
|
||||
iterator.remove()
|
||||
|
||||
caches.asSequence()
|
||||
.flatMap { it.getSubtypesOf(unprocessedType) }
|
||||
.filter { it !in subtypes }
|
||||
.forEach { types.addLast(it) }
|
||||
.forEach { types.add(it) }
|
||||
|
||||
subtypes.add(unprocessedType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user