diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index 9915bc9a566..53d7e35b75c 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -742,18 +742,18 @@ private fun doProcessChangesUsingLookups( KotlinBuilder.LOG.debug("Start processing changes") - val changedSignatureFqNames = changes.filterIsInstance().map { it.fqName } - for (classFqName in withSubtypes(changedSignatureFqNames, caches)) { - val scope = classFqName.parent().asString() - val name = classFqName.shortName().identifier - dirtyLookupSymbols.add(LookupSymbol(name, scope)) - } + for (change in changes) { + if (change is ChangeInfo.SignatureChanged) { + for (classFqName in withSubtypes(change.fqName, caches)) { + val scope = classFqName.parent().asString() + val name = classFqName.shortName().identifier + dirtyLookupSymbols.add(LookupSymbol(name, scope)) + } + } + else if (change is ChangeInfo.MembersChanged) { + val scopes = withSubtypes(change.fqName, caches).map { it.asString() } - for (change in changes.filterIsInstance()) { - val scopes = withSubtypes(listOf(change.fqName), caches).map { it.asString() } - - for (name in change.names) { - for (scope in scopes) { + change.names.forAllPairs(scopes) { name, scope -> dirtyLookupSymbols.add(LookupSymbol(name, scope)) } } @@ -774,16 +774,22 @@ private fun doProcessChangesUsingLookups( } /** - * Gets subtypes of given types inclusively + * Returns type with its subtypes transitively + * + * For example: + * open class A + * open class B : A() + * class C : B() + * withSubtypes(A) will return [A, B, C] */ /* TODO: in case of chunk containing more than one target, depending targets would be asked about same subtype more than once. Can be solved by putting all caches in set */ private fun withSubtypes( - typeFqNames: Iterable, + typeFqName: FqName, caches: Collection ): Set { - val types = typeFqNames.toCollection(LinkedList()) + val types = linkedListOf(typeFqName) val subtypes = hashSetOf() while (types.isNotEmpty()) { @@ -915,6 +921,14 @@ class GeneratedJvmClass ( } } +private inline fun Iterable.forAllPairs(other: Iterable, fn: (T, R)->Unit) { + for (t in this) { + for (r in other) { + fn(t, r) + } + } +} + private inline fun Logger.debug(message: ()->String) { if (isDebugEnabled) { debug(message())