diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt index 0cd63de8f83..ce40352d173 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinIntentionActionFactoryWithDelegate.kt @@ -68,7 +68,7 @@ abstract class KotlinIntentionActionFactoryWithDelegate // Cache data so that it can be shared between quick fixes bound to the same element & diagnostic // Cache null values - var cachedData: Ref? = null + val cachedData: Ref = Ref.create(extractFixData(originalElement, diagnostic)) val actions: List = try { createFixes(originalElementPointer, diagnostic) factory@ { val element = originalElementPointer.element ?: return@factory null @@ -80,14 +80,12 @@ abstract class KotlinIntentionActionFactoryWithDelegate .diagnostics .forElement(diagnosticElement) .firstOrNull { DefaultErrorMessages.render(it) == diagnosticMessage } ?: return@factory null - if (cachedData == null) { - cachedData = Ref(extractFixData(element, currentDiagnostic)) - } - cachedData!!.get() + + cachedData.get() ?: extractFixData(element, currentDiagnostic) }.filter { it.isAvailable(project, null, file) } } finally { - cachedData = null // Do not keep cache after all actions are initialized + cachedData.set(null) // Do not keep cache after all actions are initialized } return actions