From 9e58e3c3fd1e80c2f0534477ae031860f3905044 Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Thu, 14 Jan 2021 11:52:28 +0300 Subject: [PATCH] Remove unused KotlinSourceSetImpl.defaultIsTestModule; simplify logic of test modules detection ^KT-37127 --- .../src/KotlinMPPGradleModelBuilder.kt | 11 +---------- .../src/KotlinMPPGradleModelImpl.kt | 10 +++++----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt b/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt index 520bf8f9ff9..d2431961b54 100644 --- a/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt +++ b/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt @@ -785,16 +785,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService { } } - // TODO DISCUSS AT REVIEW: can we simplify it to: - // sourceSet.isTestModule = importingContext.compilationsBySourceSet(sourceSet)?.all { it.isTestModule} ?: false - // ^ - // | - // sic! - // The difference from the current behaviour would be in case if source set is not included into any compilation AND - // KotlinSourceSetImpl.defaultIsTestModule is set to 'true'. Though I don't know who and why would do that. - importingContext.compilationsBySourceSet(sourceSet)?.all { it.isTestModule }?.let { isTest -> - sourceSet.isTestModule = isTest - } + sourceSet.isTestModule = importingContext.compilationsBySourceSet(sourceSet)?.all { it.isTestModule } ?: false importingContext.compilationsBySourceSet(sourceSet)?.let { compilations -> val platforms = compilations.map { it.platform } diff --git a/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelImpl.kt b/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelImpl.kt index 32b66df33b8..de3b3572f08 100644 --- a/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelImpl.kt +++ b/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelImpl.kt @@ -36,7 +36,6 @@ class KotlinSourceSetImpl( override val dependencies: Array, override val dependsOnSourceSets: Set, val defaultPlatform: KotlinPlatformContainerImpl = KotlinPlatformContainerImpl(), - val defaultIsTestModule: Boolean = false ) : KotlinSourceSet { constructor(kotlinSourceSet: KotlinSourceSet, cloningCache: MutableMap) : this( @@ -46,14 +45,15 @@ class KotlinSourceSetImpl( HashSet(kotlinSourceSet.resourceDirs), kotlinSourceSet.dependencies, HashSet(kotlinSourceSet.dependsOnSourceSets), - KotlinPlatformContainerImpl(kotlinSourceSet.actualPlatforms), - kotlinSourceSet.isTestModule - ) + KotlinPlatformContainerImpl(kotlinSourceSet.actualPlatforms) + ) { + this.isTestModule = kotlinSourceSet.isTestModule + } override var actualPlatforms: KotlinPlatformContainer = defaultPlatform internal set - override var isTestModule: Boolean = defaultIsTestModule + override var isTestModule: Boolean = false internal set override fun toString() = name