KT-31553 Complete Statement: Wrong auto-insertion of closing curly brace for a code block (#2378)

* Complete statement: wrap property initializer by run/when block

#KT-31553 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-09-25 23:04:03 +09:00
committed by GitHub
parent 14bdcb1e26
commit 37ba9eccc4
13 changed files with 313 additions and 0 deletions
@@ -0,0 +1,15 @@
// WITH_RUNTIME
fun test(): Int = bar { <caret>foo()
fun foo() = 42
fun bar(f: () -> Int) = f()
//-----
// WITH_RUNTIME
fun test(): Int = bar {
<caret>foo()
}
fun foo() = 42
fun bar(f: () -> Int) = f()
@@ -0,0 +1,11 @@
// WITH_RUNTIME
fun test() {
val test = run { <caret>1
}
//-----
// WITH_RUNTIME
fun test() {
val test = run {
<caret>1
}
}
@@ -0,0 +1,19 @@
// WITH_RUNTIME
class Test {
val test = run {<caret>foo()
fun foo(): Int {
return 42
}
}
//-----
// WITH_RUNTIME
class Test {
val test = run {
<caret>foo()
}
fun foo(): Int {
return 42
}
}
@@ -0,0 +1,11 @@
// WITH_RUNTIME
val test = run {<caret>foo()
fun foo() = 42
//-----
// WITH_RUNTIME
val test = run {
<caret>foo()
}
fun foo() = 42
@@ -0,0 +1,14 @@
// WITH_RUNTIME
fun test(): Int = bar { f<caret>oo()
fun foo() = 42
fun bar(f: () -> Int) = f()
//-----
// WITH_RUNTIME
fun test(): Int = bar { f
<caret>oo()
fun foo() = 42
fun bar(f: () -> Int) = f()
@@ -0,0 +1,9 @@
fun test() {
val test = when { <caret>1
}
//-----
fun test() {
val test = when {
<caret>1
}
}
@@ -0,0 +1,17 @@
class Test {
val test = when {<caret>foo()
fun foo(): Int {
return 42
}
}
//-----
class Test {
val test = when {
<caret>foo()
}
fun foo(): Int {
return 42
}
}
@@ -0,0 +1,9 @@
val test = when {<caret>foo()
fun foo() = 42
//-----
val test = when {
<caret>foo()
}
fun foo() = 42