Do not force new line in body for empty functions and function expressions (KT-10828)
#KT-10828 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
268d55104c
commit
2841931ffa
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.idea.formatter.KotlinSpacingBuilder.CustomSpacingBui
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtFunction
|
||||
|
||||
val MODIFIERS_LIST_ENTRIES = TokenSet.orSet(TokenSet.create(ANNOTATION_ENTRY, ANNOTATION), MODIFIER_KEYWORDS)
|
||||
|
||||
@@ -403,6 +404,25 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
||||
}
|
||||
|
||||
inPosition(parent = CLASS_BODY, right = RBRACE).lineBreakIfLineBreakInParent(numSpacesOtherwise = 1)
|
||||
|
||||
inPosition(parent = BLOCK, right = RBRACE).customRule { block, left, right ->
|
||||
val funNode = block.node.treeParent.psi as? KtFunction ?: return@customRule null
|
||||
val empty = left.node.elementType == LBRACE
|
||||
if (funNode.name != null && !empty) return@customRule null
|
||||
|
||||
val spaces = if (empty) 0 else spacesInSimpleFunction
|
||||
Spacing.createDependentLFSpacing(spaces, spaces, funNode.textRange,
|
||||
codeStyleSettings.KEEP_LINE_BREAKS,
|
||||
codeStyleSettings.KEEP_BLANK_LINES_IN_CODE)
|
||||
}
|
||||
|
||||
inPosition(parent = BLOCK, left = LBRACE).customRule { parent, left, right ->
|
||||
val funNode = parent.node.treeParent.psi as? KtFunction ?: return@customRule null
|
||||
if (funNode.name != null) return@customRule null
|
||||
Spacing.createDependentLFSpacing(spacesInSimpleFunction, spacesInSimpleFunction, funNode.textRange,
|
||||
codeStyleSettings.KEEP_LINE_BREAKS,
|
||||
codeStyleSettings.KEEP_BLANK_LINES_IN_CODE)
|
||||
}
|
||||
}
|
||||
|
||||
simple {
|
||||
|
||||
+3
-2
@@ -48,6 +48,7 @@ class KotlinFunctionDeclarationBodyFixer : SmartEnterProcessorWithFixers.Fixer<K
|
||||
endOffset--
|
||||
}
|
||||
|
||||
doc.insertString(endOffset, "{}")
|
||||
// Insert '\n' to force a multiline body, otherwise there will be an empty body on one line and a caret on the next one.
|
||||
doc.insertString(endOffset, "{\n}")
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -1,11 +1,9 @@
|
||||
import java.io.File
|
||||
|
||||
internal class C {
|
||||
private fun memberFun(file: File) {
|
||||
}
|
||||
private fun memberFun(file: File) {}
|
||||
|
||||
companion object {
|
||||
@JvmStatic fun main(args: Array<String>) {
|
||||
}
|
||||
@JvmStatic fun main(args: Array<String>) {}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
class A {
|
||||
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
fun bar() {}
|
||||
|
||||
|
||||
fun f() {}
|
||||
|
||||
@@ -6,7 +6,6 @@ class A {
|
||||
list.add(1)
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
fun bar() {}
|
||||
|
||||
}
|
||||
@@ -8,5 +8,4 @@ fun foo() {
|
||||
list.add(1)
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
fun bar() {}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import test.JavaParent
|
||||
|
||||
class KotlinChild : JavaParent() {
|
||||
override fun subject() {
|
||||
}
|
||||
override fun subject() {}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import test.JavaInterface
|
||||
|
||||
class KotlinChild : JavaInterface() {
|
||||
override fun subject(s: String?) {
|
||||
}
|
||||
override fun subject(s: String?) {}
|
||||
}
|
||||
@@ -2,8 +2,7 @@ enum class E1 {
|
||||
A,
|
||||
B;
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
enum class E2 {
|
||||
@@ -11,16 +10,14 @@ enum class E2 {
|
||||
B;
|
||||
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
enum class E3 {
|
||||
A,
|
||||
B;
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
enum class E4 {
|
||||
@@ -28,6 +25,5 @@ enum class E4 {
|
||||
B
|
||||
;
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
fun some(f: (String) -> Unit) {
|
||||
}
|
||||
fun some(f: (String) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
3 + object {
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
fun f1() {
|
||||
}
|
||||
|
||||
fun f1() {}
|
||||
class C1 {}
|
||||
|
||||
// -----
|
||||
|
||||
fun f2() {
|
||||
}
|
||||
|
||||
fun f2() {}
|
||||
class C2
|
||||
|
||||
// -----
|
||||
@@ -24,15 +20,13 @@ class C4
|
||||
|
||||
class C5 {}
|
||||
|
||||
fun f5() {
|
||||
}
|
||||
fun f5() {}
|
||||
|
||||
// -----
|
||||
|
||||
class C6
|
||||
|
||||
fun f6() {
|
||||
}
|
||||
fun f6() {}
|
||||
|
||||
// -----
|
||||
|
||||
|
||||
@@ -3,29 +3,24 @@ fun f1() {
|
||||
}
|
||||
|
||||
val p1 = 1
|
||||
fun f2() {
|
||||
}
|
||||
fun f2() {}
|
||||
|
||||
fun f3() = 1
|
||||
val p2 = 1
|
||||
fun f4() = 1
|
||||
|
||||
fun f4() {
|
||||
}
|
||||
|
||||
fun f4() {}
|
||||
val p3: Int
|
||||
get() = 1
|
||||
|
||||
fun f5() = 1
|
||||
|
||||
class OneLine {
|
||||
fun f1() {
|
||||
}
|
||||
fun f1() {}
|
||||
|
||||
val p1 = 1
|
||||
|
||||
fun f2() {
|
||||
}
|
||||
fun f2() {}
|
||||
|
||||
fun f3() = 1
|
||||
|
||||
@@ -33,8 +28,7 @@ class OneLine {
|
||||
|
||||
fun f4() = 1
|
||||
|
||||
fun f4() {
|
||||
}
|
||||
fun f4() {}
|
||||
|
||||
val p3: Int
|
||||
get() = 1
|
||||
@@ -43,15 +37,13 @@ class OneLine {
|
||||
}
|
||||
|
||||
class TwoLines {
|
||||
fun f1() {
|
||||
}
|
||||
fun f1() {}
|
||||
|
||||
|
||||
val p1 = 1
|
||||
|
||||
|
||||
fun f2() {
|
||||
}
|
||||
fun f2() {}
|
||||
|
||||
|
||||
fun f3() = 1
|
||||
@@ -63,8 +55,7 @@ class TwoLines {
|
||||
fun f4() = 1
|
||||
|
||||
|
||||
fun f4() {
|
||||
}
|
||||
fun f4() {}
|
||||
|
||||
|
||||
val p3: Int
|
||||
|
||||
+8
-19
@@ -1,15 +1,9 @@
|
||||
// No lines between
|
||||
|
||||
fun f2() {
|
||||
}
|
||||
|
||||
fun f1() {
|
||||
}
|
||||
|
||||
fun f2() {}
|
||||
fun f1() {}
|
||||
fun f3() = 1
|
||||
fun f4() {
|
||||
}
|
||||
|
||||
fun f4() {}
|
||||
fun f5() {
|
||||
}
|
||||
|
||||
@@ -18,16 +12,13 @@ fun f7() = 8
|
||||
|
||||
// One line
|
||||
|
||||
fun f2() {
|
||||
}
|
||||
fun f2() {}
|
||||
|
||||
fun f1() {
|
||||
}
|
||||
fun f1() {}
|
||||
|
||||
fun f3() = 1
|
||||
|
||||
fun f4() {
|
||||
}
|
||||
fun f4() {}
|
||||
|
||||
fun f5() {
|
||||
}
|
||||
@@ -41,15 +32,13 @@ fun l1() {
|
||||
}
|
||||
|
||||
|
||||
fun l2() {
|
||||
}
|
||||
fun l2() {}
|
||||
|
||||
|
||||
fun l3() = 1
|
||||
|
||||
|
||||
fun l4() {
|
||||
}
|
||||
fun l4() {}
|
||||
|
||||
|
||||
fun l5() {
|
||||
|
||||
+22
-15
@@ -1,17 +1,13 @@
|
||||
val a = fun() {
|
||||
}
|
||||
val b = fun test() {
|
||||
}
|
||||
val a = fun() {}
|
||||
val b = fun test() {}
|
||||
|
||||
val c = fun() {
|
||||
}
|
||||
val c = fun() {}
|
||||
val c = fun() = 4
|
||||
|
||||
val c = fun() =
|
||||
4
|
||||
|
||||
val c = fun() {
|
||||
}
|
||||
val c = fun() {}
|
||||
val c = fun() = 4
|
||||
|
||||
fun test() = fun test() = 4
|
||||
@@ -19,18 +15,29 @@ fun test() = fun test() = 4
|
||||
fun test() {
|
||||
test(fun() {
|
||||
})
|
||||
test(fun test() {
|
||||
})
|
||||
test(fun test() {})
|
||||
test(fun test() = 5)
|
||||
|
||||
test(fun test() = fun test(a: Int) = 2)
|
||||
|
||||
2.(fun test() {
|
||||
})()
|
||||
2.(fun test() {})()
|
||||
|
||||
(fun() = 4)
|
||||
(fun() {
|
||||
})
|
||||
(fun() {})
|
||||
|
||||
test(fun test() = 4)
|
||||
}
|
||||
}
|
||||
|
||||
fun d = fun(a: Int,
|
||||
b: String) {
|
||||
}
|
||||
|
||||
fun e = fun() {
|
||||
val a = 1
|
||||
}
|
||||
|
||||
fun f = fun() { foo() }
|
||||
|
||||
val g: (String) -> Int = fun(p: String): Unit { /* comment */ /* other comment */ }
|
||||
|
||||
fun foo() {}
|
||||
+13
-1
@@ -27,4 +27,16 @@ fun test() {
|
||||
(fun(){})
|
||||
|
||||
test( fun test ( ) = 4 )
|
||||
}
|
||||
}
|
||||
|
||||
fun d = fun(a: Int,
|
||||
b: String) {}
|
||||
|
||||
fun e = fun() {
|
||||
val a = 1}
|
||||
|
||||
fun f = fun() {foo()}
|
||||
|
||||
val g: (String) -> Int = fun(p: String): Unit { /* comment */ /* other comment */ }
|
||||
|
||||
fun foo() {}
|
||||
@@ -42,4 +42,3 @@ fun testWithComments() {
|
||||
it > 4
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -9,15 +9,13 @@ enum class E3 {
|
||||
class C1 {}
|
||||
|
||||
class C2 {
|
||||
fun test() {
|
||||
}
|
||||
fun test() {}
|
||||
}
|
||||
|
||||
object O1 {}
|
||||
|
||||
object O2 {
|
||||
fun test() {
|
||||
}
|
||||
fun test() {}
|
||||
}
|
||||
|
||||
interface T1 {}
|
||||
@@ -32,3 +30,7 @@ enum class E1 {
|
||||
val some = 1
|
||||
}
|
||||
}
|
||||
|
||||
fun e = fun(a: Int,
|
||||
b: String) {
|
||||
}
|
||||
|
||||
+3
@@ -25,3 +25,6 @@ enum class E1 {
|
||||
EE2 {
|
||||
val some = 1}
|
||||
}
|
||||
|
||||
fun e = fun(a: Int,
|
||||
b: String) {}
|
||||
|
||||
+14
-32
@@ -1,40 +1,28 @@
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
constructor() {}
|
||||
constructor() {}
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
|
||||
constructor()
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
|
||||
constructor() {
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
val x = 1
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
fun foo() {}
|
||||
val x = 1
|
||||
|
||||
constructor() {
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
val x = 1
|
||||
val x = 1
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
constructor() {}
|
||||
constructor() {
|
||||
|
||||
x = 1
|
||||
@@ -42,30 +30,24 @@ class A {
|
||||
|
||||
fun foo() = 1
|
||||
|
||||
constructor() {
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
fun foo() = 1
|
||||
|
||||
|
||||
constructor() : this() {
|
||||
}
|
||||
|
||||
constructor() : this() {
|
||||
}
|
||||
constructor() : this() {}
|
||||
constructor() : this() {}
|
||||
|
||||
|
||||
constructor(a: Int) : this()
|
||||
constructor(a: Byte) : this()
|
||||
constructor() : this()
|
||||
constructor() : super() {
|
||||
}
|
||||
constructor() : super() {}
|
||||
|
||||
|
||||
constructor() : this()
|
||||
|
||||
constructor() : super() {
|
||||
}
|
||||
constructor() : super() {}
|
||||
|
||||
constructor() :
|
||||
this()
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
constructor(): this() {
|
||||
}
|
||||
|
||||
constructor(): super() {
|
||||
}
|
||||
|
||||
constructor(): super() {
|
||||
}
|
||||
constructor() {}
|
||||
constructor(): this() {}
|
||||
constructor(): super() {}
|
||||
constructor(): super() {}
|
||||
}
|
||||
|
||||
// SET_TRUE: SPACE_BEFORE_EXTEND_COLON
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
constructor() :this() {
|
||||
}
|
||||
|
||||
constructor() :super() {
|
||||
}
|
||||
|
||||
constructor() :super() {
|
||||
}
|
||||
constructor() {}
|
||||
constructor() :this() {}
|
||||
constructor() :super() {}
|
||||
constructor() :super() {}
|
||||
}
|
||||
|
||||
// SET_TRUE: SPACE_BEFORE_EXTEND_COLON
|
||||
|
||||
+3
-7
@@ -7,8 +7,7 @@ data class FooClass2
|
||||
|
||||
//-----------------------
|
||||
|
||||
public fun fooFun1() {
|
||||
}
|
||||
public fun fooFun1() {}
|
||||
|
||||
public
|
||||
fun fooFun2() {
|
||||
@@ -102,11 +101,8 @@ object FooObject2 {
|
||||
|
||||
}
|
||||
|
||||
fun <T> foo_1() {
|
||||
}
|
||||
|
||||
fun <T> foo_2() {
|
||||
}
|
||||
fun <T> foo_1() {}
|
||||
fun <T> foo_2() {}
|
||||
|
||||
fun
|
||||
<T>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class C {
|
||||
fun foo0() {}
|
||||
fun foo0() {
|
||||
}
|
||||
|
||||
private
|
||||
fun foo() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class C {
|
||||
fun foo0() {}
|
||||
fun foo0() {
|
||||
}
|
||||
|
||||
private
|
||||
val foo = 1
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
class C {
|
||||
fun foo0() {
|
||||
}
|
||||
fun foo0() {}
|
||||
|
||||
private
|
||||
var foo = 1
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
constructor() : this() {
|
||||
}
|
||||
constructor() {}
|
||||
constructor() : this() {}
|
||||
|
||||
constructor() {
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
fun foo() {
|
||||
}
|
||||
fun foo() {}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Add function body" "true"
|
||||
class A() {
|
||||
fun <caret>foo() {
|
||||
}
|
||||
fun <caret>foo() {}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// "Add 'open fun f()' to 'A'" "true"
|
||||
open class A {
|
||||
open fun f() {
|
||||
}
|
||||
open fun f() {}
|
||||
}
|
||||
class B : A() {
|
||||
<caret>override fun f() {}
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
// "Add 'open fun f()' to 'A'" "true"
|
||||
open class A {
|
||||
open fun f() {
|
||||
}
|
||||
open fun f() {}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
+1
-2
@@ -2,8 +2,7 @@
|
||||
open class A {
|
||||
}
|
||||
open class B : A() {
|
||||
open fun f() {
|
||||
}
|
||||
open fun f() {}
|
||||
}
|
||||
class C : B() {
|
||||
<caret>override fun f() {}
|
||||
|
||||
@@ -960,6 +960,16 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
"""
|
||||
)
|
||||
|
||||
fun testFunBody9() = doFileTest(
|
||||
"""
|
||||
fun test(){<caret>}
|
||||
""",
|
||||
"""
|
||||
fun test() {}
|
||||
<caret>
|
||||
"""
|
||||
)
|
||||
|
||||
fun testInLambda1() = doFunTest(
|
||||
"""
|
||||
some {
|
||||
|
||||
@@ -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
@@ -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
-2
@@ -1,8 +1,7 @@
|
||||
// !forceNotNullTypes: false
|
||||
// !specifyLocalVariableTypeByDefault: true
|
||||
internal class Library {
|
||||
fun call() {
|
||||
}
|
||||
fun call() {}
|
||||
|
||||
val string: String?
|
||||
get() = ""
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
internal class Library {
|
||||
fun call() {
|
||||
}
|
||||
fun call() {}
|
||||
|
||||
val string: String
|
||||
get() = ""
|
||||
|
||||
@@ -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
@@ -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
@@ -5,6 +5,5 @@ internal open class Base {
|
||||
}
|
||||
|
||||
internal class Derived : Base() {
|
||||
fun foo() {
|
||||
}
|
||||
}
|
||||
fun foo() {}
|
||||
}
|
||||
+1
-2
@@ -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
@@ -1,9 +1,6 @@
|
||||
internal object Util {
|
||||
fun util1() {
|
||||
}
|
||||
|
||||
fun util2() {
|
||||
}
|
||||
fun util1() {}
|
||||
fun util2() {}
|
||||
|
||||
val CONSTANT = 10
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -1,10 +1,7 @@
|
||||
internal object Util {
|
||||
|
||||
fun util1() {
|
||||
}
|
||||
|
||||
fun util2() {
|
||||
}
|
||||
fun util1() {}
|
||||
fun util2() {}
|
||||
|
||||
val CONSTANT = 10
|
||||
}
|
||||
|
||||
+2
-5
@@ -1,9 +1,6 @@
|
||||
internal object Util {
|
||||
fun util1() {
|
||||
}
|
||||
|
||||
fun util2() {
|
||||
}
|
||||
fun util1() {}
|
||||
fun util2() {}
|
||||
|
||||
val CONSTANT = 10
|
||||
}
|
||||
|
||||
+2
-4
@@ -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 {
|
||||
|
||||
@@ -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
@@ -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) {}
|
||||
}
|
||||
|
||||
+1
-2
@@ -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
|
||||
|
||||
+12
-24
@@ -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() {
|
||||
|
||||
+12
-24
@@ -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() {
|
||||
|
||||
+8
-16
@@ -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)
|
||||
|
||||
@@ -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
@@ -2,6 +2,5 @@
|
||||
* [C.foo]
|
||||
*/
|
||||
internal class C {
|
||||
fun foo(i: Int) {
|
||||
}
|
||||
fun foo(i: Int) {}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
* [the best foo method ever][C.foo]
|
||||
*/
|
||||
internal class C {
|
||||
fun foo(i: Int) {
|
||||
}
|
||||
fun foo(i: Int) {}
|
||||
}
|
||||
|
||||
+1
-2
@@ -2,6 +2,5 @@
|
||||
* @see C.foo
|
||||
*/
|
||||
internal class C {
|
||||
fun foo(i: Int) {
|
||||
}
|
||||
fun foo(i: Int) {}
|
||||
}
|
||||
|
||||
+2
-4
@@ -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
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
+5
-11
@@ -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
@@ -1,2 +1 @@
|
||||
fun main() {
|
||||
}
|
||||
fun main() {}
|
||||
@@ -1,6 +1,5 @@
|
||||
package demo
|
||||
|
||||
internal class Final {
|
||||
fun test() {
|
||||
}
|
||||
fun test() {}
|
||||
}
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
fun test() {
|
||||
}
|
||||
fun test() {}
|
||||
+4
-8
@@ -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
@@ -1,2 +1 @@
|
||||
@JvmStatic fun main(args: Array<String>) {
|
||||
}
|
||||
@JvmStatic fun main(args: Array<String>) {}
|
||||
+1
-2
@@ -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
@@ -1,2 +1 @@
|
||||
fun main(): String {
|
||||
}
|
||||
fun main(): String {}
|
||||
@@ -1,2 +1 @@
|
||||
fun main(): Int {
|
||||
}
|
||||
fun main(): Int {}
|
||||
@@ -1,2 +1 @@
|
||||
fun main(): Boolean {
|
||||
}
|
||||
fun main(): Boolean {}
|
||||
+2
-4
@@ -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
@@ -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
@@ -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
@@ -1,2 +1 @@
|
||||
private fun test() {
|
||||
}
|
||||
private fun test() {}
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
protected fun test() {
|
||||
}
|
||||
protected fun test() {}
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
fun test() {
|
||||
}
|
||||
fun test() {}
|
||||
@@ -3,6 +3,5 @@ internal class A {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
fun bar() {}
|
||||
}
|
||||
+7
-17
@@ -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
@@ -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
@@ -1,8 +1,7 @@
|
||||
package demo
|
||||
|
||||
internal class Test {
|
||||
fun putInt(i: Int?) {
|
||||
}
|
||||
fun putInt(i: Int?) {}
|
||||
|
||||
fun test() {
|
||||
val i = 10
|
||||
|
||||
+1
-2
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,6 +1,5 @@
|
||||
internal class Test {
|
||||
fun putInt(i: Int) {
|
||||
}
|
||||
fun putInt(i: Int) {}
|
||||
|
||||
fun test() {
|
||||
val b = 10
|
||||
|
||||
+1
-2
@@ -133,6 +133,5 @@ internal class A {
|
||||
t(c > c)
|
||||
}
|
||||
|
||||
private fun t(b: Boolean) {
|
||||
}
|
||||
private fun t(b: Boolean) {}
|
||||
}
|
||||
+2
-5
@@ -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) {}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user