Do not force new line in body for empty functions and function expressions (KT-10828)

#KT-10828 Fixed
This commit is contained in:
Nikolay Krasko
2016-12-06 16:39:17 +03:00
committed by Nikolay Krasko
parent 268d55104c
commit 2841931ffa
130 changed files with 334 additions and 575 deletions
+1 -2
View File
@@ -27,6 +27,5 @@ internal class C {
@Deprecated("") @Anon5(3) val c = 'a'
}
@Anon5(1) fun bar() {
}
@Anon5(1) fun bar() {}
}
@@ -3,8 +3,7 @@
package test
internal class Foo {
fun execute() {
}
fun execute() {}
}
internal class Bar {
+1 -2
View File
@@ -1,2 +1 @@
fun fromArrayToCollection(a: Array<Foo>) {
}
fun fromArrayToCollection(a: Array<Foo>) {}
@@ -1,6 +1,5 @@
internal object Library {
fun call() {
}
fun call() {}
val string: String
get() = ""
@@ -1,8 +1,7 @@
// !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true
internal class Library {
fun call() {
}
fun call() {}
val string: String?
get() = ""
@@ -1,6 +1,5 @@
internal class Library {
fun call() {
}
fun call() {}
val string: String
get() = ""
+3 -8
View File
@@ -1,10 +1,5 @@
internal class T {
fun main() {
}
fun i(): Int {
}
fun s(): String {
}
fun main() {}
fun i(): Int {}
fun s(): String {}
}
+2 -5
View File
@@ -5,11 +5,8 @@ package demo
import java.util.HashMap
internal class Test {
constructor() {
}
constructor(s: String) {
}
constructor() {}
constructor(s: String) {}
}
internal class User {
+2 -3
View File
@@ -5,6 +5,5 @@ internal open class Base {
}
internal class Derived : Base() {
fun foo() {
}
}
fun foo() {}
}
+1 -2
View File
@@ -1,4 +1,3 @@
class MyClass {
private fun init(arg1: Int, arg2: Int, arg3: Int) {
}
private fun init(arg1: Int, arg2: Int, arg3: Int) {}
}
+3 -6
View File
@@ -1,9 +1,6 @@
internal object Util {
fun util1() {
}
fun util2() {
}
fun util1() {}
fun util2() {}
val CONSTANT = 10
}
}
+2 -5
View File
@@ -1,10 +1,7 @@
internal object Util {
fun util1() {
}
fun util2() {
}
fun util1() {}
fun util2() {}
val CONSTANT = 10
}
+2 -5
View File
@@ -1,9 +1,6 @@
internal object Util {
fun util1() {
}
fun util2() {
}
fun util1() {}
fun util2() {}
val CONSTANT = 10
}
+2 -4
View File
@@ -14,11 +14,9 @@ internal class A {
private /*it's private*/ val field = 0
/*it's public*/ fun foo(s: String): Char {
}
/*it's public*/ fun foo(s: String): Char {}
protected /*it's protected*/ fun foo(c: Char) {
}
protected /*it's protected*/ fun foo(c: Char) {}
companion object {
@@ -16,8 +16,7 @@ internal class B// this constructor will disappear
(private val x: Int) // end of constructor body
{
fun foo() {
}
fun foo() {}
}
internal class CtorComment {
+2 -5
View File
@@ -7,11 +7,8 @@ internal class Customer(val firstName: String, val lastName: String) {
doSmthAfter()
}
private fun doSmthBefore() {
}
private fun doSmthAfter() {
}
private fun doSmthBefore() {}
private fun doSmthAfter() {}
}
internal class CustomerBuilder {
+1 -2
View File
@@ -1,8 +1,7 @@
internal open class Base
internal class C : Base {
constructor(arg1: Int, arg2: Int, arg3: Int) {
}
constructor(arg1: Int, arg2: Int, arg3: Int) {}
constructor(arg1: Int, arg2: Int) : this(arg1, arg2, 0) {
println()
@@ -2,6 +2,5 @@ package pack
internal class C @JvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
constructor(a: Int) : this(a, 0, 0, 0, 1) {
}
constructor(a: Int) : this(a, 0, 0, 0, 1) {}
}
@@ -2,9 +2,7 @@ package pack
internal class C @JvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
constructor(a1: Int, b1: Int, c1: Int) : this(a1, b1, c1, 0, 0) {
}
constructor(a1: Int, b1: Int, c1: Int) : this(a1, b1, c1, 0, 0) {}
constructor(b: Byte) : this(b.toInt(), 0, 0, 0, 0) {
}
constructor(b: Byte) : this(b.toInt(), 0, 0, 0, 0) {}
}
@@ -2,6 +2,5 @@ package pack
internal class C @JvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
constructor(a: Int, b: Int, c: Int) : this(b, a, c, 0, 0) {
}
constructor(a: Int, b: Int, c: Int) : this(b, a, c, 0, 0) {}
}
@@ -1,5 +1,4 @@
internal class C private constructor(arg1: Int, arg2: Int, arg3: Int = 0) {
constructor(arg1: Int) : this(arg1, 0, 0) {
}
constructor(arg1: Int) : this(arg1, 0, 0) {}
}
@@ -4,8 +4,7 @@ internal class A {
private val s = ""
private val x = 0
constructor() {
}
constructor() {}
@JvmOverloads constructor(p: Int, s: String, x: Int = 1) {
this.s = s
@@ -1,51 +1,39 @@
internal class Outer {
private inner class Inner1() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
protected inner class Inner2() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
internal inner class Inner3() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
inner class Inner4() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
fun foo() {
@@ -2,51 +2,39 @@
internal object Outer {
private class Nested1() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
protected class Nested2() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
internal class Nested3() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
class Nested4() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
private constructor(b: Boolean) : this() {
}
private constructor(b: Boolean) : this() {}
}
fun foo() {
@@ -1,29 +1,21 @@
internal class A() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
constructor(f: Float) : this() {
}
constructor(f: Float) : this() {}
private constructor(d: Double) : this() {
}
private constructor(d: Double) : this() {}
}
class B() {
constructor(a: Int) : this() {
}
constructor(a: Int) : this() {}
protected constructor(c: Char) : this() {
}
protected constructor(c: Char) : this() {}
internal constructor(f: Float) : this() {
}
internal constructor(f: Float) : this() {}
private constructor(d: Double) : this() {
}
private constructor(d: Double) : this() {}
}
@@ -9,8 +9,7 @@ class Test {
protected var f: Short = 0
protected var g: Char = ' '
constructor() {
}
constructor() {}
constructor(name: String) {
myName = foo(name)
+1 -2
View File
@@ -39,8 +39,7 @@ internal open class B {
set(value) {
}
open fun setFromB5(value: String) {
}
open fun setFromB5(value: String) {}
}
internal abstract class C(override val something1: Int) : B(), I {
+1 -2
View File
@@ -2,6 +2,5 @@
* [C.foo]
*/
internal class C {
fun foo(i: Int) {
}
fun foo(i: Int) {}
}
+1 -2
View File
@@ -2,6 +2,5 @@
* [the best foo method ever][C.foo]
*/
internal class C {
fun foo(i: Int) {
}
fun foo(i: Int) {}
}
+1 -2
View File
@@ -2,6 +2,5 @@
* @see C.foo
*/
internal class C {
fun foo(i: Int) {
}
fun foo(i: Int) {}
}
+2 -4
View File
@@ -2,10 +2,8 @@ enum class E {
A,
B {
override fun bar() {
}
override fun bar() {}
};
internal open fun bar() {
}
internal open fun bar() {}
}
+2 -4
View File
@@ -7,12 +7,10 @@ enum class E private constructor(private val p: Int) {
},
B(2) {
override fun bar() {
}
override fun bar() {}
};
internal fun foo(p: Int) {
}
internal fun foo(p: Int) {}
internal abstract fun bar()
}
@@ -1,6 +1,5 @@
internal class F {
fun f1(p1: Int, p2: Int, p3: Int, p4: Int, vararg p5: Int) {
}
fun f1(p1: Int, p2: Int, p3: Int, p4: Int, vararg p5: Int) {}
fun f2(array: IntArray) {
f1(1, 2,
+3 -7
View File
@@ -1,14 +1,10 @@
internal class F {
fun f1() {
}
fun f1() {}
fun f2() {
}
fun f2() {}
var i: Int? = 0
fun f3() {
}
fun f3() {}
}
@@ -4,8 +4,7 @@ internal class F {
/*c2*/
fun f1() {
}
fun f1() {}
//c3
@@ -13,13 +12,10 @@ internal class F {
//c4
fun f2() {
}
fun f2() {}
var i: Int? = 0
fun f3() {
}
fun f3() {}
//c5
}
@@ -6,14 +6,11 @@ internal class F {
//c4
fun f2() {
}
fun f2() {}
fun f3() {
}
fun f3() {}
fun f4() {
}
fun f4() {}
companion object {
@@ -21,15 +18,12 @@ internal class F {
/*c2*/
fun f1() {
}
fun f1() {}
var i: Int? = 0
//c5
fun f5() {
}
fun f5() {}
}
//c6
@@ -4,8 +4,7 @@ internal object F {
/*c2*/
fun f1() {
}
fun f1() {}
//c3
@@ -13,13 +12,10 @@ internal object F {
//c4
fun f2() {
}
fun f2() {}
var i: Int? = 0
fun f3() {
}
fun f3() {}
//c5
}
+1 -2
View File
@@ -1,2 +1 @@
fun main() {
}
fun main() {}
@@ -1,6 +1,5 @@
package demo
internal class Final {
fun test() {
}
fun test() {}
}
+1 -2
View File
@@ -1,2 +1 @@
fun test() {
}
fun test() {}
+4 -8
View File
@@ -5,17 +5,13 @@
// ERROR: 'return' is not allowed here
// ERROR: Type mismatch: inferred type is String but Unit was expected
class Java8Class {
fun foo0(r: Function0<String>) {
}
fun foo0(r: Function0<String>) {}
fun foo1(r: Function1<Int, String>) {
}
fun foo1(r: Function1<Int, String>) {}
fun foo2(r: Function2<Int, Int, String>) {
}
fun foo2(r: Function2<Int, Int, String>) {}
fun helper() {
}
fun helper() {}
fun foo() {
foo0 { "42" }
@@ -8,11 +8,9 @@ internal class Test {
return 1
}
constructor(i: Int) : super() {
}
constructor(i: Int) : super() {}
constructor() {
}
constructor() {}
companion object {
var field = Java8Class()
@@ -1,6 +1,5 @@
internal class C {
fun foo1(p1: Int, p2: Int) {
}
fun foo1(p1: Int, p2: Int) {}
fun foo2(
p1: Int,
@@ -16,4 +15,4 @@ internal class C {
p3: Int, p4: Int
) {
}
}
}
+1 -2
View File
@@ -1,2 +1 @@
@JvmStatic fun main(args: Array<String>) {
}
@JvmStatic fun main(args: Array<String>) {}
+1 -2
View File
@@ -1,4 +1,3 @@
object A {
@JvmStatic fun main(args: Array<String>) {
}
@JvmStatic fun main(args: Array<String>) {}
}
@@ -1,5 +1,4 @@
// !forceNotNullTypes: false
object A {
@JvmStatic fun main(args: Array<String>) {
}
@JvmStatic fun main(args: Array<String>) {}
}
+1 -2
View File
@@ -1,2 +1 @@
fun main(): String {
}
fun main(): String {}
+1 -2
View File
@@ -1,2 +1 @@
fun main(): Int {
}
fun main(): Int {}
@@ -1,2 +1 @@
fun main(): Boolean {
}
fun main(): Boolean {}
+2 -4
View File
@@ -1,9 +1,7 @@
internal open class A {
internal open fun a() {
}
internal open fun a() {}
}
internal class B : A() {
override fun a() {
}
override fun a() {}
}
+3 -6
View File
@@ -1,14 +1,11 @@
internal open class A {
internal open fun foo() {
}
internal open fun foo() {}
}
internal open class B : A() {
override fun foo() {
}
override fun foo() {}
}
internal class C : B() {
override fun foo() {
}
override fun foo() {}
}
@@ -1,6 +1,5 @@
internal open class Base {
protected open fun foo() {
}
protected open fun foo() {}
}
internal class Derived : Base() {
+1 -2
View File
@@ -1,2 +1 @@
fun <U> putU(u: U) {
}
fun <U> putU(u: U) {}
@@ -1,2 +1 @@
fun <U, V, W> putUVW(u: U, v: V, w: W) {
}
fun <U, V, W> putUVW(u: U, v: V, w: W) {}
+1 -2
View File
@@ -1,2 +1 @@
private fun test() {
}
private fun test() {}
+1 -2
View File
@@ -1,2 +1 @@
protected fun test() {
}
protected fun test() {}
+1 -2
View File
@@ -1,2 +1 @@
fun test() {
}
fun test() {}
+1 -2
View File
@@ -3,6 +3,5 @@ internal class A {
bar()
}
fun bar() {
}
fun bar() {}
}
+7 -17
View File
@@ -1,14 +1,9 @@
import java.lang.Void
internal open class A {
open fun f1() {
}
fun f2() {
}
private fun f3() {
}
open fun f1() {}
fun f2() {}
private fun f3() {}
}
internal open class B : A() {
@@ -28,22 +23,17 @@ internal interface I {
}
internal class D : I {
override fun f() {
}
override fun f() {}
}
internal abstract class E {
internal abstract fun f1()
internal open fun f2() {
}
fun f3() {
}
internal open fun f2() {}
fun f3() {}
}
internal class F : E() {
override fun f1() {
}
override fun f1() {}
override fun f2() {
super.f2()
+1 -2
View File
@@ -1,8 +1,7 @@
package demo
internal class Test {
fun putInt(i: Int?) {
}
fun putInt(i: Int?) {}
fun test() {
val b: Byte = 10
+1 -2
View File
@@ -1,8 +1,7 @@
package demo
internal class Test {
fun putInt(i: Int?) {
}
fun putInt(i: Int?) {}
fun test() {
val i = 10
+1 -2
View File
@@ -1,8 +1,7 @@
package demo
internal class Test {
fun putInt(i: Int) {
}
fun putInt(i: Int) {}
fun test() {
val b: Byte = 10
+1 -3
View File
@@ -11,9 +11,7 @@ internal object One {
internal class StringContainer(s: String)
internal class Test {
fun putString(s: String) {
}
fun putString(s: String) {}
fun test() {
putString(One.myContainer.myString)
StringContainer(One.myContainer.myString)
+1 -3
View File
@@ -11,9 +11,7 @@ internal object One {
internal class IntContainer(i: Int)
internal class Test {
fun putInt(i: Int) {
}
fun putInt(i: Int) {}
fun test() {
putInt(One.myContainer.myInt)
IntContainer(One.myContainer.myInt)
+2 -6
View File
@@ -11,18 +11,14 @@ class Language(protected var code: String) : Serializable {
internal open class Base {
internal open fun test() {
}
internal open fun test() {}
override fun toString(): String {
return "BASE"
}
}
internal class Child : Base() {
override fun test() {
}
override fun test() {}
override fun toString(): String {
return "Child"
}
+1 -2
View File
@@ -1,6 +1,5 @@
internal class Test {
fun putInt(i: Int) {
}
fun putInt(i: Int) {}
fun test() {
val b = 10
+1 -2
View File
@@ -133,6 +133,5 @@ internal class A {
t(c > c)
}
private fun t(b: Boolean) {
}
private fun t(b: Boolean) {}
}
+2 -5
View File
@@ -39,9 +39,6 @@ internal class Test {
i(c.toInt() shr i)
}
fun b(b: Boolean) {
}
fun i(i: Int) {
}
fun b(b: Boolean) {}
fun i(i: Int) {}
}
+2 -5
View File
@@ -10,11 +10,8 @@ internal class A {
private val d9 = 1.0
private val x = 1 / (1.0 + 0)
fun foo1(d: Double) {
}
fun foo2(d: Double?) {
}
fun foo1(d: Double) {}
fun foo2(d: Double?) {}
fun bar() {
foo1(1.0)
+2 -5
View File
@@ -10,11 +10,8 @@ internal class A {
private val f9 = 1f
private val f10 = 1f
fun foo1(f: Float) {
}
fun foo2(f: Float?) {
}
fun foo1(f: Float) {}
fun foo2(f: Float?) {}
fun bar() {
foo1(1f)
+2 -5
View File
@@ -8,11 +8,8 @@ internal class A {
private val l7: Long = +1
private val l8 = +1L
fun foo1(l: Long) {
}
fun foo2(l: Long?) {
}
fun foo1(l: Long) {}
fun foo2(l: Long?) {}
fun bar() {
foo1(1)
@@ -1,8 +1,7 @@
package demo
internal class Map {
fun <K, V> put(k: K?, v: V) {
}
fun <K, V> put(k: K?, v: V) {}
}
internal class U {
@@ -138,6 +138,5 @@ internal class A {
*/
}
fun useSplit(result: Array<String>) {
}
fun useSplit(result: Array<String>) {}
}
@@ -1,6 +1,5 @@
internal class C {
private fun foo(s: String?) {
}
private fun foo(s: String?) {}
fun bar() {
foo(null)
@@ -1,6 +1,5 @@
internal class C {
fun foo(s: String?) {
}
fun foo(s: String?) {}
}
internal class D {
@@ -1,6 +1,5 @@
internal class C {
private fun foo(s: String?) {
}
private fun foo(s: String?) {}
fun bar(b: Boolean) {
foo(if (b) "a" else null)
@@ -1,11 +1,9 @@
// ERROR: There's a cycle in the inheritance hierarchy for this type
// ERROR: There's a cycle in the inheritance hierarchy for this type
internal open class A : B() {
open fun foo(s: String) {
}
open fun foo(s: String) {}
}
internal open class B : A() {
open fun foo(s: String) {
}
open fun foo(s: String) {}
}
+2 -4
View File
@@ -23,9 +23,7 @@ class Passenger {
accept2(pass as PassChild?)
}
fun accept1(p: PassChild) {
}
fun accept1(p: PassChild) {}
fun accept2(p: PassChild) {
}
fun accept2(p: PassChild) {}
}
+4 -8
View File
@@ -8,27 +8,23 @@ internal interface EmptyWindowListener
internal open class EmptyWindowAdapter
internal open class WindowAdapter : WindowListener {
override fun windowClosing() {
}
override fun windowClosing() {}
}
internal open class Frame {
fun addWindowListener(listener: WindowListener) {
}
fun addWindowListener(listener: WindowListener) {}
}
internal class Client : Frame() {
init {
val a = object : WindowAdapter() {
override fun windowClosing() {
}
override fun windowClosing() {}
}
addWindowListener(a)
addWindowListener(object : WindowAdapter() {
override fun windowClosing() {
}
override fun windowClosing() {}
})
val b = object : EmptyWindowListener {
+3 -6
View File
@@ -20,22 +20,19 @@ internal open class A : I {
bar(1)
}
fun bar(i: Int) {
}
fun bar(i: Int) {}
open fun x() {
x(1)
}
fun x(i: Int) {
}
fun x(i: Int) {}
fun y() {
y(1)
}
open fun y(i: Int) {
}
open fun y(i: Int) {}
}
internal class B : A() {
+1 -2
View File
@@ -17,6 +17,5 @@ internal class C<T> {
return comparable.compareTo(t)
}
fun foo5(w: Collection<*>) {
}
fun foo5(w: Collection<*>) {}
}
+1 -2
View File
@@ -1,8 +1,7 @@
package demo
internal class TestT {
fun <T> getT() {
}
fun <T> getT() {}
}
internal class U {
@@ -12,8 +12,7 @@ internal class C {
return string
}
fun foo(i: I) {
}
fun foo(i: I) {}
var string: String? = null
}
+5 -12
View File
@@ -1,19 +1,13 @@
// !openByDefault: true
internal open class A {
internal open fun foo1() {
}
private fun foo2() {
}
fun foo3() {
}
internal open fun foo1() {}
private fun foo2() {}
fun foo3() {}
}
internal class B {
fun foo() {
}
fun foo() {}
}
internal abstract class C {
@@ -25,8 +19,7 @@ internal interface I {
}
internal open class D : I {
override fun foo() {
}
override fun foo() {}
}
internal enum class E {
@@ -8,10 +8,7 @@ internal class A {
companion object {
private val s = "abc"
private fun privateStatic1() {
}
private fun privateStatic2() {
}
private fun privateStatic1() {}
private fun privateStatic2() {}
}
}
@@ -4,9 +4,6 @@ internal class A {
privateStatic2()
}
private fun privateStatic1() {
}
private fun privateStatic2() {
}
private fun privateStatic1() {}
private fun privateStatic2() {}
}
@@ -10,10 +10,7 @@ internal class A {
privateStatic1()
}
private fun privateStatic1() {
}
private fun privateStatic2() {
}
private fun privateStatic1() {}
private fun privateStatic2() {}
}
}
@@ -11,10 +11,7 @@ internal class A {
companion object {
private fun privateStatic1() {
}
private fun privateStatic2() {
}
private fun privateStatic1() {}
private fun privateStatic2() {}
}
}
@@ -9,9 +9,6 @@ internal class A {
privateStatic2()
}
private fun privateStatic1() {
}
private fun privateStatic2() {
}
private fun privateStatic1() {}
private fun privateStatic2() {}
}
@@ -1,8 +1,7 @@
package a.b
internal open class Base {
fun foo() {
}
fun foo() {}
}
internal class A : Base() {
@@ -1,8 +1,7 @@
package a.b
internal open class Base {
fun foo() {
}
fun foo() {}
}
internal class A : Base() {
@@ -1,2 +1 @@
fun <T : Any, K : Node> max(coll: Collection<T>): T where T : Comparable<T>, K : Collection<in K> {
}
fun <T : Any, K : Node> max(coll: Collection<T>): T where T : Comparable<T>, K : Collection<in K> {}
+1 -2
View File
@@ -1,2 +1 @@
fun <T : Any> max(coll: Collection<T>): T where T : Comparable<T> {
}
fun <T : Any> max(coll: Collection<T>): T where T : Comparable<T> {}
@@ -1,2 +1 @@
fun pushAll(vararg objs: Any) {
}
fun pushAll(vararg objs: Any) {}