FIR IDE: use EntityWasGarbageCollectedException instead of ISE in ReadOnlyWeakRef

This commit is contained in:
Ilya Kirillov
2021-03-29 14:01:46 +02:00
parent d685e2aac7
commit d5951bc97d
2 changed files with 2 additions and 2 deletions
@@ -5,6 +5,6 @@
package org.jetbrains.kotlin.idea.frontend.api.fir.utils
internal class EntityWasGarbageCollectedException(entity: String) : IllegalStateException() {
class EntityWasGarbageCollectedException(entity: String) : IllegalStateException() {
override val message: String = "$entity was garbage collected while KtAnalysisSession session is still valid"
}
@@ -18,7 +18,7 @@ constructor(value: V, val token: ValidityToken) {
@Suppress("NOTHING_TO_INLINE")
inline operator fun getValue(thisRef: Any, property: KProperty<*>): V =
weakRef.get() ?: if (token.isValid()) {
error("Value of $property was garbage collected while analysis session is still valid")
throw EntityWasGarbageCollectedException(property.toString())
} else {
error("Accessing the invalid value of $property")
}