Support for conditional access calls

This commit is contained in:
Brian Norman
2020-02-07 17:22:09 -06:00
parent 2ff6d92601
commit 3f9f1faf17
2 changed files with 23 additions and 1 deletions
@@ -149,7 +149,9 @@ fun buildAssertTree(expression: IrExpression): RootNode {
}
}
else -> {
super.visitWhen(expression, data)
// Add as basic expression and terminate
// TODO this has to be broken and not work in all cases...
ExpressionNode(data)
}
}
}
@@ -196,6 +196,26 @@ assert(text == null || (text.length == 5 && text.toLowerCase() == text))
| | Hello
| false
Hello
""".trimIndent()
)
}
@Test
fun conditionalAccess() {
assertMessage(
"""
fun main() {
val text: String? = "Hello"
assert(text?.length?.minus(2) == 1)
}""",
"""
Assertion failed
assert(text?.length?.minus(2) == 1)
| | | |
| | | false
| | 3
| 5
Hello
""".trimIndent()
)
}