diff --git a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions index 9fdc0fd55f3..a91884c040a 100644 --- a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions +++ b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions @@ -1,34 +1,34 @@ == foo == fun foo() { val a = 1 - val f = { (x: Int) -> + val f = { x: Int -> val y = x + a use(a) } } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} - 2 mark({ val a = 1 val f = { (x: Int) -> val y = x + a use(a) } }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} - v(val f = { (x: Int) -> val y = x + a use(a) }) INIT: in: {a=ID} out: {a=ID, f=D} - mark({ (x: Int) -> val y = x + a use(a) }) INIT: in: {a=ID, f=D} out: {a=ID, f=D} + 1 INIT: in: {} out: {} USE: in: {} out: {} + 2 mark({ val a = 1 val f = { x: Int -> val y = x + a use(a) } }) + v(val a = 1) INIT: in: {} out: {a=D} + r(1) -> INIT: in: {a=D} out: {a=D} + w(a|) INIT: in: {a=D} out: {a=ID} + v(val f = { x: Int -> val y = x + a use(a) }) INIT: in: {a=ID} out: {a=ID, f=D} + mark({ x: Int -> val y = x + a use(a) }) INIT: in: {a=ID, f=D} out: {a=ID, f=D} jmp?(L2) - d({ (x: Int) -> val y = x + a use(a) }) USE: in: {a=READ} out: {a=READ} + d({ x: Int -> val y = x + a use(a) }) USE: in: {a=READ} out: {a=READ} L2 [after local declaration]: - r({ (x: Int) -> val y = x + a use(a) }) -> - w(f|) INIT: in: {a=ID, f=D} out: {a=ID, f=ID} + r({ x: Int -> val y = x + a use(a) }) -> + w(f|) INIT: in: {a=ID, f=D} out: {a=ID, f=ID} L1: - 1 INIT: in: {} out: {} + 1 INIT: in: {} out: {} error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == anonymous_0 == -{ (x: Int) -> +{ x: Int -> val y = x + a use(a) } diff --git a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.kt b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.kt index 893b0287bb9..4489dbe2cd1 100644 --- a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.kt +++ b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.kt @@ -1,6 +1,6 @@ fun foo() { val a = 1 - val f = { (x: Int) -> + val f = { x: Int -> val y = x + a use(a) } diff --git a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.values b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.values index 02a26ef3b5b..9998d68a207 100644 --- a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.values +++ b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.values @@ -1,17 +1,17 @@ == foo == fun foo() { val a = 1 - val f = { (x: Int) -> + val f = { x: Int -> val y = x + a use(a) } } --------------------- -1 : Int NEW: r(1) -> -{ (x: Int) -> val y = x + a use(a) } : {<: (Int) -> Array} NEW: r({ (x: Int) -> val y = x + a use(a) }) -> +1 : Int NEW: r(1) -> +{ x: Int -> val y = x + a use(a) } : {<: (Int) -> Array} NEW: r({ x: Int -> val y = x + a use(a) }) -> ===================== == anonymous_0 == -{ (x: Int) -> +{ x: Int -> val y = x + a use(a) } diff --git a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions index 86ce0a95d9e..3429c27ce26 100644 --- a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions +++ b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions @@ -1,28 +1,28 @@ == TestFunctionLiteral == class TestFunctionLiteral { - val sum: (Int)->Int = { (x: Int) -> + val sum: (Int)->Int = { x: Int -> sum(x - 1) + x } } --------------------- L0: - 1 INIT: in: {} out: {} - v(val sum: (Int)->Int = { (x: Int) -> sum(x - 1) + x }) INIT: in: {} out: {sum=D} - mark({ (x: Int) -> sum(x - 1) + x }) INIT: in: {sum=D} out: {sum=D} + 1 INIT: in: {} out: {} + v(val sum: (Int)->Int = { x: Int -> sum(x - 1) + x }) INIT: in: {} out: {sum=D} + mark({ x: Int -> sum(x - 1) + x }) INIT: in: {sum=D} out: {sum=D} jmp?(L2) - d({ (x: Int) -> sum(x - 1) + x }) USE: in: {sum=READ} out: {sum=READ} + d({ x: Int -> sum(x - 1) + x }) USE: in: {sum=READ} out: {sum=READ} L2 [after local declaration]: - r({ (x: Int) -> sum(x - 1) + x }) -> - w(sum|) INIT: in: {sum=D} out: {sum=ID} + r({ x: Int -> sum(x - 1) + x }) -> + w(sum|) INIT: in: {sum=D} out: {sum=ID} L1: - INIT: in: {sum=ID} out: {sum=ID} + INIT: in: {sum=ID} out: {sum=ID} error: - INIT: in: {} out: {} + INIT: in: {} out: {} sink: - INIT: in: {sum=I?D} out: {sum=I?D} USE: in: {} out: {} + INIT: in: {sum=I?D} out: {sum=I?D} USE: in: {} out: {} ===================== == anonymous_0 == -{ (x: Int) -> +{ x: Int -> sum(x - 1) + x } --------------------- diff --git a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.kt b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.kt index 92ea871109f..dbdd5d4f2c2 100644 --- a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.kt +++ b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.kt @@ -1,5 +1,5 @@ class TestFunctionLiteral { - val sum: (Int)->Int = { (x: Int) -> + val sum: (Int)->Int = { x: Int -> sum(x - 1) + x } } diff --git a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.values b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.values index 38dbe45cbd1..8f20c98c10b 100644 --- a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.values +++ b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.values @@ -1,27 +1,27 @@ == TestFunctionLiteral == class TestFunctionLiteral { - val sum: (Int)->Int = { (x: Int) -> + val sum: (Int)->Int = { x: Int -> sum(x - 1) + x } } --------------------- -{ (x: Int) -> sum(x - 1) + x } : {<: (Int) -> Int} NEW: r({ (x: Int) -> sum(x - 1) + x }) -> +{ x: Int -> sum(x - 1) + x } : {<: (Int) -> Int} NEW: r({ x: Int -> sum(x - 1) + x }) -> ===================== == anonymous_0 == -{ (x: Int) -> +{ x: Int -> sum(x - 1) + x } --------------------- - : Int NEW: magic[FAKE_INITIALIZER](x: Int) -> - : TestFunctionLiteral NEW: magic[IMPLICIT_RECEIVER](sum) -> -sum : {<: (Int) -> Int} NEW: r(sum|) -> -x : Int NEW: r(x) -> -1 : Int NEW: r(1) -> -x - 1 : Int NEW: call(x - 1, minus|, ) -> -sum(x - 1) : Int NEW: call(sum(x - 1), invoke|, ) -> -x : Int NEW: r(x) -> + : Int NEW: magic[FAKE_INITIALIZER](x: Int) -> + : TestFunctionLiteral NEW: magic[IMPLICIT_RECEIVER](sum) -> +sum : {<: (Int) -> Int} NEW: r(sum|) -> +x : Int NEW: r(x) -> +1 : Int NEW: r(1) -> +x - 1 : Int NEW: call(x - 1, minus|, ) -> +sum(x - 1) : Int NEW: call(sum(x - 1), invoke|, ) -> +x : Int NEW: r(x) -> sum(x - 1) + x : Int NEW: call(sum(x - 1) + x, plus|, ) -> -sum(x - 1) + x : Int COPY +sum(x - 1) + x : Int COPY ===================== == A == open class A(val a: A) diff --git a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions index aaa61c9a96d..a2961cd1354 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions @@ -2,38 +2,38 @@ fun foo() { "before" val b = 1 - val f = { (x: Int) -> + val f = { x: Int -> val a = x + b } "after" } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} - 2 mark({ "before" val b = 1 val f = { (x: Int) -> val a = x + b } "after" }) + 1 INIT: in: {} out: {} USE: in: {} out: {} + 2 mark({ "before" val b = 1 val f = { x: Int -> val a = x + b } "after" }) mark("before") r("before") -> - v(val b = 1) INIT: in: {} out: {b=D} - r(1) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} - v(val f = { (x: Int) -> val a = x + b }) INIT: in: {b=ID} out: {b=ID, f=D} - mark({ (x: Int) -> val a = x + b }) INIT: in: {b=ID, f=D} out: {b=ID, f=D} + v(val b = 1) INIT: in: {} out: {b=D} + r(1) -> INIT: in: {b=D} out: {b=D} + w(b|) INIT: in: {b=D} out: {b=ID} + v(val f = { x: Int -> val a = x + b }) INIT: in: {b=ID} out: {b=ID, f=D} + mark({ x: Int -> val a = x + b }) INIT: in: {b=ID, f=D} out: {b=ID, f=D} jmp?(L2) - d({ (x: Int) -> val a = x + b }) USE: in: {b=READ} out: {b=READ} + d({ x: Int -> val a = x + b }) USE: in: {b=READ} out: {b=READ} L2 [after local declaration]: - r({ (x: Int) -> val a = x + b }) -> - w(f|) INIT: in: {b=ID, f=D} out: {b=ID, f=ID} - mark("after") INIT: in: {b=ID, f=ID} out: {b=ID, f=ID} + r({ x: Int -> val a = x + b }) -> + w(f|) INIT: in: {b=ID, f=D} out: {b=ID, f=ID} + mark("after") INIT: in: {b=ID, f=ID} out: {b=ID, f=ID} r("after") -> L1: - 1 INIT: in: {} out: {} + 1 INIT: in: {} out: {} error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == anonymous_0 == -{ (x: Int) -> +{ x: Int -> val a = x + b } --------------------- @@ -55,4 +55,4 @@ error: INIT: in: {} out: {} sink: INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {} -===================== \ No newline at end of file +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.kt b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.kt index 12b2fde1678..0f1e9ef890e 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.kt +++ b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.kt @@ -1,7 +1,7 @@ fun foo() { "before" val b = 1 - val f = { (x: Int) -> + val f = { x: Int -> val a = x + b } "after" diff --git a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.values b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.values index 80ae74bf62a..a60a459215d 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.values +++ b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.values @@ -2,20 +2,20 @@ fun foo() { "before" val b = 1 - val f = { (x: Int) -> + val f = { x: Int -> val a = x + b } "after" } --------------------- -"before" : * NEW: r("before") -> -1 : Int NEW: r(1) -> -{ (x: Int) -> val a = x + b } : {<: (Int) -> Unit} NEW: r({ (x: Int) -> val a = x + b }) -> -"after" : * NEW: r("after") -> -{ "before" val b = 1 val f = { (x: Int) -> val a = x + b } "after" } : * COPY +"before" : * NEW: r("before") -> +1 : Int NEW: r(1) -> +{ x: Int -> val a = x + b } : {<: (Int) -> Unit} NEW: r({ x: Int -> val a = x + b }) -> +"after" : * NEW: r("after") -> +{ "before" val b = 1 val f = { x: Int -> val a = x + b } "after" } : * COPY ===================== == anonymous_0 == -{ (x: Int) -> +{ x: Int -> val a = x + b } --------------------- diff --git a/compiler/testData/cfg/controlStructures/Finally.instructions b/compiler/testData/cfg/controlStructures/Finally.instructions index 082f942716b..7215a5671ae 100644 --- a/compiler/testData/cfg/controlStructures/Finally.instructions +++ b/compiler/testData/cfg/controlStructures/Finally.instructions @@ -89,7 +89,7 @@ sink: fun t3() { try { 1 - l@{ () -> + l@{ -> if (2 > 3) { return@l } @@ -101,38 +101,38 @@ fun t3() { --------------------- L0: 1 - 2 mark({ try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 } }) - mark(try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 }) - jmp?(L2) NEXT:[mark({ 2 }), mark({ 1 l@{ () -> if (2 > 3) { return@l } } })] - 3 mark({ 1 l@{ () -> if (2 > 3) { return@l } } }) + 2 mark({ try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 } }) + mark(try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 }) + jmp?(L2) NEXT:[mark({ 2 }), mark({ 1 l@{ -> if (2 > 3) { return@l } } })] + 3 mark({ 1 l@{ -> if (2 > 3) { return@l } } }) r(1) -> - mark(l@{ () -> if (2 > 3) { return@l } }) - mark({ () -> if (2 > 3) { return@l } }) - jmp?(L3) NEXT:[r({ () -> if (2 > 3) { return@l } }) -> , d({ () -> if (2 > 3) { return@l } })] - d({ () -> if (2 > 3) { return@l } }) NEXT:[] + mark(l@{ -> if (2 > 3) { return@l } }) + mark({ -> if (2 > 3) { return@l } }) + jmp?(L3) NEXT:[r({ -> if (2 > 3) { return@l } }) -> , d({ -> if (2 > 3) { return@l } })] + d({ -> if (2 > 3) { return@l } }) NEXT:[] L3 [after local declaration]: - r({ () -> if (2 > 3) { return@l } }) -> PREV:[jmp?(L3)] - 2 jmp(L8) NEXT:[mark({ 2 })] + r({ -> if (2 > 3) { return@l } }) -> PREV:[jmp?(L3)] + 2 jmp(L8) NEXT:[mark({ 2 })] L2 [onExceptionToFinallyBlock]: L9 [start finally]: - 3 mark({ 2 }) PREV:[jmp?(L2)] + 3 mark({ 2 }) PREV:[jmp?(L2)] r(2) -> L10 [finish finally]: - 2 jmp(error) NEXT:[] + 2 jmp(error) NEXT:[] L8 [skipFinallyToErrorBlock]: L11 [copy of L2, onExceptionToFinallyBlock]: - 3 mark({ 2 }) PREV:[jmp(L8)] + 3 mark({ 2 }) PREV:[jmp(L8)] r(2) -> - 2 merge(try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 }|) -> + 2 merge(try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 }|) -> L1: - 1 NEXT:[] + 1 NEXT:[] error: - PREV:[jmp(error)] + PREV:[jmp(error)] sink: - PREV:[, , d({ () -> if (2 > 3) { return@l } })] + PREV:[, , d({ -> if (2 > 3) { return@l } })] ===================== == anonymous_0 == -{ () -> +{ -> if (2 > 3) { return@l } @@ -163,7 +163,7 @@ sink: ===================== == t4 == fun t4() { - l@{ () -> + l@{ -> try { 1 if (2 > 3) { @@ -177,22 +177,22 @@ fun t4() { --------------------- L0: 1 - 2 mark({ l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } }) - mark(l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) - mark({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) - jmp?(L2) NEXT:[r({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> , d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })] - d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) NEXT:[] + 2 mark({ l@{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } } }) + mark(l@{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) + mark({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) + jmp?(L2) NEXT:[r({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> , d({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } })] + d({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) NEXT:[] L2 [after local declaration]: - r({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> PREV:[jmp?(L2)] + r({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> PREV:[jmp?(L2)] L1: - 1 NEXT:[] + 1 NEXT:[] error: - PREV:[] + PREV:[] sink: - PREV:[, , d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })] + PREV:[, , d({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } })] ===================== == anonymous_1 == -{ () -> +{ -> try { 1 if (2 > 3) { diff --git a/compiler/testData/cfg/controlStructures/Finally.kt b/compiler/testData/cfg/controlStructures/Finally.kt index 7f2ea4526ce..49443aff89f 100644 --- a/compiler/testData/cfg/controlStructures/Finally.kt +++ b/compiler/testData/cfg/controlStructures/Finally.kt @@ -20,7 +20,7 @@ fun t2() { fun t3() { try { 1 - l@{ () -> + l@{ -> if (2 > 3) { return@l } @@ -31,7 +31,7 @@ fun t3() { } fun t4() { - l@{ () -> + l@{ -> try { 1 if (2 > 3) { diff --git a/compiler/testData/cfg/controlStructures/Finally.values b/compiler/testData/cfg/controlStructures/Finally.values index 32c1f616e23..e4147236134 100644 --- a/compiler/testData/cfg/controlStructures/Finally.values +++ b/compiler/testData/cfg/controlStructures/Finally.values @@ -43,7 +43,7 @@ try { 1 if (2 > 3) { return } } finally { 2 } : * fun t3() { try { 1 - l@{ () -> + l@{ -> if (2 > 3) { return@l } @@ -53,33 +53,33 @@ fun t3() { } } --------------------- -1 : * NEW: r(1) -> -{ () -> if (2 > 3) { return@l } } : * NEW: r({ () -> if (2 > 3) { return@l } }) -> -l@{ () -> if (2 > 3) { return@l } } : * COPY -{ 1 l@{ () -> if (2 > 3) { return@l } } } : * COPY -2 : * NEW: r(2) -> -{ 2 } : * COPY -try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 } : * NEW: merge(try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 }|) -> -{ try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 } } : * COPY +1 : * NEW: r(1) -> +{ -> if (2 > 3) { return@l } } : * NEW: r({ -> if (2 > 3) { return@l } }) -> +l@{ -> if (2 > 3) { return@l } } : * COPY +{ 1 l@{ -> if (2 > 3) { return@l } } } : * COPY +2 : * NEW: r(2) -> +{ 2 } : * COPY +try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 } : * NEW: merge(try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 }|) -> +{ try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 } } : * COPY ===================== == anonymous_0 == -{ () -> +{ -> if (2 > 3) { return@l } } --------------------- -2 : {<: Comparable} NEW: r(2) -> -3 : Int NEW: r(3) -> -2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -return@l !: * -{ return@l } !: * COPY +2 : {<: Comparable} NEW: r(2) -> +3 : Int NEW: r(3) -> +2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> +return@l !: * +{ return@l } !: * COPY if (2 > 3) { return@l } : * NEW: merge(if (2 > 3) { return@l }|!) -> if (2 > 3) { return@l } : * COPY ===================== == t4 == fun t4() { - l@{ () -> + l@{ -> try { 1 if (2 > 3) { @@ -91,12 +91,12 @@ fun t4() { } } --------------------- -{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } : * NEW: r({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> -l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } : * COPY -{ l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } } : * COPY +{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } } : * NEW: r({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> +l@{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } } : * COPY +{ l@{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } } } : * COPY ===================== == anonymous_1 == -{ () -> +{ -> try { 1 if (2 > 3) { @@ -107,16 +107,16 @@ l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } : * COPY } } --------------------- -1 : * NEW: r(1) -> -2 : {<: Comparable} NEW: r(2) -> -3 : Int NEW: r(3) -> -2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -return@l !: * -{ return@l } !: * COPY +1 : * NEW: r(1) -> +2 : {<: Comparable} NEW: r(2) -> +3 : Int NEW: r(3) -> +2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> +return@l !: * +{ return@l } !: * COPY if (2 > 3) { return@l } : * NEW: merge(if (2 > 3) { return@l }|!) -> { 1 if (2 > 3) { return@l } } : * COPY -2 : * NEW: r(2) -> -{ 2 } : * COPY +2 : * NEW: r(2) -> +{ 2 } : * COPY try { 1 if (2 > 3) { return@l } } finally { 2 } : * NEW: merge(try { 1 if (2 > 3) { return@l } } finally { 2 }|) -> try { 1 if (2 > 3) { return@l } } finally { 2 } : * COPY ===================== @@ -140,17 +140,17 @@ true : Bo 2 : {<: Comparable} NEW: r(2) -> 3 : Int NEW: r(3) -> 2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -break@l !: * -{ break@l } !: * COPY -if (2 > 3) { break@l } : * NEW: merge(if (2 > 3) { break@l }|!) -> -{ 1 if (2 > 3) { break@l } } : * COPY +break@l !: * +{ break@l } !: * COPY +if (2 > 3) { break@l } : * NEW: merge(if (2 > 3) { break@l }|!) -> +{ 1 if (2 > 3) { break@l } } : * COPY 2 : * NEW: r(2) -> { 2 } : * COPY try { 1 if (2 > 3) { break@l } } finally { 2 } : * NEW: merge(try { 1 if (2 > 3) { break@l } } finally { 2 }|) -> -{ try { 1 if (2 > 3) { break@l } } finally { 2 } } : * COPY -while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !: * -l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !: * COPY -{ l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } } !: * COPY +{ try { 1 if (2 > 3) { break@l } } finally { 2 } } : * COPY +while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !: * +l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !: * COPY +{ l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } } !: * COPY ===================== == t6 == fun t6() { @@ -173,18 +173,18 @@ true : 2 : {<: Comparable} NEW: r(2) -> 3 : Int NEW: r(3) -> 2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -break@l !: * -{ break@l } !: * COPY -if (2 > 3) { break@l } : * NEW: merge(if (2 > 3) { break@l }|!) -> +break@l !: * +{ break@l } !: * COPY +if (2 > 3) { break@l } : * NEW: merge(if (2 > 3) { break@l }|!) -> { 1 if (2 > 3) { break@l } } : * COPY -while(true) { 1 if (2 > 3) { break@l } } !: * -l@ while(true) { 1 if (2 > 3) { break@l } } !: * COPY +while(true) { 1 if (2 > 3) { break@l } } !: * +l@ while(true) { 1 if (2 > 3) { break@l } } !: * COPY 5 : * NEW: r(5) -> -{ l@ while(true) { 1 if (2 > 3) { break@l } } 5 } : * COPY +{ l@ while(true) { 1 if (2 > 3) { break@l } } 5 } : * COPY 2 : * NEW: r(2) -> { 2 } : * COPY try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 } : * NEW: merge(try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 }|) -> -{ try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 } } : * COPY +{ try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 } } : * COPY ===================== == t7 == fun t7() { @@ -206,17 +206,17 @@ true : Bo 2 : {<: Comparable} NEW: r(2) -> 3 : Int NEW: r(3) -> 2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -break@l !: * -{ break@l } !: * COPY -if (2 > 3) { break@l } : * NEW: merge(if (2 > 3) { break@l }|!) -> -{ 1 if (2 > 3) { break@l } } : * COPY -while(true) { 1 if (2 > 3) { break@l } } !: * -l@ while(true) { 1 if (2 > 3) { break@l } } !: * COPY -{ l@ while(true) { 1 if (2 > 3) { break@l } } } !: * COPY +break@l !: * +{ break@l } !: * COPY +if (2 > 3) { break@l } : * NEW: merge(if (2 > 3) { break@l }|!) -> +{ 1 if (2 > 3) { break@l } } : * COPY +while(true) { 1 if (2 > 3) { break@l } } !: * +l@ while(true) { 1 if (2 > 3) { break@l } } !: * COPY +{ l@ while(true) { 1 if (2 > 3) { break@l } } } !: * COPY 2 : * NEW: r(2) -> { 2 } : * COPY try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 } : * NEW: merge(try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 }|!) -> -{ try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 } } : * COPY +{ try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 } } : * COPY ===================== == t8 == fun t8(a : Int) { @@ -241,17 +241,17 @@ a < 2 : {<: Comparable} NEW: r(2) -> 3 : Int NEW: r(3) -> 2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -continue@l !: * -{ continue@l } !: * COPY -if (2 > 3) { continue@l } : * NEW: merge(if (2 > 3) { continue@l }|!) -> -{ 1 if (2 > 3) { continue@l } } : * COPY +continue@l !: * +{ continue@l } !: * COPY +if (2 > 3) { continue@l } : * NEW: merge(if (2 > 3) { continue@l }|!) -> +{ 1 if (2 > 3) { continue@l } } : * COPY 2 : * NEW: r(2) -> { 2 } : * COPY try { 1 if (2 > 3) { continue@l } } finally { 2 } : * NEW: merge(try { 1 if (2 > 3) { continue@l } } finally { 2 }|) -> -{ try { 1 if (2 > 3) { continue@l } } finally { 2 } } : * COPY -for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !: * -l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !: * COPY -{ l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } } !: * COPY +{ try { 1 if (2 > 3) { continue@l } } finally { 2 } } : * COPY +for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !: * +l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !: * COPY +{ l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } } !: * COPY ===================== == t9 == fun t9(a : Int) { @@ -277,18 +277,18 @@ a 2 : {<: Comparable} NEW: r(2) -> 3 : Int NEW: r(3) -> 2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -continue@l !: * -{ continue@l } !: * COPY -if (2 > 3) { continue@l } : * NEW: merge(if (2 > 3) { continue@l }|!) -> -{ 1 if (2 > 3) { continue@l } } : * COPY -for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * -l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * COPY +continue@l !: * +{ continue@l } !: * COPY +if (2 > 3) { continue@l } : * NEW: merge(if (2 > 3) { continue@l }|!) -> +{ 1 if (2 > 3) { continue@l } } : * COPY +for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * +l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * COPY 5 : * NEW: r(5) -> -{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } : * COPY +{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } : * COPY 2 : * NEW: r(2) -> { 2 } : * COPY try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 } : * NEW: merge(try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 }|) -> -{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 } } : * COPY +{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 } } : * COPY ===================== == t10 == fun t10(a : Int) { @@ -313,17 +313,17 @@ a < 2 : {<: Comparable} NEW: r(2) -> 3 : Int NEW: r(3) -> 2 > 3 : Boolean NEW: call(2 > 3, compareTo|, ) -> -continue@l !: * -{ continue@l } !: * COPY -if (2 > 3) { continue@l } : * NEW: merge(if (2 > 3) { continue@l }|!) -> -{ 1 if (2 > 3) { continue@l } } : * COPY -for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * -l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * COPY -{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } !: * COPY +continue@l !: * +{ continue@l } !: * COPY +if (2 > 3) { continue@l } : * NEW: merge(if (2 > 3) { continue@l }|!) -> +{ 1 if (2 > 3) { continue@l } } : * COPY +for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * +l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !: * COPY +{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } !: * COPY 2 : * NEW: r(2) -> { 2 } : * COPY try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 } : * NEW: merge(try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 }|!) -> -{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 } } : * COPY +{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 } } : * COPY ===================== == t11 == fun t11() { diff --git a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.kt b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.kt index 33eceb5b8a0..34467eba145 100644 --- a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.kt +++ b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.kt @@ -5,5 +5,3 @@ fun test(@ann p: Int) { } val bar = fun(@ann g: Int) {} - -val bas = { (@ann t: Int) -> } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt index c911b6bc9a8..9bd4f8995db 100644 --- a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt @@ -1,7 +1,6 @@ package public val bar: (kotlin.Int) -> kotlin.Unit -public val bas: (kotlin.Int) -> kotlin.Unit public fun test(/*0*/ @ann() p: kotlin.Int): kotlin.Unit @kotlin.annotation.annotation() public final class ann : kotlin.Annotation { diff --git a/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.kt b/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.kt index ba9e060a0c2..07fa453d885 100644 --- a/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.kt +++ b/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.kt @@ -34,7 +34,7 @@ fun test4() { // should be an error on receiver, shouldn't be thrown away fun test5() { - 1.{ String.(): String -> this}() + 1.(fun String.()=1)() } fun R?.sure() : R = this!! diff --git a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt index 32296c421f0..2856038971f 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt @@ -1,16 +1,16 @@ -val receiver = { Int.() -> } -val receiverWithParameter = { Int.(a) -> } +val receiver = { Int.() -> } +val receiverWithParameter = { Int.(a) -> } -val receiverAndReturnType = { Int.(): Int -> 5 } -val receiverAndReturnTypeWithParameter = { Int.(a: Int): Int -> 5 } +val receiverAndReturnType = { Int.(): Int -> 5 } +val receiverAndReturnTypeWithParameter = { Int.(a: Int): Int -> 5 } -val returnType = { (): Int -> 5 } -val returnTypeWithParameter = { (b: Int): Int -> 5 } +val returnType = { (): Int -> 5 } +val returnTypeWithParameter = { (b: Int): Int -> 5 } -val receiverWithFunctionType = { ((Int) -> Int).() -> } +val receiverWithFunctionType = { ((Int) -> Int).() -> } -val parenthesizedParameters = { (a: Int) -> } -val parenthesizedParameters2 = { (b) -> } +val parenthesizedParameters = { (a: Int) -> } +val parenthesizedParameters2 = { (b) -> } val none = { -> } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.txt b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.txt index fb1094a7192..9adea8f484f 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.txt +++ b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.txt @@ -7,12 +7,12 @@ public val newSyntax3: (???, kotlin.Int) -> kotlin.Unit public val newSyntax4: (kotlin.Int, ???) -> kotlin.Unit public val none: () -> kotlin.Unit public val parameterWithFunctionType: () -> ((kotlin.Int) -> kotlin.Int) -> [ERROR : No type element] -public val parenthesizedParameters: (kotlin.Int) -> kotlin.Unit -public val parenthesizedParameters2: (???) -> kotlin.Unit -public val receiver: kotlin.Int.() -> kotlin.Unit -public val receiverAndReturnType: kotlin.Int.() -> kotlin.Int -public val receiverAndReturnTypeWithParameter: kotlin.Int.(kotlin.Int) -> kotlin.Int -public val receiverWithFunctionType: ((kotlin.Int) -> kotlin.Int).() -> kotlin.Unit -public val receiverWithParameter: kotlin.Int.(???) -> kotlin.Unit +public val parenthesizedParameters: () -> kotlin.Int +public val parenthesizedParameters2: () -> ??? +public val receiver: () -> ??? +public val receiverAndReturnType: () -> kotlin.Int +public val receiverAndReturnTypeWithParameter: () -> kotlin.Int +public val receiverWithFunctionType: () -> kotlin.Int.Companion +public val receiverWithParameter: () -> ??? public val returnType: () -> kotlin.Int -public val returnTypeWithParameter: (kotlin.Int) -> kotlin.Int +public val returnTypeWithParameter: () -> kotlin.Int diff --git a/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParameterTypeMismatchVariance.kt b/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParameterTypeMismatchVariance.kt index 886f9079cc2..f2d58801d68 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParameterTypeMismatchVariance.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParameterTypeMismatchVariance.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER package a interface Super @@ -8,12 +9,12 @@ fun foo(f: (Trait) -> Trait) = f fun test(s: Sub) { foo { - (t: Super): Sub -> s + t: Super -> s } foo { - (t: Trait): Trait -> s - } - foo { - (t: Sub): Super -> s + t: Trait -> s } + + foo(fun(t: Sub) = s) + foo(fun(t): Super = s) } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt b/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt index 3337f64a242..635903ce24f 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt @@ -9,26 +9,23 @@ fun test1() { "" } foo0 { - (s: String) -> "" + s: String-> "" } foo0 { x, y -> "" } - foo0 { - (): Int -> 42 - } foo1 { "" } foo1 { - (s: String) -> "" + s: String -> "" } foo1 { x, y -> "" } foo1 { - (): Int -> 42 + -> 42 } @@ -36,12 +33,12 @@ fun test1() { "" } foo2 { - (s: String) -> "" + s: String -> "" } foo2 { x -> "" } foo2 { - (): Int -> 42 + -> 42 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnsWithExplicitReturnType.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnsWithExplicitReturnType.kt index 3a8749785c7..ef2724576dd 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnsWithExplicitReturnType.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnsWithExplicitReturnType.kt @@ -1,11 +1,11 @@ fun test(a: Int) { - run f@{ (): Int -> + runf@{ if (a > 0) return@f "" return@f 1 } - run { (): Int -> "" } - run { (): Int -> 1 } + run{ "" } + run{ 1 } } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt index 8ebd4186041..231c8f79721 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt @@ -8,15 +8,11 @@ fun Array.forEach(operation: (T) -> Unit) : Unit { for (element in this) fun bar(operation: (String) -> Unit) = operation("") fun main(args: Array) { - args.forEach { (a : String) : Unit -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found - args.forEach { (a) : Unit -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found - args.forEach { (a : String) -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found + args.forEach { a : String -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found args.forEach { a -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found args.forEach { it.length() } // This works! - bar { (a: String) : Unit -> a.length() } - bar { (a) : Unit -> a.length() } - bar { (a: String) -> a.length() } + bar { a: String -> a.length() } bar { a -> a.length() } bar { it.length() } } diff --git a/compiler/testData/diagnostics/tests/infos/SmartCasts.kt b/compiler/testData/diagnostics/tests/infos/SmartCasts.kt index e24b4187a1f..ceb0b43cd93 100644 --- a/compiler/testData/diagnostics/tests/infos/SmartCasts.kt +++ b/compiler/testData/diagnostics/tests/infos/SmartCasts.kt @@ -176,9 +176,15 @@ fun returnFunctionLiteralBlock(a: Any?): Function0 { if (a is Int) return { a } else return { 1 } } -fun returnFunctionLiteral(a: Any?): Function0 = - if (a is Int) { (): Int -> a } - else { () -> 1 } +fun returnFunctionLiteral(a: Any?): Function0 { + if (a is Int) return { -> a } + else return { -> 1 } +} + +fun returnFunctionLiteralDoesntWork(a: Any?): Function0 = + if (a is Int) { -> a } + else { -> 1 } + fun mergeSmartCasts(a: Any?) { if (a is String || a is Int) { diff --git a/compiler/testData/diagnostics/tests/infos/SmartCasts.txt b/compiler/testData/diagnostics/tests/infos/SmartCasts.txt index cb923a9e436..6abe1150e98 100644 --- a/compiler/testData/diagnostics/tests/infos/SmartCasts.txt +++ b/compiler/testData/diagnostics/tests/infos/SmartCasts.txt @@ -17,6 +17,7 @@ public fun illegalWhenBody(/*0*/ a: kotlin.Any): kotlin.Int public fun mergeSmartCasts(/*0*/ a: kotlin.Any?): kotlin.Unit public fun returnFunctionLiteral(/*0*/ a: kotlin.Any?): () -> kotlin.Int public fun returnFunctionLiteralBlock(/*0*/ a: kotlin.Any?): () -> kotlin.Int +public fun returnFunctionLiteralDoesntWork(/*0*/ a: kotlin.Any?): () -> kotlin.Int public fun toInt(/*0*/ i: kotlin.Int?): kotlin.Int public fun vars(/*0*/ a: kotlin.Any?): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/inline/propagation.kt b/compiler/testData/diagnostics/tests/inline/propagation.kt index e6205abf455..274f9256cf8 100644 --- a/compiler/testData/diagnostics/tests/inline/propagation.kt +++ b/compiler/testData/diagnostics/tests/inline/propagation.kt @@ -6,8 +6,8 @@ inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { } inline fun inlineFunWithInvokeClosure(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { - subInline({p: Int -> s(p)}, {Int.(p:Int) -> this.ext(p)}) - subNoInline({p: Int -> s(p)}, {Int.(p:Int) -> this.ext(p)}) + subInline({p: Int -> s(p)}, { p -> this.ext(p)}) + subNoInline({p: Int -> s(p)}, { p -> this.ext(p)}) } //No inline @@ -17,8 +17,8 @@ inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, noinline e } inline fun inlineFunWithInvokeClosureNoinline(noinline s: (p: Int) -> Unit, noinline ext: Int.(p: Int) -> Unit) { - subInline({p: Int -> s(p)}, {Int.(p:Int) -> this.ext(p)}) - subNoInline({p: Int -> s(p)}, {Int.(p:Int) -> this.ext(p)}) + subInline({p: Int -> s(p)}, { p -> this.ext(p)}) + subNoInline({p: Int -> s(p)}, { p -> this.ext(p)}) } //ext function @@ -28,8 +28,8 @@ inline fun Function1.inlineExt(ext: Int.(p: Int) -> Unit) { } inline fun Function1.inlineExtWithClosure(ext: Int.(p: Int) -> Unit) { - subInline({p: Int -> this(p)}, {Int.(p:Int) -> this.ext(p)}) - subNoInline({p: Int -> this(p)}, {Int.(p:Int) -> this.ext(p)}) + subInline({p: Int -> this(p)}, { p -> this.ext(p)}) + subNoInline({p: Int -> this(p)}, { p -> this.ext(p)}) } inline fun subInline(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {} diff --git a/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.kt b/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.kt index a1c0881c106..83262680064 100644 --- a/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.kt +++ b/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.kt @@ -14,12 +14,14 @@ fun B.b() { } } + fun test() { - b@ { B.() -> + fun without(f: T.() -> Unit): Unit = (null!!).f() + without() b@ { object : A { override fun foo() { this@b.bar() } } - } + } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/labels/labelsMustBeNamed.kt b/compiler/testData/diagnostics/tests/labels/labelsMustBeNamed.kt index cb1def0c60b..1433d5dd18b 100644 --- a/compiler/testData/diagnostics/tests/labels/labelsMustBeNamed.kt +++ b/compiler/testData/diagnostics/tests/labels/labelsMustBeNamed.kt @@ -1,5 +1,5 @@ fun foo(a: Any?): Int { - @{ () : Unit -> + @{ -> return@ } diff --git a/compiler/testData/diagnostics/tests/regressions/kt306.kt b/compiler/testData/diagnostics/tests/regressions/kt306.kt index 248cebd0177..dba4b547214 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt306.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt306.kt @@ -1,16 +1,17 @@ // KT-306 Ambiguity when different this's have same-looking functions fun test() { - {Foo.() -> - bar(); - {Barr.() -> + (fun Foo.() { + bar() + (fun Barr.() { this.bar() bar() - } - } - {Barr.() -> + }) + }) + (fun Barr.() { + this.bar() bar() - } + }) } class Foo { diff --git a/compiler/testData/diagnostics/tests/regressions/kt352.kt b/compiler/testData/diagnostics/tests/regressions/kt352.kt index 73887af05ae..f876e633d2d 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt352.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt352.kt @@ -2,18 +2,19 @@ package kt352 -val f : (Any) -> Unit = { () : Unit -> } //type mismatch +val f : (Any) -> Unit = { -> } //type mismatch fun foo() { - val f : (Any) -> Unit = { () : Unit -> } //!!! no error + val f : (Any) -> Unit = { -> } //!!! no error } class A() { - val f : (Any) -> Unit = { () : Unit -> } //type mismatch + val f : (Any) -> Unit = { -> } //type mismatch } //more tests -val g : () -> Unit = { (): Int -> 42 } +val g : () -> Unit = { 42 } +val gFunction : () -> Unit = fun(): Int = 1 val h : () -> Unit = { doSmth() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt352.txt b/compiler/testData/diagnostics/tests/regressions/kt352.txt index 7a54b87c6eb..25f17d1cc3e 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt352.txt +++ b/compiler/testData/diagnostics/tests/regressions/kt352.txt @@ -3,6 +3,7 @@ package package kt352 { public val f: (kotlin.Any) -> kotlin.Unit public val g: () -> kotlin.Unit + public val gFunction: () -> kotlin.Unit public val h: () -> kotlin.Unit public val testIt: (kotlin.Any) -> kotlin.Unit public fun doSmth(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiterals.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiterals.kt index 73b2db7fcf5..514962d5bc0 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiterals.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiterals.kt @@ -16,11 +16,11 @@ object A { fun foo(i: Int, f: (Int)->Int) = f(i) fun test() { - foo(1) { (x1: Int):Int -> - foo(2) { (x2: Int): Int -> - foo(3) { (x3: Int): Int -> - foo(4) { (x4: Int): Int -> - foo(5) { (x5: Int): Int -> + foo(1) { x1: Int -> + foo(2) { x2: Int -> + foo(3) { x3: Int -> + foo(4) { x4: Int -> + foo(5) { x5: Int -> x1 + x2 + x3 + x4 + x5 + A.iii } } diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralsOverload.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralsOverload.kt index 3cf7a1a7990..7b6e982c94d 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralsOverload.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralsOverload.kt @@ -17,11 +17,11 @@ fun foo(a: Any, f: (Any)->Int) = f(a) fun foo(i: Int, f: (Int)->Int) = f(i) fun test() { - foo(1) { (x1: Int):Int -> - foo(2) { (x2: Int): Int -> - foo(3) { (x3: Int): Int -> - foo(4) { (x4: Int): Int -> - foo(5) { (x5: Int): Int -> + foo(1) { x1: Int -> + foo(2) { x2: Int -> + foo(3) { x3: Int -> + foo(4) { x4: Int -> + foo(5) { x5: Int -> x1 + x2 + x3 + x4 + x5 + A.iii } } diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.dynamic.txt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.dynamic.txt index 01c682a07b4..9cb618d1b4b 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.dynamic.txt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.dynamic.txt @@ -5,8 +5,6 @@ public final fun foo(/*0*/ p0: (dynamic) -> dynamic): dynamic public final fun foo(/*0*/ p0: (dynamic, dynamic) -> dynamic): dynamic public final fun foo(/*0*/ p0: (dynamic, dynamic) -> dynamic): dynamic public final fun foo(/*0*/ p0: (dynamic, dynamic) -> dynamic): dynamic -public final fun foo(/*0*/ p0: (dynamic, dynamic) -> dynamic): dynamic -public final fun foo(/*0*/ p0: dynamic.(dynamic, dynamic) -> dynamic): dynamic public final fun foo(/*0*/ p0: () -> dynamic): dynamic public final fun foo(/*0*/ p0: (dynamic) -> dynamic): dynamic public final fun foo(/*0*/ p0: dynamic): dynamic diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt index 041fce0ae2f..49bc59a1630 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt @@ -7,17 +7,13 @@ fun test(d: dynamic) { d.foo { x -> } - d.foo { (x: Int) -> "" } + d.foo { x: Int -> "" } d.foo { x, y -> "" } - d.foo { (x: String, y: Int) -> "" } + d.foo { x: String, y: Int -> "" } - d.foo { (x, y: Int) -> "" } - - d.foo { (x: String, y: Int): Int -> "" } - - d.foo { String.(x: String, y: Int): Int -> length() } + d.foo { x, y: Int -> "" } d.foo({}) @@ -29,7 +25,7 @@ fun test(d: dynamic) { d.foo(label@ ({ x, y -> })) - d.foo((label@ ({ (x, y: Int) -> }))) + d.foo((label@ ({ x, y: Int -> }))) d.foo(({ x -> })) diff --git a/compiler/testData/resolve/Classifiers.resolve b/compiler/testData/resolve/Classifiers.resolve index 125189d5d45..8cdbe613573 100644 --- a/compiler/testData/resolve/Classifiers.resolve +++ b/compiler/testData/resolve/Classifiers.resolve @@ -8,7 +8,7 @@ package qualified_this { ~xx~val Int.xx get() = `xx`this : Int ~xx()~fun Int.xx() { `xx()`this : Int - val a = {Int.() -> `xx()`this`xx()`@xx + this} + val a = (fun Int.() = `xx()`this`xx()`@xx + this) } } diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt index b0714a6a5ab..56070008af7 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt @@ -1,5 +1,5 @@ fun foo(f: (T) -> String) {} fun test() { - foo { (x: Int) -> "$x"} + foo { x: Int -> "$x"} } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt index ff920577a7f..f6275bc3249 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt @@ -1,7 +1,7 @@ fun foo(f: (T) -> String) {} fun test() { - foo { (x: Int) -> "$x"} + foo { x: Int -> "$x"} } @@ -16,4 +16,4 @@ Extension receiver = NO_RECEIVER Value arguments mapping: -SUCCESS f : (Int) -> String = { (x: Int) -> "$x"} +SUCCESS f : (Int) -> String = { x: Int -> "$x"} diff --git a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java index 39ffa78e8b4..a0416498e2c 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java @@ -366,30 +366,30 @@ public class JetTypeCheckerTest extends JetLiteFixture { } public void testFunctionLiterals() throws Exception { - assertType("{() -> }", "() -> Unit"); - assertType("{() : Int -> }", "() -> Int"); - assertType("{() -> 1}", "() -> Int"); + assertType("{ -> }", "() -> Unit"); + assertType("fun(): Int = 1", "() -> Int"); + assertType("{ 1}", "() -> Int"); - assertType("{(a : Int) -> 1}", "(a : Int) -> Int"); - assertType("{(a : Int, b : String) -> 1}", "(a : Int, b : String) -> Int"); + assertType("{ a : Int -> 1}", "(a : Int) -> Int"); + assertType("{ a : Int, b : String -> 1}", "(a : Int, b : String) -> Int"); - assertType("{(a : Int) -> 1}", "(Int) -> Int"); - assertType("{(a : Int, b : String) -> 1}", "(Int, String) -> Int"); + assertType("{ a : Int -> 1}", "(Int) -> Int"); + assertType("{ a : Int, b : String -> 1}", "(Int, String) -> Int"); - assertType("{Any.() -> 1}", "Any.() -> Int"); + assertType("fun Any.(): Int = 1", "Any.() -> Int"); - assertType("{Any.(a : Int) -> 1}", "Any.(a : Int) -> Int"); - assertType("{Any.(a : Int, b : String) -> 1}", "Any.(a : Int, b : String) -> Int"); + assertType("fun Any.(a : Int) = 1", "Any.(a : Int) -> Int"); + assertType("fun Any.(a : Int, b : String) = 1", "Any.(a : Int, b : String) -> Int"); - assertType("{Any.(a : Int) -> 1}", "Any.(Int) -> Int"); - assertType("{Any.(a : Int, b : String) -> 1}", "Any.(Int, String) -> Int"); + assertType("fun Any.(a : Int) = 1", "Any.(Int) -> Int"); + assertType("fun Any.(a : Int, b : String) = 1", "Any.(Int, String) -> Int"); - assertType("{Any.(a : Int, b : String) -> b}", "Any.(Int, String) -> String"); + assertType("fun Any.(a : Int, b : String) = b", "Any.(Int, String) -> String"); } public void testBlocks() throws Exception { assertType("if (1) {val a = 1; a} else {null}", "Int?"); - assertType("if (1) {() -> val a = 1; a} else {() -> null}", "Function0"); + assertType("if (1) { -> val a = 1; a} else { -> null}", "Function0"); assertType("if (1) (fun (): Boolean { val a = 1; a; var b : Boolean; return b }) else null", "Function0?"); assertType("if (1) (fun (): Int { val a = 1; a; var b = a; return b }) else null", "Function0?"); } diff --git a/idea/idea-completion/testData/basic/common/CallLocalLambda.kt b/idea/idea-completion/testData/basic/common/CallLocalLambda.kt index 2b80b2c859e..8f8eb1abe30 100644 --- a/idea/idea-completion/testData/basic/common/CallLocalLambda.kt +++ b/idea/idea-completion/testData/basic/common/CallLocalLambda.kt @@ -4,7 +4,7 @@ class TestClass { } fun testFun() { - val lambda = {() -> TestClass() } + val lambda = { -> TestClass() } lambda(). } diff --git a/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt b/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt index b15f7823ff2..05ceab7ebdf 100644 --- a/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt +++ b/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt @@ -1,6 +1,6 @@ fun foo() { takeHandler1 { - takeHandler2({ (): String -> ret }) + takeHandler2({ -> ret }) } } diff --git a/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt.after b/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt.after index a981d8cbd7f..dd217a15d0e 100644 --- a/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt.after +++ b/idea/idea-completion/testData/handlers/keywords/QualifiedReturnNonUnitExplicit.kt.after @@ -1,6 +1,6 @@ fun foo() { takeHandler1 { - takeHandler2({ (): String -> return@takeHandler2 }) + takeHandler2({ -> return@takeHandler2 }) } } diff --git a/idea/idea-completion/testData/smart/multipleArgsItem/8.kt b/idea/idea-completion/testData/smart/multipleArgsItem/8.kt index c85508a907e..b13cef11490 100644 --- a/idea/idea-completion/testData/smart/multipleArgsItem/8.kt +++ b/idea/idea-completion/testData/smart/multipleArgsItem/8.kt @@ -3,7 +3,7 @@ fun foo(a: Int, b: String) {} fun f(p: (Int, String) -> Unit){} fun bar() { - f { (a, b) -> foo() } + f { a, b -> foo() } } // EXIST: "a, b" diff --git a/idea/testData/diagnosticMessage/functionPlaceholder.kt b/idea/testData/diagnosticMessage/functionPlaceholder.kt index 6528f3994ec..01642366b71 100644 --- a/idea/testData/diagnosticMessage/functionPlaceholder.kt +++ b/idea/testData/diagnosticMessage/functionPlaceholder.kt @@ -7,5 +7,5 @@ fun foo(a: A) = a fun test() { foo { it } foo { x -> x} - foo { (x: Int) -> x} + foo { x: Int -> x} } \ No newline at end of file diff --git a/idea/testData/formatter/ColonSpaces.after.inv.kt b/idea/testData/formatter/ColonSpaces.after.inv.kt index c4dcc8fbd4e..46970c861bb 100644 --- a/idea/testData/formatter/ColonSpaces.after.inv.kt +++ b/idea/testData/formatter/ColonSpaces.after.inv.kt @@ -1,6 +1,6 @@ fun foo() { val (i :Int, s :String) = bar() - val h = {() :Unit -> bar() } + val h = { -> bar() } for (i :Int in collection) { } } diff --git a/idea/testData/formatter/ColonSpaces.after.kt b/idea/testData/formatter/ColonSpaces.after.kt index a4cec627a6b..533dc82f59a 100644 --- a/idea/testData/formatter/ColonSpaces.after.kt +++ b/idea/testData/formatter/ColonSpaces.after.kt @@ -1,6 +1,6 @@ fun foo() { val (i: Int, s: String) = bar() - val h = {(): Unit -> bar() } + val h = { -> bar() } for (i: Int in collection) { } } diff --git a/idea/testData/formatter/ColonSpaces.kt b/idea/testData/formatter/ColonSpaces.kt index 4d4e8c734fb..68cacdc1f87 100644 --- a/idea/testData/formatter/ColonSpaces.kt +++ b/idea/testData/formatter/ColonSpaces.kt @@ -1,6 +1,6 @@ fun foo() { val (i:Int,s:String) = bar() - val h = {():Unit -> bar()} + val h = { -> bar()} for (i:Int in collection) { } } diff --git a/idea/testData/formatter/ReturnExpression.after.kt b/idea/testData/formatter/ReturnExpression.after.kt index fe2558f66e6..46befcd04ba 100644 --- a/idea/testData/formatter/ReturnExpression.after.kt +++ b/idea/testData/formatter/ReturnExpression.after.kt @@ -16,19 +16,19 @@ fun test3(): Int { } fun test4(): Int { - return synchronized(this) {(): Int -> + return synchronized(this) { -> return@synchronized 12 } } fun test5(): Int { - return synchronized(this) {(): Int -> + return synchronized(this) { -> return@synchronized 12 } } fun test6(): Int { - return synchronized(this) {(): Int -> + return synchronized(this) { -> return @synchronized diff --git a/idea/testData/formatter/ReturnExpression.kt b/idea/testData/formatter/ReturnExpression.kt index 94b952e7cfb..1eaa34573ef 100644 --- a/idea/testData/formatter/ReturnExpression.kt +++ b/idea/testData/formatter/ReturnExpression.kt @@ -16,19 +16,19 @@ fun test3(): Int { } fun test4(): Int { - return synchronized(this) {(): Int -> + return synchronized(this) { -> return@synchronized 12 } } fun test5(): Int { - return synchronized(this) {(): Int -> + return synchronized(this) { -> return @synchronized 12 } } fun test6(): Int { - return synchronized(this) {(): Int -> + return synchronized(this) { -> return @synchronized diff --git a/idea/testData/formatter/SingleLineFunctionLiteral.after.inv.kt b/idea/testData/formatter/SingleLineFunctionLiteral.after.inv.kt index 54adfac48da..3f970fe8165 100644 --- a/idea/testData/formatter/SingleLineFunctionLiteral.after.inv.kt +++ b/idea/testData/formatter/SingleLineFunctionLiteral.after.inv.kt @@ -2,7 +2,7 @@ fun test(some: (Int) -> Int) { } fun foo() = test() {it} -val function = test {(a: Int) -> a} +val function = test {a: Int -> a} val function1 = test {a: Int -> a} val function2 = test { } val function3 = test {} diff --git a/idea/testData/formatter/SingleLineFunctionLiteral.after.kt b/idea/testData/formatter/SingleLineFunctionLiteral.after.kt index c4bf6358109..c12ded3981f 100644 --- a/idea/testData/formatter/SingleLineFunctionLiteral.after.kt +++ b/idea/testData/formatter/SingleLineFunctionLiteral.after.kt @@ -2,7 +2,7 @@ fun test(some: (Int) -> Int) { } fun foo() = test() { it } -val function = test {(a: Int) -> a } +val function = test { a: Int -> a } val function1 = test { a: Int -> a } val function2 = test { } val function3 = test {} diff --git a/idea/testData/formatter/SingleLineFunctionLiteral.kt b/idea/testData/formatter/SingleLineFunctionLiteral.kt index 9167be85bb9..e5c156192c2 100644 --- a/idea/testData/formatter/SingleLineFunctionLiteral.kt +++ b/idea/testData/formatter/SingleLineFunctionLiteral.kt @@ -2,7 +2,7 @@ fun test(some: (Int) -> Int) { } fun foo() = test() { it } -val function = test { (a: Int) -> a } +val function = test { a: Int -> a } val function1 = test {a : Int -> a} val function2 = test { } val function3 = test {} diff --git a/idea/testData/formatter/UnnecessarySpacesInParametersLists.after.kt b/idea/testData/formatter/UnnecessarySpacesInParametersLists.after.kt index 7c6a18daa97..dbcf02d194a 100644 --- a/idea/testData/formatter/UnnecessarySpacesInParametersLists.after.kt +++ b/idea/testData/formatter/UnnecessarySpacesInParametersLists.after.kt @@ -1,4 +1,4 @@ -fun test(a: Int) = {(a: Int) -> a } +fun test(a: Int) = { a: Int -> a } class Test fun foo() { diff --git a/idea/testData/formatter/UnnecessarySpacesInParametersLists.kt b/idea/testData/formatter/UnnecessarySpacesInParametersLists.kt index 43f70d70145..007fc50edcf 100644 --- a/idea/testData/formatter/UnnecessarySpacesInParametersLists.kt +++ b/idea/testData/formatter/UnnecessarySpacesInParametersLists.kt @@ -1,4 +1,4 @@ -fun < T > test( a: Int ) = {( a: Int ) -> a } +fun < T > test( a: Int ) = { a: Int -> a } class Test< T > fun foo( ) { diff --git a/idea/testData/intentions/specifyTypeExplicitly/lambdaParam.kt b/idea/testData/intentions/specifyTypeExplicitly/lambdaParam.kt index 54015f0a1fd..183d1f84587 100644 --- a/idea/testData/intentions/specifyTypeExplicitly/lambdaParam.kt +++ b/idea/testData/intentions/specifyTypeExplicitly/lambdaParam.kt @@ -1,4 +1,4 @@ // IS_APPLICABLE: false fun foo(): Any { - return { (x: String) -> 42 } + return { x: String -> 42 } } \ No newline at end of file diff --git a/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt b/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt index 105eae3a6a6..d5bf1872028 100644 --- a/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt +++ b/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt @@ -1,3 +1,3 @@ fun f() { - val f = { (x: Int) -> x + x } + val f = { x: Int -> x + x } } \ No newline at end of file diff --git a/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt.after b/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt.after index ab1c823d4d4..71b04dd9eca 100644 --- a/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt.after +++ b/idea/testData/refactoring/rename/inplace/FunctionLiteralParenthesis.kt.after @@ -1,3 +1,3 @@ fun f() { - val f = { (y: Int) -> y + y } + val f = { y: Int -> y + y } } \ No newline at end of file diff --git a/idea/testData/resolve/partialBodyResolve/Lambda.dump b/idea/testData/resolve/partialBodyResolve/Lambda.dump index 74133442e12..eb89a7deae8 100644 --- a/idea/testData/resolve/partialBodyResolve/Lambda.dump +++ b/idea/testData/resolve/partialBodyResolve/Lambda.dump @@ -5,6 +5,6 @@ class C { } fun foo() { - val lambda = {() -> /* STATEMENT DELETED: x() */; C() } + val lambda = { -> /* STATEMENT DELETED: x() */; C() } lambda().f() } diff --git a/idea/testData/resolve/partialBodyResolve/Lambda.kt b/idea/testData/resolve/partialBodyResolve/Lambda.kt index b7914432530..31c5051971d 100644 --- a/idea/testData/resolve/partialBodyResolve/Lambda.kt +++ b/idea/testData/resolve/partialBodyResolve/Lambda.kt @@ -3,6 +3,6 @@ class C { } fun foo() { - val lambda = {() -> x(); C() } + val lambda = { -> x(); C() } lambda().f() } diff --git a/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt b/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt index a321ede61ac..3ea93476ac3 100644 --- a/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt +++ b/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt @@ -1,29 +1,23 @@ fun foo(f: (Int) -> Unit) { - { (m: Int, n: Int, s: String) -> + { m: Int, n: Int, s: String -> val a = n + m println(s) f(a) } - { (n: Int, s: String) -> + { n: Int, s: String -> val a = n + 1 println(s) f(a) } - { Int.(n: Int, s: String) -> + val q: Int.(Int, String) -> Unit = { n: Int, s: String -> val a = n + this println(s) f(a) } - { Int.(m: Int, r: String) -> - val b = m + this - println(r) - f(b) - } - - val g: Int.(Int, String) -> Unit = { (a, b) -> + val g: Int.(Int, String) -> Unit = { a, b -> val m = a + this println(b) f(m) diff --git a/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt.match b/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt.match index c0c44666ce8..215df4e1551 100644 --- a/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt.match +++ b/idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt.match @@ -1,16 +1,10 @@ -{ Int.(n: Int, s: String) -> +{ n: Int, s: String -> val a = n + this println(s) f(a) } -{ Int.(m: Int, r: String) -> - val b = m + this - println(r) - f(b) - } - -{ (a, b) -> +{ a, b -> val m = a + this println(b) f(m) diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberAndNonExtensionCompatibility.kt b/js/js.translator/testData/callableReference/function/cases/classMemberAndNonExtensionCompatibility.kt index 9bb628371d3..5b994297c34 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberAndNonExtensionCompatibility.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberAndNonExtensionCompatibility.kt @@ -25,7 +25,7 @@ fun box():String { r = run(a, "!!", A::locExtBar) if (r != "sA:locExtBar:!!") return r - r = run(a, "!!") {(a: A, other: String): String -> a.s + ":literal:" + other } + r = run(a, "!!") { a: A, other: String -> a.s + ":literal:" + other } if (r != "sA:literal:!!") return r return "OK" diff --git a/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt b/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt index 9ccfd7ef4e1..9c434b73d4d 100644 --- a/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt +++ b/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt @@ -5,7 +5,7 @@ fun Int.sum0(other: Int): Int = this + other fun box(): String { fun Int.sum1(other: Int): Int = this + other - val sum2 = {Int.(other : Int) : Int -> this + other} + val sum2 = fun Int.(other: Int): Int = this + other var x = 10 x = x.sum0(5) diff --git a/js/js.translator/testData/examples/cases/closureWithParameter.kt b/js/js.translator/testData/examples/cases/closureWithParameter.kt index 66734c13a79..4c502ba2925 100644 --- a/js/js.translator/testData/examples/cases/closureWithParameter.kt +++ b/js/js.translator/testData/examples/cases/closureWithParameter.kt @@ -1,5 +1,5 @@ fun box(): String { - return apply("OK", {(arg: String) -> arg }) + return apply("OK", { arg: String -> arg }) } fun apply(arg: String, f: (p: String) -> String): String { diff --git a/js/js.translator/testData/examples/cases/closureWithParameterAndBoxing.kt b/js/js.translator/testData/examples/cases/closureWithParameterAndBoxing.kt index 9b3401b9d7b..a77375d6bac 100644 --- a/js/js.translator/testData/examples/cases/closureWithParameterAndBoxing.kt +++ b/js/js.translator/testData/examples/cases/closureWithParameterAndBoxing.kt @@ -1,5 +1,5 @@ fun box(): String { - return if (apply(5) {(arg: Int) -> arg + 13 } == 18) "OK" else "fail" + return if (apply(5) { arg: Int -> arg + 13 } == 18) "OK" else "fail" } fun apply(arg: Int, f: (p: Int) -> Int): Int { diff --git a/js/js.translator/testData/examples/cases/extensionClosure.kt b/js/js.translator/testData/examples/cases/extensionClosure.kt index c566a427b75..3831e15b6c1 100644 --- a/js/js.translator/testData/examples/cases/extensionClosure.kt +++ b/js/js.translator/testData/examples/cases/extensionClosure.kt @@ -1,7 +1,7 @@ class Point(val x: Int, val y: Int) fun box(): String { - val answer = apply(Point(3, 5), { Point.(scalar: Int): Point -> + val answer = apply(Point(3, 5), { scalar: Int -> Point(x * scalar, y * scalar) }) diff --git a/js/js.translator/testData/expression/function/cases/expressionAsExtFunction.kt b/js/js.translator/testData/expression/function/cases/expressionAsExtFunction.kt index 66c80d30e75..5434e9352d6 100644 --- a/js/js.translator/testData/expression/function/cases/expressionAsExtFunction.kt +++ b/js/js.translator/testData/expression/function/cases/expressionAsExtFunction.kt @@ -1,7 +1,7 @@ package foo fun box(): String { - val a = 23.{ Int.(a: Int) -> a * a + this }(3) + val a = 23.(fun Int.(a: Int): Int = a * a + this)(3) if (a != 32) return "a != 32, a = $a"; return "OK"; diff --git a/js/js.translator/testData/expression/function/cases/functionExpression.kt b/js/js.translator/testData/expression/function/cases/functionExpression.kt index 2914b6858dc..9a4422a22c2 100644 --- a/js/js.translator/testData/expression/function/cases/functionExpression.kt +++ b/js/js.translator/testData/expression/function/cases/functionExpression.kt @@ -16,11 +16,11 @@ fun box(): Any? { if ( (10.foo1())() != "23910") return "foo1 fail" if ( (10.foo2())(1) != 11 ) return "foo2 fail" - if (1.{ Int.() -> this + 1 }() != 2) return "test 3 failed"; + if (1.(fun Int.(): Int = this + 1)() != 2) return "test 3 failed"; if ( { 1 }() != 1) return "test 4 failed"; if ( { x: Int -> x }(1) != 1) return "test 5 failed"; - if ( 1.{ Int.(x: Int) -> x + this }(1) != 2) return "test 6 failed"; - val tmp = 1.({ Int.() -> this })() + if ( 1.(fun Int.(x: Int): Int = x + this)(1) != 2) return "test 6 failed"; + val tmp = 1.(fun Int.(): Int = this)() if (+tmp != 1) return "test 7 failed, res: $tmp ${tmp is Int}"; if ( (fooT1("mama"))() != "mama") return "test 8 failed"; if ( (fooT2("mama"))("papa") != "mamapapa") return "test 9 failed"; diff --git a/js/js.translator/testData/expression/function/cases/infixCall.kt b/js/js.translator/testData/expression/function/cases/infixCall.kt index 7687cb63e6a..cdb75d00d23 100644 --- a/js/js.translator/testData/expression/function/cases/infixCall.kt +++ b/js/js.translator/testData/expression/function/cases/infixCall.kt @@ -3,12 +3,12 @@ package foo fun Int.foo(a: Int) = this + a -val bar = { Int.(a: Int) -> this * a } +val bar = fun Int.(a: Int): Int = this * a fun test(op: Int.(Int) -> Int) = 3 op 20 fun box(): String { - val op = { Int.(a: Int) -> this / a } + val op = fun Int.(a: Int): Int = this / a assertEquals(41, 34 foo 7) assertEquals(28, 4 bar 7) diff --git a/js/js.translator/testData/expression/function/cases/manglingStability.kt b/js/js.translator/testData/expression/function/cases/manglingStability.kt index f917fbf5afa..a077b9c1902 100644 --- a/js/js.translator/testData/expression/function/cases/manglingStability.kt +++ b/js/js.translator/testData/expression/function/cases/manglingStability.kt @@ -124,8 +124,8 @@ public val A.boo: Int get() = 1 public fun A.boo(): Int = 2 -val public_ext_f = { A.(): Int -> this.foo() + this.foo } -val public_ext_b = { A.(): Int -> this.boo() + this.boo } +val public_ext_f: A.() -> Int = { -> this.foo() + this.foo } +val public_ext_b: A.() -> Int = { -> this.boo() + this.boo } interface TestPublicInTrait { public fun foo(): Int = 2 diff --git a/js/js.translator/testData/expression/invoke/cases/invokeInExtensionFunctionLiteral.kt b/js/js.translator/testData/expression/invoke/cases/invokeInExtensionFunctionLiteral.kt index bb42317963c..9a44c19b751 100644 --- a/js/js.translator/testData/expression/invoke/cases/invokeInExtensionFunctionLiteral.kt +++ b/js/js.translator/testData/expression/invoke/cases/invokeInExtensionFunctionLiteral.kt @@ -1,9 +1,9 @@ package foo fun box(): Boolean { - val v1 = 1.{ Int.(x: Int) -> this + x }(2) + val v1 = 1.(fun Int.(x: Int) = this + x)(2) - val f = { Int.(x: Int) -> this + x } + val f = fun Int.(x: Int) = this + x val v2 = 1.(f)(2) return v1 == 3 && v2 == 3 diff --git a/js/js.translator/testData/extensionFunction/cases/extensionInsideFunctionLiteral.kt b/js/js.translator/testData/extensionFunction/cases/extensionInsideFunctionLiteral.kt index 1b09621fbd7..c01257b0820 100644 --- a/js/js.translator/testData/extensionFunction/cases/extensionInsideFunctionLiteral.kt +++ b/js/js.translator/testData/extensionFunction/cases/extensionInsideFunctionLiteral.kt @@ -5,7 +5,7 @@ class M() { fun eval() { var d = { - var c = { Int.() -> this + 3 } + var c = fun Int.(): Int = this + 3 m += 3.c() } d(); diff --git a/js/js.translator/testData/inline/cases/extension.kt b/js/js.translator/testData/inline/cases/extension.kt index 6be7b29df66..4f1ec0851d5 100644 --- a/js/js.translator/testData/inline/cases/extension.kt +++ b/js/js.translator/testData/inline/cases/extension.kt @@ -42,7 +42,7 @@ fun test1(): Int { fun test2(): Int { val inlineX = Inline(9) - return inlineX.calcExt2({Int.() -> this}, 25) + return inlineX.calcExt2({ -> this}, 25) } fun test3(): Int { diff --git a/js/js.translator/testData/inlineMultiFile/cases/closureChain/closureChain.1.kt b/js/js.translator/testData/inlineMultiFile/cases/closureChain/closureChain.1.kt index 8de117c2308..3866655ffe7 100644 --- a/js/js.translator/testData/inlineMultiFile/cases/closureChain/closureChain.1.kt +++ b/js/js.translator/testData/inlineMultiFile/cases/closureChain/closureChain.1.kt @@ -7,7 +7,7 @@ package foo fun test1(): Int { val inlineX = Inline() - return inlineX.foo({ z: Int -> "" + z}, 25, { String.() -> this.length() }) + return inlineX.foo({ z: Int -> "" + z}, 25, { -> this.length() }) } fun box(): String { diff --git a/js/js.translator/testData/operatorOverloading/cases/overloadByLambda.kt b/js/js.translator/testData/operatorOverloading/cases/overloadByLambda.kt index 177e11ebf13..1759fb741c5 100644 --- a/js/js.translator/testData/operatorOverloading/cases/overloadByLambda.kt +++ b/js/js.translator/testData/operatorOverloading/cases/overloadByLambda.kt @@ -3,12 +3,12 @@ package foo class A(val v: Int) -val times = { A.(a: Int) -> this.v * a } +val times: A.(Int) -> Int = { a -> this.v * a } fun test(div: A.(Int) -> Int) = A(20) / 4 fun box(): String { - val compareTo = { A.(a: A) -> this.v - a.v } + val compareTo: A.(A) -> Int = { a: A -> this.v - a.v } assertEquals(28, A(4) * 7) assertEquals(5, test { this.v / it })