More accurate handling of Elvis in areParenthesesNecessary #KT-15227 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-12-19 21:01:39 +03:00
parent 6d6a16f399
commit ee1b741e84
5 changed files with 36 additions and 1 deletions
@@ -503,7 +503,10 @@ public class KtPsiUtil {
if (parentElement instanceof KtLabeledExpression) return false;
// 'x ?: ...' case
if (parentElement instanceof KtBinaryExpression && parentOperation == KtTokens.ELVIS && currentInner == ((KtBinaryExpression) parentElement).getRight()) {
if (parentElement instanceof KtBinaryExpression &&
parentOperation == KtTokens.ELVIS &&
!(innerExpression instanceof KtBinaryExpression) &&
currentInner == ((KtBinaryExpression) parentElement).getRight()) {
return false;
}