diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CommonPlatformKindResolution.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CommonPlatformKindResolution.kt index 3185aea2b97..afbbb35ed4f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CommonPlatformKindResolution.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CommonPlatformKindResolution.kt @@ -33,7 +33,7 @@ class CommonPlatformKindResolution : IdePlatformKindResolution { override val kind get() = CommonIdePlatformKind - override fun getKeyForBuiltIns(moduleInfo: ModuleInfo): BuiltInsCacheKey = BuiltInsCacheKey.DefaultBuiltInsKey + override fun getKeyForBuiltIns(moduleInfo: ModuleInfo, sdkInfo: SdkInfo?): BuiltInsCacheKey = BuiltInsCacheKey.DefaultBuiltInsKey override fun createBuiltIns(moduleInfo: ModuleInfo, projectContext: ProjectContext, sdkDependency: SdkInfo?): KotlinBuiltIns { return DefaultBuiltIns.Instance diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/IdePlatformKindResolution.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/IdePlatformKindResolution.kt index cd0dfcc5c94..b5cefcb18b8 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/IdePlatformKindResolution.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/IdePlatformKindResolution.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.storage.StorageManager interface IdePlatformKindResolution { val kind: IdePlatformKind<*> - fun getKeyForBuiltIns(moduleInfo: ModuleInfo): BuiltInsCacheKey + fun getKeyForBuiltIns(moduleInfo: ModuleInfo, sdkInfo: SdkInfo?): BuiltInsCacheKey fun createBuiltIns(moduleInfo: ModuleInfo, projectContext: ProjectContext, sdkDependency: SdkInfo?): KotlinBuiltIns fun createResolverForModuleFactory( diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JsPlatformKindResolution.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JsPlatformKindResolution.kt index 72e407b7b5a..085a1229ea1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JsPlatformKindResolution.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JsPlatformKindResolution.kt @@ -31,7 +31,7 @@ class JsPlatformKindResolution : IdePlatformKindResolution { override val kind get() = JsIdePlatformKind - override fun getKeyForBuiltIns(moduleInfo: ModuleInfo): BuiltInsCacheKey { + override fun getKeyForBuiltIns(moduleInfo: ModuleInfo, sdkInfo: SdkInfo?): BuiltInsCacheKey { return BuiltInsCacheKey.DefaultBuiltInsKey } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JvmPlatformKindResolution.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JvmPlatformKindResolution.kt index 3a29633f236..e61c9c42bd9 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JvmPlatformKindResolution.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/JvmPlatformKindResolution.kt @@ -42,8 +42,7 @@ class JvmPlatformKindResolution : IdePlatformKindResolution { override val kind get() = JvmIdePlatformKind - override fun getKeyForBuiltIns(moduleInfo: ModuleInfo): BuiltInsCacheKey { - val sdkInfo = moduleInfo.findSdkAcrossDependencies() + override fun getKeyForBuiltIns(moduleInfo: ModuleInfo, sdkInfo: SdkInfo?): BuiltInsCacheKey { return if (sdkInfo != null) CacheKeyBySdk(sdkInfo.sdk) else BuiltInsCacheKey.DefaultBuiltInsKey } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaResolverForProject.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaResolverForProject.kt index 65467d6b7f2..a3a7981f6d8 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaResolverForProject.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaResolverForProject.kt @@ -123,13 +123,14 @@ class IdeaResolverForProject( private val cache = mutableMapOf() fun getOrCreateIfNeeded(module: IdeaModuleInfo): KotlinBuiltIns = projectContextFromSdkResolver.storageManager.compute { - val key = module.platform.idePlatformKind.resolution.getKeyForBuiltIns(module) + val sdk = resolverForSdk.sdkDependency(module) + + val key = module.platform.idePlatformKind.resolution.getKeyForBuiltIns(module, sdk) val cachedBuiltIns = cache[key] if (cachedBuiltIns != null) return@compute cachedBuiltIns // Note #1: we can't use .getOrPut, because we have to put builtIns into map *before* initialization // Note #2: it's OK to put not-initialized built-ins into public map, because access to [cache] is guarded by storageManager.lock - val sdk = resolverForSdk.sdkDependency(module) val newBuiltIns = module.platform.idePlatformKind.resolution.createBuiltIns(module, projectContextFromSdkResolver, sdk) cache[key] = newBuiltIns diff --git a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt index 410878a9c4a..3dd3ec42706 100644 --- a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativePlatformKindResolution.kt @@ -132,7 +132,7 @@ class NativePlatformKindResolution : IdePlatformKindResolution { override val kind get() = NativeIdePlatformKind - override fun getKeyForBuiltIns(moduleInfo: ModuleInfo): BuiltInsCacheKey = NativeBuiltInsCacheKey + override fun getKeyForBuiltIns(moduleInfo: ModuleInfo, sdkInfo: SdkInfo?): BuiltInsCacheKey = NativeBuiltInsCacheKey override fun createBuiltIns(moduleInfo: ModuleInfo, projectContext: ProjectContext, sdkDependency: SdkInfo?) = createKotlinNativeBuiltIns(moduleInfo, projectContext)