Partial body resolve: fixed for ! and parenthesis in conditions
This commit is contained in:
@@ -319,6 +319,18 @@ class PartialBodyResolveFilter(
|
||||
val cast = condition.getLeftHandSide().smartCastExpressionName().singletonOrEmptySet()
|
||||
return if (condition.isNegated()) Pair(setOf(), cast) else Pair(cast, setOf())
|
||||
}
|
||||
|
||||
is JetPrefixExpression -> {
|
||||
if (condition.getOperationToken() == JetTokens.EXCL) {
|
||||
val operand = condition.getBaseExpression() ?: return emptyResult
|
||||
return possiblySmartCastInCondition(operand).swap()
|
||||
}
|
||||
}
|
||||
|
||||
is JetParenthesizedExpression -> {
|
||||
val operand = condition.getExpression() ?: return emptyResult
|
||||
return possiblySmartCastInCondition(operand)
|
||||
}
|
||||
}
|
||||
|
||||
return emptyResult
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Resolve target: value-parameter val p: kotlin.Any? smart-cast to kotlin.Any
|
||||
----------------------------------------------
|
||||
fun foo(p: Any?) {
|
||||
if (!(p != null)) return
|
||||
<caret>p.hashCode()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo(p: Any?) {
|
||||
if (!(p != null)) return
|
||||
<caret>p.hashCode()
|
||||
}
|
||||
@@ -144,6 +144,12 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("IfNegatedNotNullReturn.kt")
|
||||
public void testIfNegatedNotNullReturn() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNegatedNotNullReturn.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("IfNotIsError.kt")
|
||||
public void testIfNotIsError() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNotIsError.kt");
|
||||
|
||||
Reference in New Issue
Block a user