Partial body resolve correctly handles elvis operator
This commit is contained in:
@@ -157,8 +157,9 @@ class PartialBodyResolveFilter(
|
||||
}
|
||||
|
||||
fun addPlaces(name: SmartCastName, places: Collection<JetExpression>) {
|
||||
assert(!places.isEmpty())
|
||||
map.getOrPut(name, { ArrayList(places.size()) }).addAll(places)
|
||||
if (places.isNotEmpty()) {
|
||||
map.getOrPut(name, { ArrayList(places.size()) }).addAll(places)
|
||||
}
|
||||
}
|
||||
|
||||
fun addIfCanBeSmartCast(expression: JetExpression) {
|
||||
@@ -185,6 +186,22 @@ class PartialBodyResolveFilter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitBinaryExpression(expression: JetBinaryExpression) {
|
||||
expression.acceptChildren(this)
|
||||
|
||||
if (expression.getOperationToken() == JetTokens.ELVIS) {
|
||||
val left = expression.getLeft()
|
||||
val right = expression.getRight()
|
||||
if (left != null && right != null) {
|
||||
val smartCastName = left.smartCastExpressionName()
|
||||
if (smartCastName != null && filter(smartCastName)) {
|
||||
val exits = collectAlwaysExitPoints(right)
|
||||
addPlaces(smartCastName, exits)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitIfExpression(expression: JetIfExpression) {
|
||||
val condition = expression.getCondition()
|
||||
val thenBranch = expression.getThen()
|
||||
|
||||
Reference in New Issue
Block a user