Use constantSdkDependencyIfAny in getKeyForSdk as well
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -123,13 +123,14 @@ class IdeaResolverForProject(
|
||||
private val cache = mutableMapOf<BuiltInsCacheKey, KotlinBuiltIns>()
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user