attempt at addjustment
failed, because as fucks up our structure anyways by putting evertthing
in one scope
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 0dabf9b..4249ed3 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -32,5 +32,6 @@
</component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
+ <mapping directory="$PROJECT_DIR$/kotlin-ultimate" vcs="Git" />
</component>
</project>
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt
index e6aff57..7145b83 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt
@@ -229,8 +229,8 @@
) {
val compatibility = implementedModules
.mapNotNull { ExpectedActualResolver.findExpectedForActual(descriptor, it) }
- .ifEmpty { return }
.foldMaps()
+ .ifEmpty { return }
checkAmbiguousExpects(compatibility, trace, reportOn, descriptor)
diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/utils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/utils.kt
index 2d8d5ed..a971108 100644
--- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/utils.kt
+++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/utils.kt
@@ -14,22 +14,17 @@
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
-import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
-import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor
// TODO: Klibs still need to better handle source in deserialized descriptors.
-internal val DeclarationDescriptorWithSource.couldHaveASource: Boolean
- get() =
- this.source.containingFile != SourceFile.NO_SOURCE_FILE ||
- this is DeserializedMemberDescriptor ||
- this is DeserializedClassDescriptor
+val DeclarationDescriptorWithSource.couldHaveASource: Boolean
+ get() = this.source.containingFile != SourceFile.NO_SOURCE_FILE || this is DeserializedDescriptor
internal fun CallableMemberDescriptor.findNamesakesFromModule(
module: PackageMemberScopeProvider
): Collection<CallableMemberDescriptor> {
val scopes = when (val containingDeclaration = containingDeclaration) {
is PackageFragmentDescriptor -> {
- listOf(module.getPackageWithoutDependencies(containingDeclaration.fqName).memberScope)
+ listOf(module.getPackageScopeWithoutDependencies(containingDeclaration.fqName))
}
is ClassDescriptor -> {
val classes = containingDeclaration.findClassifiersFromModule(module)
@@ -72,9 +67,9 @@
val segments = classId.relativeClassName.pathSegments()
val scope = if (includeDependencies)
- module.getPackage(classId.packageFqName).memberScope
+ module.getPackageScope(classId.packageFqName)
else
- module.getPackageWithoutDependencies(classId.packageFqName).memberScope
+ module.getPackageScopeWithoutDependencies(classId.packageFqName)
var classifiers = scope.getAllClassifiers(segments.first())
diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java
index 3860418..0ba5ed1 100644
--- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java
+++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java
@@ -109,6 +109,18 @@
@NotNull
@Override
+ public MemberScope getPackageScope(@NotNull FqName fqName) {
+ throw new IllegalStateException("Should not be called!");
+ }
+
+ @NotNull
+ @Override
+ public MemberScope getPackageScopeWithoutDependencies(@NotNull FqName fqName) {
+ throw new IllegalStateException("Should not be called!");
+ }
+
+ @NotNull
+ @Override
public List<ModuleDescriptor> getAllDependencyModules() {
return emptyList();
}
diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaModuleStructureOracle.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaModuleStructureOracle.kt
index 022ab3b..d7e58d1 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaModuleStructureOracle.kt
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/IdeaModuleStructureOracle.kt
@@ -93,10 +93,6 @@
}
return ModulePath(scopesInPath)
}
-
- private fun ModuleInfo.hackAndroidModules(): ModuleInfo {
-
- }
}
private val ModuleDescriptor.moduleInfo: ModuleInfo?
diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinMPPGradleProjectResolver.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinMPPGradleProjectResolver.kt
index 3f98a72..dcb1786 100644
--- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinMPPGradleProjectResolver.kt
+++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinMPPGradleProjectResolver.kt
@@ -112,6 +112,7 @@
val projectDataNode = ideModule.getDataNode(ProjectKeys.PROJECT)!!
val moduleOutputsMap = projectDataNode.getUserData(MODULES_OUTPUTS)!!
val outputDirs = HashSet<String>()
+
processCompilations(gradleModule, mppModel, ideModule, resolverCtx) { dataNode, compilation ->
var gradleOutputMap = dataNode.getUserData(GradleProjectResolver.GRADLE_OUTPUTS)
if (gradleOutputMap == null) {
@@ -189,6 +190,8 @@
Key.create<MutableMap<String/* artifact path */, MutableList<String> /* module ids*/>>("gradleMPPArtifactsMap")
val proxyObjectCloningCache = WeakHashMap<Any, Any>()
+ var dependsOnAdjustmentMap: Map<KotlinSourceSet, Collection<KotlinSourceSet>> = emptyMap()
+
private var nativeDebugAdvertised = false
private val androidPluginPresent = PluginManager.getPlugin(PluginId.findId("org.jetbrains.android"))?.isEnabled ?: false
@@ -303,10 +306,13 @@
val sourceSetMap = projectDataNode.getUserData(GradleProjectResolver.RESOLVED_SOURCE_SETS)!!
val sourceSetToRunTasks = calculateRunTasks(mppModel, gradleModule, resolverCtx)
+ dependsOnAdjustmentMap = calculateDependsOnAdjustmentsForAndroidSourceSetsInHmpp(mppModel)
val sourceSetToCompilationData = LinkedHashMap<String, MutableSet<GradleSourceSetData>>()
for (target in mppModel.targets) {
- if (delegateToAndroidPlugin(target)) continue
+ if (delegateToAndroidPlugin(target)) {
+ continue
+ }
if (target.name == KotlinTarget.METADATA_TARGET_NAME) continue
val targetData = KotlinTargetData(target.name).also {
it.archiveFile = target.jar?.archiveFile
@@ -507,6 +513,42 @@
return sourceSetToRunTasks
}
+ private fun calculateDependsOnAdjustmentsForAndroidSourceSetsInHmpp(
+ mppModel: KotlinMPPGradleModel
+ ): Map<KotlinSourceSet, Collection<KotlinSourceSet>> {
+ if (!mppModel.extraFeatures.isHMPPEnabled) return emptyMap()
+
+ val androidTarget = mppModel.targets.find { it.platform == KotlinPlatform.ANDROID } ?: return emptyMap()
+
+ val sourceSetsToCompilations: MutableMap<KotlinSourceSet, MutableSet<KotlinCompilation>> = mutableMapOf()
+ for (compilation in androidTarget.compilations) {
+ compilation.sourceSets.forEach {
+ sourceSetsToCompilations.getOrPut(it, { mutableSetOf() }) += compilation
+ }
+ }
+
+ // Stupid quadratic algorithm
+ val allPairsOfSourcesets: Collection<kotlin.Pair<KotlinSourceSet, KotlinSourceSet>> =
+ sourceSetsToCompilations.keys.flatMap { l -> sourceSetsToCompilations.keys.map { r -> l to r } }
+ val approximatedDependsOn: MutableMap<KotlinSourceSet, MutableSet<KotlinSourceSet>> = mutableMapOf()
+
+ for ((first, second) in allPairsOfSourcesets) {
+ if (first == second) continue
+
+ // null possible for orphan-source sets
+ val firstCompilations = sourceSetsToCompilations[first] ?: continue
+ val secondCompilations = sourceSetsToCompilations[second] ?: continue
+
+ if (firstCompilations.size > secondCompilations.size) continue // fast check sizes
+
+ if (secondCompilations.containsAll(firstCompilations)) {
+ approximatedDependsOn.getOrPut(first, { mutableSetOf() }) += second
+ }
+ }
+
+ return approximatedDependsOn
+ }
+
fun populateContentRoots(
gradleModule: IdeaModule,
ideModule: DataNode<ModuleData>,
@@ -1008,7 +1050,7 @@
sourceSetInfo.gradleModuleId = getModuleId(resolverCtx, gradleModule)
sourceSetInfo.actualPlatforms.addSimplePlatforms(listOf(compilation.platform))
sourceSetInfo.isTestModule = compilation.isTestModule
- sourceSetInfo.dependsOn = compilation.sourceSets.flatMap { it.dependsOnSourceSets }.map {
+ sourceSetInfo.dependsOn = compilation.sourceSets.flatMap { it.dependsOnWithAdjustmentIfNeeded() }.map {
getGradleModuleQualifiedName(resolverCtx, gradleModule, it)
}.distinct().toList()
sourceSetInfo.compilerArguments =
@@ -1022,6 +1064,13 @@
}
}
+ private fun KotlinSourceSet.dependsOnWithAdjustmentIfNeeded(): Collection<String> {
+ // No adjustment for non-android source sets
+ if (actualPlatforms.getSinglePlatform() != KotlinPlatform.ANDROID) return dependsOnSourceSets
+
+ return dependsOnAdjustmentMap[this]?.map { it.name } ?: dependsOnSourceSets
+ }
+
/** Checks if our IDE doesn't support such platform */
private fun KotlinPlatform.isNotSupported() = IdePlatformKindTooling.getToolingIfAny(this) == null