Extracted 'deparenthesizeArgument', used it where necessary

#KT-6176 Fixed
This commit is contained in:
Svetlana Isakova
2014-11-10 17:05:25 +03:00
parent e2826a47e1
commit 8ad017c071
12 changed files with 574 additions and 33 deletions
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
fun <R> foo(f: () -> R): R = f()
fun <T : Any> some(v: T?, b: T): T {
return foo {
if (v != null) {
v
}
else {
b
}
}
}
fun <T : Any> some1(v: T?, b: T): T {
return foo { if (v != null) v else b }
}
fun box() = when {
some(1, 2) != 1 -> "fail 1"
some(null, 2) != 2 -> "fail 2"
some1(1, 2) != 1 -> "fail 3"
else -> "OK"
}