From 6faf3f1ebac783f8f183739f0521fb7c8c057fa5 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 11 Sep 2015 14:10:57 +0300 Subject: [PATCH] Fix deadlock in ReflectionAPICallChecker because of conflict in lazy() and storageManager --- .../jvm/calls/checkers/ReflectionAPICallChecker.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt index 88587a2a3cd..1533720f320 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt @@ -27,18 +27,20 @@ import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.NO_REFLECTION_IN_CLASS_PATH import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleDependencies +import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.expressions.OperatorConventions +import org.jetbrains.kotlin.storage.get /** * If there's no Kotlin reflection implementation found in the classpath, checks that there are no usages * of reflection API which will fail at runtime. */ -class ReflectionAPICallChecker(private val module: ModuleDescriptor) : CallChecker { - private val isReflectionAvailable by lazy { +class ReflectionAPICallChecker(private val module: ModuleDescriptor, storageManager: StorageManager) : CallChecker { + private val isReflectionAvailable by storageManager.createLazyValue { module.findClassAcrossModuleDependencies(JvmAbi.REFLECTION_FACTORY_IMPL) != null } - private val kPropertyClasses by lazy { + private val kPropertyClasses by storageManager.createLazyValue { val reflectionTypes = ReflectionTypes(module) setOf(reflectionTypes.kProperty0, reflectionTypes.kProperty1, reflectionTypes.kProperty2) }