Hopefully fixed EA-87200 - TCE: UtilsKt.tryChangeAndCheckErrors

#EA-87200 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-08-22 16:35:05 +03:00
parent 2d875e516e
commit f21f23744e
2 changed files with 5 additions and 3 deletions
@@ -247,6 +247,7 @@ private fun isExpressionTypeSupported(expression: KtExpression): Boolean {
private fun checkSmartCastsPreserved(loop: KtForExpression, matchResult: MatchResult): Boolean {
val bindingContext = loop.analyze(BodyResolveMode.FULL)
// we declare these keys locally to avoid possible race-condition problems if this code is executed in 2 threads simultaneously
val SMARTCAST_KEY = Key<ExplicitSmartCasts>("SMARTCAST_KEY")
val IMPLICIT_RECEIVER_SMARTCAST_KEY = Key<ImplicitSmartCasts>("IMPLICIT_RECEIVER_SMARTCAST")
@@ -228,9 +228,6 @@ fun canChangeLocalVariableType(variable: KtProperty, newTypeText: String, loop:
}
}
private val EXPRESSION = Key<Unit>("EXPRESSION")
private val SCOPE_TO_EXCLUDE = Key<Unit>("SCOPE_TO_EXCLUDE")
fun <TExpression : KtExpression> tryChangeAndCheckErrors(
expressionToChange: TExpression,
scopeToExclude: KtElement,
@@ -244,6 +241,10 @@ fun <TExpression : KtExpression> tryChangeAndCheckErrors(
.firstOrNull { bindingContext[BindingContext.USED_AS_EXPRESSION, it] != true }
?: return true
// we declare these keys locally to avoid possible race-condition problems if this code is executed in 2 threads simultaneously
val EXPRESSION = Key<Unit>("EXPRESSION")
val SCOPE_TO_EXCLUDE = Key<Unit>("SCOPE_TO_EXCLUDE")
expressionToChange.putCopyableUserData(EXPRESSION, Unit)
scopeToExclude.putCopyableUserData(SCOPE_TO_EXCLUDE, Unit)