diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropPropagatedDependencies.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropPropagatedDependencies.kt index 670fd06557b..4af64a9a2a5 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropPropagatedDependencies.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CInteropPropagatedDependencies.kt @@ -67,9 +67,11 @@ private fun Project.getPropagatedCInteropDependenciesOrEmpty(sourceSet: DefaultK /* Participating in multiple compilations? -> can't propagate -> should be commonized */ val compilation = compilations.singleOrNull() as? KotlinNativeCompilation ?: return@files emptySet() - /* Source Set is directly included in compilation -> No need to add dependency again (will be handled already) */ - if (sourceSet in compilation.kotlinSourceSets) return@files emptySet() - getAllCInteropOutputFiles(compilation) + (compilation.associateWith + compilation) + .filterIsInstance() + /* Source Set is directly included in compilation -> No need to add dependency again (will be handled already) */ + .filter { relevantCompilation -> sourceSet !in relevantCompilation.kotlinSourceSets } + .map { relevantCompilation -> getAllCInteropOutputFiles(relevantCompilation) } } }