Replace deprecated lambda syntax in testData

It's done with similar constructions where possible trying to preserve
intended behavior.
Some usages are removed because they test exactly the feature that
we are going to drop soon.
This commit is contained in:
Denis Zharkov
2015-09-23 20:07:06 +03:00
parent 5f69789636
commit 73799e2c3c
73 changed files with 325 additions and 340 deletions
@@ -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 <START> 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) -> <v0> INIT: in: {a=D} out: {a=D}
w(a|<v0>) 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 <START> 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) -> <v0> INIT: in: {a=D} out: {a=D}
w(a|<v0>) 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) }) -> <v1>
w(f|<v1>) INIT: in: {a=ID, f=D} out: {a=ID, f=ID}
r({ x: Int -> val y = x + a use(a) }) -> <v1>
w(f|<v1>) INIT: in: {a=ID, f=D} out: {a=ID, f=ID}
L1:
1 <END> INIT: in: {} out: {}
1 <END> INIT: in: {} out: {}
error:
<ERROR>
sink:
<SINK> USE: in: {} out: {}
<SINK> USE: in: {} out: {}
=====================
== anonymous_0 ==
{ (x: Int) ->
{ x: Int ->
val y = x + a
use(a)
}
@@ -1,6 +1,6 @@
fun foo() {
val a = 1
val f = { (x: Int) ->
val f = { x: Int ->
val y = x + a
use(a)
}
@@ -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 <v0>: Int NEW: r(1) -> <v0>
{ (x: Int) -> val y = x + a use(a) } <v1>: {<: (Int) -> Array<out Any?>} NEW: r({ (x: Int) -> val y = x + a use(a) }) -> <v1>
1 <v0>: Int NEW: r(1) -> <v0>
{ x: Int -> val y = x + a use(a) } <v1>: {<: (Int) -> Array<out Any?>} NEW: r({ x: Int -> val y = x + a use(a) }) -> <v1>
=====================
== anonymous_0 ==
{ (x: Int) ->
{ x: Int ->
val y = x + a
use(a)
}
@@ -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 <START> 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 <START> 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 }) -> <v0>
w(sum|<v0>) INIT: in: {sum=D} out: {sum=ID}
r({ x: Int -> sum(x - 1) + x }) -> <v0>
w(sum|<v0>) INIT: in: {sum=D} out: {sum=ID}
L1:
<END> INIT: in: {sum=ID} out: {sum=ID}
<END> INIT: in: {sum=ID} out: {sum=ID}
error:
<ERROR> INIT: in: {} out: {}
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {sum=I?D} out: {sum=I?D} USE: in: {} out: {}
<SINK> INIT: in: {sum=I?D} out: {sum=I?D} USE: in: {} out: {}
=====================
== anonymous_0 ==
{ (x: Int) ->
{ x: Int ->
sum(x - 1) + x
}
---------------------
@@ -1,5 +1,5 @@
class TestFunctionLiteral {
val sum: (Int)->Int = { (x: Int) ->
val sum: (Int)->Int = { x: Int ->
sum(x - 1) + x
}
}
@@ -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 } <v0>: {<: (Int) -> Int} NEW: r({ (x: Int) -> sum(x - 1) + x }) -> <v0>
{ x: Int -> sum(x - 1) + x } <v0>: {<: (Int) -> Int} NEW: r({ x: Int -> sum(x - 1) + x }) -> <v0>
=====================
== anonymous_0 ==
{ (x: Int) ->
{ x: Int ->
sum(x - 1) + x
}
---------------------
<v0>: Int NEW: magic[FAKE_INITIALIZER](x: Int) -> <v0>
<v1>: TestFunctionLiteral NEW: magic[IMPLICIT_RECEIVER](sum) -> <v1>
sum <v2>: {<: (Int) -> Int} NEW: r(sum|<v1>) -> <v2>
x <v3>: Int NEW: r(x) -> <v3>
1 <v4>: Int NEW: r(1) -> <v4>
x - 1 <v5>: Int NEW: call(x - 1, minus|<v3>, <v4>) -> <v5>
sum(x - 1) <v6>: Int NEW: call(sum(x - 1), invoke|<v2>, <v5>) -> <v6>
x <v7>: Int NEW: r(x) -> <v7>
<v0>: Int NEW: magic[FAKE_INITIALIZER](x: Int) -> <v0>
<v1>: TestFunctionLiteral NEW: magic[IMPLICIT_RECEIVER](sum) -> <v1>
sum <v2>: {<: (Int) -> Int} NEW: r(sum|<v1>) -> <v2>
x <v3>: Int NEW: r(x) -> <v3>
1 <v4>: Int NEW: r(1) -> <v4>
x - 1 <v5>: Int NEW: call(x - 1, minus|<v3>, <v4>) -> <v5>
sum(x - 1) <v6>: Int NEW: call(sum(x - 1), invoke|<v2>, <v5>) -> <v6>
x <v7>: Int NEW: r(x) -> <v7>
sum(x - 1) + x <v8>: Int NEW: call(sum(x - 1) + x, plus|<v6>, <v7>) -> <v8>
sum(x - 1) + x <v8>: Int COPY
sum(x - 1) + x <v8>: Int COPY
=====================
== A ==
open class A(val a: A)
@@ -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 <START> INIT: in: {} out: {} USE: in: {} out: {}
2 mark({ "before" val b = 1 val f = { (x: Int) -> val a = x + b } "after" })
1 <START> 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") -> <v0>
v(val b = 1) INIT: in: {} out: {b=D}
r(1) -> <v1> INIT: in: {b=D} out: {b=D}
w(b|<v1>) 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) -> <v1> INIT: in: {b=D} out: {b=D}
w(b|<v1>) 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 }) -> <v2>
w(f|<v2>) 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 }) -> <v2>
w(f|<v2>) 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") -> <v3>
L1:
1 <END> INIT: in: {} out: {}
1 <END> INIT: in: {} out: {}
error:
<ERROR>
sink:
<SINK> USE: in: {} out: {}
<SINK> USE: in: {} out: {}
=====================
== anonymous_0 ==
{ (x: Int) ->
{ x: Int ->
val a = x + b
}
---------------------
@@ -55,4 +55,4 @@ error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
=====================
=====================
@@ -1,7 +1,7 @@
fun foo() {
"before"
val b = 1
val f = { (x: Int) ->
val f = { x: Int ->
val a = x + b
}
"after"
@@ -2,20 +2,20 @@
fun foo() {
"before"
val b = 1
val f = { (x: Int) ->
val f = { x: Int ->
val a = x + b
}
"after"
}
---------------------
"before" <v0>: * NEW: r("before") -> <v0>
1 <v1>: Int NEW: r(1) -> <v1>
{ (x: Int) -> val a = x + b } <v2>: {<: (Int) -> Unit} NEW: r({ (x: Int) -> val a = x + b }) -> <v2>
"after" <v3>: * NEW: r("after") -> <v3>
{ "before" val b = 1 val f = { (x: Int) -> val a = x + b } "after" } <v3>: * COPY
"before" <v0>: * NEW: r("before") -> <v0>
1 <v1>: Int NEW: r(1) -> <v1>
{ x: Int -> val a = x + b } <v2>: {<: (Int) -> Unit} NEW: r({ x: Int -> val a = x + b }) -> <v2>
"after" <v3>: * NEW: r("after") -> <v3>
{ "before" val b = 1 val f = { x: Int -> val a = x + b } "after" } <v3>: * COPY
=====================
== anonymous_0 ==
{ (x: Int) ->
{ x: Int ->
val a = x + b
}
---------------------
+30 -30
View File
@@ -89,7 +89,7 @@ sink:
fun t3() {
try {
1
l@{ () ->
l@{ ->
if (2 > 3) {
return@l
}
@@ -101,38 +101,38 @@ fun t3() {
---------------------
L0:
1 <START>
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) -> <v0>
mark(l@{ () -> if (2 > 3) { return@l } })
mark({ () -> if (2 > 3) { return@l } })
jmp?(L3) NEXT:[r({ () -> if (2 > 3) { return@l } }) -> <v1>, d({ () -> if (2 > 3) { return@l } })]
d({ () -> if (2 > 3) { return@l } }) NEXT:[<SINK>]
mark(l@{ -> if (2 > 3) { return@l } })
mark({ -> if (2 > 3) { return@l } })
jmp?(L3) NEXT:[r({ -> if (2 > 3) { return@l } }) -> <v1>, d({ -> if (2 > 3) { return@l } })]
d({ -> if (2 > 3) { return@l } }) NEXT:[<SINK>]
L3 [after local declaration]:
r({ () -> if (2 > 3) { return@l } }) -> <v1> PREV:[jmp?(L3)]
2 jmp(L8) NEXT:[mark({ 2 })]
r({ -> if (2 > 3) { return@l } }) -> <v1> 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) -> <v2>
L10 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
2 jmp(error) NEXT:[<ERROR>]
L8 [skipFinallyToErrorBlock]:
L11 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ 2 }) PREV:[jmp(L8)]
3 mark({ 2 }) PREV:[jmp(L8)]
r(2) -> <v2>
2 merge(try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 }|<v1>) -> <v3>
2 merge(try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 }|<v1>) -> <v3>
L1:
1 <END> NEXT:[<SINK>]
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[jmp(error)]
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>, d({ () -> if (2 > 3) { return@l } })]
<SINK> PREV:[<ERROR>, <END>, 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 <START>
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 } }) -> <v0>, d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })]
d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) NEXT:[<SINK>]
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 } }) -> <v0>, d({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } })]
d({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) NEXT:[<SINK>]
L2 [after local declaration]:
r({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> <v0> PREV:[jmp?(L2)]
r({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> <v0> PREV:[jmp?(L2)]
L1:
1 <END> NEXT:[<SINK>]
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>, d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })]
<SINK> PREV:[<ERROR>, <END>, d({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } })]
=====================
== anonymous_1 ==
{ () ->
{ ->
try {
1
if (2 > 3) {
+2 -2
View File
@@ -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) {
+75 -75
View File
@@ -43,7 +43,7 @@ try { 1 if (2 > 3) { return } } finally { 2 } <v7>: *
fun t3() {
try {
1
l@{ () ->
l@{ ->
if (2 > 3) {
return@l
}
@@ -53,33 +53,33 @@ fun t3() {
}
}
---------------------
1 <v0>: * NEW: r(1) -> <v0>
{ () -> if (2 > 3) { return@l } } <v1>: * NEW: r({ () -> if (2 > 3) { return@l } }) -> <v1>
l@{ () -> if (2 > 3) { return@l } } <v1>: * COPY
{ 1 l@{ () -> if (2 > 3) { return@l } } } <v1>: * COPY
2 <v2>: * NEW: r(2) -> <v2>
{ 2 } <v2>: * COPY
try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 } <v3>: * NEW: merge(try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 }|<v1>) -> <v3>
{ try { 1 l@{ () -> if (2 > 3) { return@l } } } finally { 2 } } <v3>: * COPY
1 <v0>: * NEW: r(1) -> <v0>
{ -> if (2 > 3) { return@l } } <v1>: * NEW: r({ -> if (2 > 3) { return@l } }) -> <v1>
l@{ -> if (2 > 3) { return@l } } <v1>: * COPY
{ 1 l@{ -> if (2 > 3) { return@l } } } <v1>: * COPY
2 <v2>: * NEW: r(2) -> <v2>
{ 2 } <v2>: * COPY
try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 } <v3>: * NEW: merge(try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 }|<v1>) -> <v3>
{ try { 1 l@{ -> if (2 > 3) { return@l } } } finally { 2 } } <v3>: * COPY
=====================
== anonymous_0 ==
{ () ->
{ ->
if (2 > 3) {
return@l
}
}
---------------------
2 <v0>: {<: Comparable<Int>} NEW: r(2) -> <v0>
3 <v1>: Int NEW: r(3) -> <v1>
2 > 3 <v2>: Boolean NEW: call(2 > 3, compareTo|<v0>, <v1>) -> <v2>
return@l !<v3>: *
{ return@l } !<v3>: * COPY
2 <v0>: {<: Comparable<Int>} NEW: r(2) -> <v0>
3 <v1>: Int NEW: r(3) -> <v1>
2 > 3 <v2>: Boolean NEW: call(2 > 3, compareTo|<v0>, <v1>) -> <v2>
return@l !<v3>: *
{ return@l } !<v3>: * COPY
if (2 > 3) { return@l } <v4>: * NEW: merge(if (2 > 3) { return@l }|!<v3>) -> <v4>
if (2 > 3) { return@l } <v4>: * 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 } } <v0>: * NEW: r({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> <v0>
l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } <v0>: * COPY
{ l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } } <v0>: * COPY
{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } } <v0>: * NEW: r({ -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) -> <v0>
l@{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } } <v0>: * COPY
{ l@{ -> try { 1 if (2 > 3) { return@l } } finally { 2 } } } <v0>: * COPY
=====================
== anonymous_1 ==
{ () ->
{ ->
try {
1
if (2 > 3) {
@@ -107,16 +107,16 @@ l@{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } <v0>: * COPY
}
}
---------------------
1 <v0>: * NEW: r(1) -> <v0>
2 <v1>: {<: Comparable<Int>} NEW: r(2) -> <v1>
3 <v2>: Int NEW: r(3) -> <v2>
2 > 3 <v3>: Boolean NEW: call(2 > 3, compareTo|<v1>, <v2>) -> <v3>
return@l !<v5>: *
{ return@l } !<v5>: * COPY
1 <v0>: * NEW: r(1) -> <v0>
2 <v1>: {<: Comparable<Int>} NEW: r(2) -> <v1>
3 <v2>: Int NEW: r(3) -> <v2>
2 > 3 <v3>: Boolean NEW: call(2 > 3, compareTo|<v1>, <v2>) -> <v3>
return@l !<v5>: *
{ return@l } !<v5>: * COPY
if (2 > 3) { return@l } <v6>: * NEW: merge(if (2 > 3) { return@l }|!<v5>) -> <v6>
{ 1 if (2 > 3) { return@l } } <v6>: * COPY
2 <v4>: * NEW: r(2) -> <v4>
{ 2 } <v4>: * COPY
2 <v4>: * NEW: r(2) -> <v4>
{ 2 } <v4>: * COPY
try { 1 if (2 > 3) { return@l } } finally { 2 } <v7>: * NEW: merge(try { 1 if (2 > 3) { return@l } } finally { 2 }|<v6>) -> <v7>
try { 1 if (2 > 3) { return@l } } finally { 2 } <v7>: * COPY
=====================
@@ -140,17 +140,17 @@ true <v0>: Bo
2 <v3>: {<: Comparable<Int>} NEW: r(2) -> <v3>
3 <v4>: Int NEW: r(3) -> <v4>
2 > 3 <v5>: Boolean NEW: call(2 > 3, compareTo|<v3>, <v4>) -> <v5>
break@l !<v7>: *
{ break@l } !<v7>: * COPY
if (2 > 3) { break@l } <v8>: * NEW: merge(if (2 > 3) { break@l }|!<v7>) -> <v8>
{ 1 if (2 > 3) { break@l } } <v8>: * COPY
break@l !<v7>: *
{ break@l } !<v7>: * COPY
if (2 > 3) { break@l } <v8>: * NEW: merge(if (2 > 3) { break@l }|!<v7>) -> <v8>
{ 1 if (2 > 3) { break@l } } <v8>: * COPY
2 <v6>: * NEW: r(2) -> <v6>
{ 2 } <v6>: * COPY
try { 1 if (2 > 3) { break@l } } finally { 2 } <v9>: * NEW: merge(try { 1 if (2 > 3) { break@l } } finally { 2 }|<v8>) -> <v9>
{ try { 1 if (2 > 3) { break@l } } finally { 2 } } <v9>: * COPY
while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !<v10>: *
l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !<v10>: * COPY
{ l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } } !<v10>: * COPY
{ try { 1 if (2 > 3) { break@l } } finally { 2 } } <v9>: * COPY
while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !<v10>: *
l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } !<v10>: * COPY
{ l@ while(true) { try { 1 if (2 > 3) { break@l } } finally { 2 } } } !<v10>: * COPY
=====================
== t6 ==
fun t6() {
@@ -173,18 +173,18 @@ true <v0>:
2 <v3>: {<: Comparable<Int>} NEW: r(2) -> <v3>
3 <v4>: Int NEW: r(3) -> <v4>
2 > 3 <v5>: Boolean NEW: call(2 > 3, compareTo|<v3>, <v4>) -> <v5>
break@l !<v6>: *
{ break@l } !<v6>: * COPY
if (2 > 3) { break@l } <v7>: * NEW: merge(if (2 > 3) { break@l }|!<v6>) -> <v7>
break@l !<v6>: *
{ break@l } !<v6>: * COPY
if (2 > 3) { break@l } <v7>: * NEW: merge(if (2 > 3) { break@l }|!<v6>) -> <v7>
{ 1 if (2 > 3) { break@l } } <v7>: * COPY
while(true) { 1 if (2 > 3) { break@l } } !<v8>: *
l@ while(true) { 1 if (2 > 3) { break@l } } !<v8>: * COPY
while(true) { 1 if (2 > 3) { break@l } } !<v8>: *
l@ while(true) { 1 if (2 > 3) { break@l } } !<v8>: * COPY
5 <v9>: * NEW: r(5) -> <v9>
{ l@ while(true) { 1 if (2 > 3) { break@l } } 5 } <v9>: * COPY
{ l@ while(true) { 1 if (2 > 3) { break@l } } 5 } <v9>: * COPY
2 <v10>: * NEW: r(2) -> <v10>
{ 2 } <v10>: * COPY
try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 } <v11>: * NEW: merge(try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 }|<v9>) -> <v11>
{ try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 } } <v11>: * COPY
{ try { l@ while(true) { 1 if (2 > 3) { break@l } } 5 } finally { 2 } } <v11>: * COPY
=====================
== t7 ==
fun t7() {
@@ -206,17 +206,17 @@ true <v0>: Bo
2 <v3>: {<: Comparable<Int>} NEW: r(2) -> <v3>
3 <v4>: Int NEW: r(3) -> <v4>
2 > 3 <v5>: Boolean NEW: call(2 > 3, compareTo|<v3>, <v4>) -> <v5>
break@l !<v6>: *
{ break@l } !<v6>: * COPY
if (2 > 3) { break@l } <v7>: * NEW: merge(if (2 > 3) { break@l }|!<v6>) -> <v7>
{ 1 if (2 > 3) { break@l } } <v7>: * COPY
while(true) { 1 if (2 > 3) { break@l } } !<v8>: *
l@ while(true) { 1 if (2 > 3) { break@l } } !<v8>: * COPY
{ l@ while(true) { 1 if (2 > 3) { break@l } } } !<v8>: * COPY
break@l !<v6>: *
{ break@l } !<v6>: * COPY
if (2 > 3) { break@l } <v7>: * NEW: merge(if (2 > 3) { break@l }|!<v6>) -> <v7>
{ 1 if (2 > 3) { break@l } } <v7>: * COPY
while(true) { 1 if (2 > 3) { break@l } } !<v8>: *
l@ while(true) { 1 if (2 > 3) { break@l } } !<v8>: * COPY
{ l@ while(true) { 1 if (2 > 3) { break@l } } } !<v8>: * COPY
2 <v9>: * NEW: r(2) -> <v9>
{ 2 } <v9>: * COPY
try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 } <v10>: * NEW: merge(try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 }|!<v8>) -> <v10>
{ try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 } } <v10>: * COPY
{ try { l@ while(true) { 1 if (2 > 3) { break@l } } } finally { 2 } } <v10>: * COPY
=====================
== t8 ==
fun t8(a : Int) {
@@ -241,17 +241,17 @@ a <
2 <v6>: {<: Comparable<Int>} NEW: r(2) -> <v6>
3 <v7>: Int NEW: r(3) -> <v7>
2 > 3 <v8>: Boolean NEW: call(2 > 3, compareTo|<v6>, <v7>) -> <v8>
continue@l !<v10>: *
{ continue@l } !<v10>: * COPY
if (2 > 3) { continue@l } <v11>: * NEW: merge(if (2 > 3) { continue@l }|!<v10>) -> <v11>
{ 1 if (2 > 3) { continue@l } } <v11>: * COPY
continue@l !<v10>: *
{ continue@l } !<v10>: * COPY
if (2 > 3) { continue@l } <v11>: * NEW: merge(if (2 > 3) { continue@l }|!<v10>) -> <v11>
{ 1 if (2 > 3) { continue@l } } <v11>: * COPY
2 <v9>: * NEW: r(2) -> <v9>
{ 2 } <v9>: * COPY
try { 1 if (2 > 3) { continue@l } } finally { 2 } <v12>: * NEW: merge(try { 1 if (2 > 3) { continue@l } } finally { 2 }|<v11>) -> <v12>
{ try { 1 if (2 > 3) { continue@l } } finally { 2 } } <v12>: * COPY
for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !<v13>: *
l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !<v13>: * COPY
{ l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } } !<v13>: * COPY
{ try { 1 if (2 > 3) { continue@l } } finally { 2 } } <v12>: * COPY
for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !<v13>: *
l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } !<v13>: * COPY
{ l@ for (i in 1..a) { try { 1 if (2 > 3) { continue@l } } finally { 2 } } } !<v13>: * COPY
=====================
== t9 ==
fun t9(a : Int) {
@@ -277,18 +277,18 @@ a
2 <v6>: {<: Comparable<Int>} NEW: r(2) -> <v6>
3 <v7>: Int NEW: r(3) -> <v7>
2 > 3 <v8>: Boolean NEW: call(2 > 3, compareTo|<v6>, <v7>) -> <v8>
continue@l !<v9>: *
{ continue@l } !<v9>: * COPY
if (2 > 3) { continue@l } <v10>: * NEW: merge(if (2 > 3) { continue@l }|!<v9>) -> <v10>
{ 1 if (2 > 3) { continue@l } } <v10>: * COPY
for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: *
l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: * COPY
continue@l !<v9>: *
{ continue@l } !<v9>: * COPY
if (2 > 3) { continue@l } <v10>: * NEW: merge(if (2 > 3) { continue@l }|!<v9>) -> <v10>
{ 1 if (2 > 3) { continue@l } } <v10>: * COPY
for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: *
l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: * COPY
5 <v12>: * NEW: r(5) -> <v12>
{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } <v12>: * COPY
{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } <v12>: * COPY
2 <v13>: * NEW: r(2) -> <v13>
{ 2 } <v13>: * COPY
try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 } <v14>: * NEW: merge(try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 }|<v12>) -> <v14>
{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 } } <v14>: * COPY
{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } 5 } finally { 2 } } <v14>: * COPY
=====================
== t10 ==
fun t10(a : Int) {
@@ -313,17 +313,17 @@ a <
2 <v6>: {<: Comparable<Int>} NEW: r(2) -> <v6>
3 <v7>: Int NEW: r(3) -> <v7>
2 > 3 <v8>: Boolean NEW: call(2 > 3, compareTo|<v6>, <v7>) -> <v8>
continue@l !<v9>: *
{ continue@l } !<v9>: * COPY
if (2 > 3) { continue@l } <v10>: * NEW: merge(if (2 > 3) { continue@l }|!<v9>) -> <v10>
{ 1 if (2 > 3) { continue@l } } <v10>: * COPY
for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: *
l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: * COPY
{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } !<v11>: * COPY
continue@l !<v9>: *
{ continue@l } !<v9>: * COPY
if (2 > 3) { continue@l } <v10>: * NEW: merge(if (2 > 3) { continue@l }|!<v9>) -> <v10>
{ 1 if (2 > 3) { continue@l } } <v10>: * COPY
for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: *
l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } !<v11>: * COPY
{ l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } !<v11>: * COPY
2 <v12>: * NEW: r(2) -> <v12>
{ 2 } <v12>: * COPY
try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 } <v13>: * NEW: merge(try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 }|!<v11>) -> <v13>
{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 } } <v13>: * COPY
{ try { l@ for (i in 1..a) { 1 if (2 > 3) { continue@l } } } finally { 2 } } <v13>: * COPY
=====================
== t11 ==
fun t11() {
@@ -5,5 +5,3 @@ fun test(@ann <!UNUSED_PARAMETER!>p<!>: Int) {
}
val bar = fun(@ann <!UNUSED_PARAMETER!>g<!>: Int) {}
val bas = { <!DEPRECATED_LAMBDA_SYNTAX!>(@ann t: Int)<!> -> }
@@ -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 {
@@ -34,7 +34,7 @@ fun test4() {
// should be an error on receiver, shouldn't be thrown away
fun test5() {
<!TYPE_MISMATCH!>1<!>.{ <!DEPRECATED_LAMBDA_SYNTAX!>String.(): String<!> -> this}()
<!TYPE_MISMATCH!>1<!>.(fun String.()=1)()
}
fun <R: Any> R?.sure() : R = this!!
@@ -1,16 +1,16 @@
val receiver = { <!DEPRECATED_LAMBDA_SYNTAX!>Int.()<!> -> }
val receiverWithParameter = { <!DEPRECATED_LAMBDA_SYNTAX!>Int.(<!CANNOT_INFER_PARAMETER_TYPE!>a<!>)<!> -> }
val receiver = { Int.(<!SYNTAX!><!>) <!SYNTAX!>-><!> }
val receiverWithParameter = { Int.<!ILLEGAL_SELECTOR!>(<!DEBUG_INFO_MISSING_UNRESOLVED!>a<!>)<!> <!SYNTAX!>-><!> }
val receiverAndReturnType = { <!DEPRECATED_LAMBDA_SYNTAX!>Int.(): Int<!> -> 5 }
val receiverAndReturnTypeWithParameter = { <!DEPRECATED_LAMBDA_SYNTAX!>Int.(a: Int): Int<!> -> 5 }
val receiverAndReturnType = { Int.(<!SYNTAX!><!>): Int <!SYNTAX!>-> 5<!> }
val receiverAndReturnTypeWithParameter = { Int.<!ILLEGAL_SELECTOR!>(<!DEBUG_INFO_MISSING_UNRESOLVED!>a<!>: <!DEBUG_INFO_MISSING_UNRESOLVED!>Int<!>)<!>: Int <!SYNTAX!>-> 5<!> }
val returnType = { <!DEPRECATED_LAMBDA_SYNTAX!>(): Int<!> -> 5 }
val returnTypeWithParameter = { <!DEPRECATED_LAMBDA_SYNTAX!>(b: Int): Int<!> -> 5 }
val returnType = { (<!SYNTAX!><!>): Int <!SYNTAX!>-> 5<!> }
val returnTypeWithParameter = { (<!UNRESOLVED_REFERENCE!>b<!>: Int)<!DEPRECATED_STATIC_ASSERT!>: Int<!> <!SYNTAX!>-> 5<!> }
val receiverWithFunctionType = { <!DEPRECATED_LAMBDA_SYNTAX!>((Int) -> Int).()<!> -> }
val receiverWithFunctionType = { ((Int)<!SYNTAX!><!> <!SYNTAX!>-> Int).() -><!> }
val parenthesizedParameters = { <!DEPRECATED_LAMBDA_SYNTAX!>(a: Int)<!> -> }
val parenthesizedParameters2 = { <!DEPRECATED_LAMBDA_SYNTAX!>(<!CANNOT_INFER_PARAMETER_TYPE!>b<!>)<!> -> }
val parenthesizedParameters = { (<!UNRESOLVED_REFERENCE!>a<!>: Int) <!SYNTAX!>-><!> }
val parenthesizedParameters2 = { (<!UNRESOLVED_REFERENCE!>b<!>) <!SYNTAX!>-><!> }
val none = { -> }
@@ -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
@@ -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 {
<!DEPRECATED_LAMBDA_SYNTAX!>(t: Super): Sub<!> -> s
t: Super -> s
}
foo {
<!DEPRECATED_LAMBDA_SYNTAX!>(t: Trait): Trait<!> -> s
}
foo {
<!DEPRECATED_LAMBDA_SYNTAX!>(<!EXPECTED_PARAMETER_TYPE_MISMATCH!>t: Sub<!>): <!EXPECTED_RETURN_TYPE_MISMATCH!>Super<!><!> -> s
t: Trait -> s
}
foo(<!TYPE_MISMATCH!>fun(<!EXPECTED_PARAMETER_TYPE_MISMATCH!>t: Sub<!>) = s<!>)
foo(<!TYPE_MISMATCH!>fun(t): Super = s<!>)
}
@@ -9,26 +9,23 @@ fun test1() {
""
}
foo0 {
<!DEPRECATED_LAMBDA_SYNTAX, EXPECTED_PARAMETERS_NUMBER_MISMATCH!>(s: String)<!> -> ""
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>s: String<!>-> ""
}
foo0 {
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!CANNOT_INFER_PARAMETER_TYPE!>x<!>, <!CANNOT_INFER_PARAMETER_TYPE!>y<!><!> -> ""
}
foo0 {
<!DEPRECATED_LAMBDA_SYNTAX!>(): <!EXPECTED_RETURN_TYPE_MISMATCH!>Int<!><!> -> 42
}
foo1 {
""
}
foo1 {
<!DEPRECATED_LAMBDA_SYNTAX!>(<!EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!>)<!> -> ""
<!EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!> -> ""
}
foo1 {
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>x, <!CANNOT_INFER_PARAMETER_TYPE!>y<!><!> -> ""
}
foo1 {
<!DEPRECATED_LAMBDA_SYNTAX!><!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>()<!>: <!EXPECTED_RETURN_TYPE_MISMATCH!>Int<!><!> -> 42
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>
}
@@ -36,12 +33,12 @@ fun test1() {
""
}
foo2 {
<!DEPRECATED_LAMBDA_SYNTAX, EXPECTED_PARAMETERS_NUMBER_MISMATCH!>(<!EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!>)<!> -> ""
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH, EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!> -> ""
}
foo2 {
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>x<!> -> ""
}
foo2 {
<!DEPRECATED_LAMBDA_SYNTAX!><!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>()<!>: <!EXPECTED_RETURN_TYPE_MISMATCH!>Int<!><!> -> 42
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>
}
}
@@ -1,11 +1,11 @@
fun test(a: Int) {
run f@{ <!DEPRECATED_LAMBDA_SYNTAX!>(): Int<!> ->
run<Int>f@{
if (a > 0) return@f <!TYPE_MISMATCH!>""<!>
return@f 1
}
run { <!DEPRECATED_LAMBDA_SYNTAX!>(): Int<!> -> <!TYPE_MISMATCH!>""<!> }
run { <!DEPRECATED_LAMBDA_SYNTAX!>(): Int<!> -> 1 }
run<Int>{ <!TYPE_MISMATCH!>""<!> }
run<Int>{ 1 }
}
fun run<T>(f: () -> T): T { return f() }
@@ -8,15 +8,11 @@ fun <T> Array<T>.forEach(operation: (T) -> Unit) : Unit { for (element in this)
fun bar(operation: (String) -> Unit) = operation("")
fun main(args: Array<String>) {
args.forEach { <!DEPRECATED_LAMBDA_SYNTAX!>(a : String) : Unit<!> -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found
args.forEach { <!DEPRECATED_LAMBDA_SYNTAX!>(a) : Unit<!> -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found
args.forEach { <!DEPRECATED_LAMBDA_SYNTAX!>(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 { <!DEPRECATED_LAMBDA_SYNTAX!>(a: String) : Unit<!> -> a.length() }
bar { <!DEPRECATED_LAMBDA_SYNTAX!>(a) : Unit<!> -> a.length() }
bar { <!DEPRECATED_LAMBDA_SYNTAX!>(a: String)<!> -> a.length() }
bar { a: String -> a.length() }
bar { a -> a.length() }
bar { it.length() }
}
+9 -3
View File
@@ -176,9 +176,15 @@ fun returnFunctionLiteralBlock(a: Any?): Function0<Int> {
if (a is Int) return { <!DEBUG_INFO_SMARTCAST!>a<!> }
else return { 1 }
}
fun returnFunctionLiteral(a: Any?): Function0<Int> =
if (a is Int) { <!DEPRECATED_LAMBDA_SYNTAX!>(): Int<!> -> <!DEBUG_INFO_SMARTCAST!>a<!> }
else { <!DEPRECATED_LAMBDA_SYNTAX!>()<!> -> 1 }
fun returnFunctionLiteral(a: Any?): Function0<Int> {
if (a is Int) return { -> <!DEBUG_INFO_SMARTCAST!>a<!> }
else return { -> 1 }
}
fun returnFunctionLiteralDoesntWork(a: Any?): Function0<Int> =
if (a is Int) <!TYPE_MISMATCH!>{ -> a }<!>
else { -> 1 }
fun mergeSmartCasts(a: Any?) {
if (a is String || a is Int) {
@@ -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
+6 -6
View File
@@ -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)}, {<!DEPRECATED_LAMBDA_SYNTAX!>Int.(p:Int)<!> -> this.ext(p)})
subNoInline({p: Int -> s(p)}, {<!DEPRECATED_LAMBDA_SYNTAX!>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)}, {<!DEPRECATED_LAMBDA_SYNTAX!>Int.(p:Int)<!> -> this.ext(p)})
subNoInline({p: Int -> s(p)}, {<!DEPRECATED_LAMBDA_SYNTAX!>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<Int, Unit>.inlineExt(ext: Int.(p: Int) -> Unit) {
}
inline fun Function1<Int, Unit>.inlineExtWithClosure(ext: Int.(p: Int) -> Unit) {
subInline({p: Int -> this(p)}, {<!DEPRECATED_LAMBDA_SYNTAX!>Int.(p:Int)<!> -> this.ext(p)})
subNoInline({p: Int -> this(p)}, {<!DEPRECATED_LAMBDA_SYNTAX!>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) {}
@@ -14,12 +14,14 @@ fun B.b() {
}
}
fun test() {
b@ <!UNUSED_FUNCTION_LITERAL!>{ <!DEPRECATED_LAMBDA_SYNTAX!>B.()<!> ->
fun <T> without(f: T.() -> Unit): Unit = (null!!).f<!UNREACHABLE_CODE!>()<!>
without<B>() b@ {
object : A {
override fun foo() {
this@b.bar()
}
}
}<!>
}
}
@@ -1,5 +1,5 @@
fun foo(a: Any?): Int {
<!SYNTAX!>@<!>{ () : Unit ->
<!SYNTAX!>@<!>{ ->
return<!SYNTAX!>@<!>
}
+8 -7
View File
@@ -1,16 +1,17 @@
// KT-306 Ambiguity when different this's have same-looking functions
fun test() {
<!UNUSED_FUNCTION_LITERAL!>{<!DEPRECATED_LAMBDA_SYNTAX!>Foo.()<!> ->
bar();
{<!DEPRECATED_LAMBDA_SYNTAX!>Barr.()<!> ->
(fun Foo.() {
bar()
(fun Barr.() {
this.bar()
bar()
}
}<!>
<!UNUSED_FUNCTION_LITERAL!>{<!DEPRECATED_LAMBDA_SYNTAX!>Barr.()<!> ->
})
})
(fun Barr.() {
this.bar()
bar()
}<!>
})
}
class Foo {
+5 -4
View File
@@ -2,18 +2,19 @@
package kt352
val f : (Any) -> Unit = { <!DEPRECATED_LAMBDA_SYNTAX!><!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>()<!> : Unit<!> -> } //type mismatch
val f : (Any) -> Unit = { <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> } //type mismatch
fun foo() {
val <!UNUSED_VARIABLE!>f<!> : (Any) -> Unit = { <!DEPRECATED_LAMBDA_SYNTAX!><!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>()<!> : Unit<!> -> } //!!! no error
val <!UNUSED_VARIABLE!>f<!> : (Any) -> Unit = { <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> } //!!! no error
}
class A() {
val f : (Any) -> Unit = { <!DEPRECATED_LAMBDA_SYNTAX!><!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>()<!> : Unit<!> -> } //type mismatch
val f : (Any) -> Unit = { <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> } //type mismatch
}
//more tests
val g : () -> Unit = { <!DEPRECATED_LAMBDA_SYNTAX!>(): <!EXPECTED_RETURN_TYPE_MISMATCH!>Int<!><!> -> 42 }
val g : () -> Unit = { <!UNUSED_EXPRESSION!>42<!> }
val gFunction : () -> Unit = <!TYPE_MISMATCH!>fun(): Int = 1<!>
val h : () -> Unit = { doSmth() }
@@ -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
@@ -16,11 +16,11 @@ object A {
fun foo(i: Int, f: (Int)->Int) = f(i)
fun test() {
foo(1) { <!DEPRECATED_LAMBDA_SYNTAX!>(x1: Int):Int<!> ->
foo(2) { <!DEPRECATED_LAMBDA_SYNTAX!>(x2: Int): Int<!> ->
foo(3) { <!DEPRECATED_LAMBDA_SYNTAX!>(x3: Int): Int<!> ->
foo(4) { <!DEPRECATED_LAMBDA_SYNTAX!>(x4: Int): Int<!> ->
foo(5) { <!DEPRECATED_LAMBDA_SYNTAX!>(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
}
}
@@ -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) { <!DEPRECATED_LAMBDA_SYNTAX!>(x1: Int):Int<!> ->
foo(2) { <!DEPRECATED_LAMBDA_SYNTAX!>(x2: Int): Int<!> ->
foo(3) { <!DEPRECATED_LAMBDA_SYNTAX!>(x3: Int): Int<!> ->
foo(4) { <!DEPRECATED_LAMBDA_SYNTAX!>(x4: Int): Int<!> ->
foo(5) { <!DEPRECATED_LAMBDA_SYNTAX!>(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
}
}
@@ -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
@@ -7,17 +7,13 @@ fun test(d: dynamic) {
d.foo { x -> }
d.foo { <!DEPRECATED_LAMBDA_SYNTAX!>(x: Int)<!> -> "" }
d.foo { x: Int -> "" }
d.foo { x, y -> "" }
d.foo { <!DEPRECATED_LAMBDA_SYNTAX!>(x: String, y: Int)<!> -> "" }
d.foo { x: String, y: Int -> "" }
d.foo { <!DEPRECATED_LAMBDA_SYNTAX!>(x, y: Int)<!> -> "" }
d.foo { <!DEPRECATED_LAMBDA_SYNTAX!>(x: String, y: Int): Int<!> -> <!TYPE_MISMATCH!>""<!> }
d.foo { <!DEPRECATED_LAMBDA_SYNTAX!>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@ ({ <!DEPRECATED_LAMBDA_SYNTAX!>(x, y: Int)<!> -> })))
d.foo((label@ ({ x, y: Int -> })))
d.foo(({ x -> }))
+1 -1
View File
@@ -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)
}
}
@@ -1,5 +1,5 @@
fun <T> foo(f: (T) -> String) {}
fun test() {
<caret>foo { (x: Int) -> "$x"}
<caret>foo { x: Int -> "$x"}
}
@@ -1,7 +1,7 @@
fun <T> foo(f: (T) -> String) {}
fun test() {
<caret>foo { (x: Int) -> "$x"}
<caret>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"}
@@ -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<Int?>");
assertType("if (1) { -> val a = 1; a} else { -> null}", "Function0<Int?>");
assertType("if (1) (fun (): Boolean { val a = 1; a; var b : Boolean; return b }) else null", "Function0<Boolean>?");
assertType("if (1) (fun (): Int { val a = 1; a; var b = a; return b }) else null", "Function0<Int>?");
}
@@ -4,7 +4,7 @@ class TestClass {
}
fun testFun() {
val lambda = {() -> TestClass() }
val lambda = { -> TestClass() }
lambda().<caret>
}
@@ -1,6 +1,6 @@
fun foo() {
takeHandler1 {
takeHandler2({ (): String -> ret<caret> })
takeHandler2({ -> ret<caret> })
}
}
@@ -1,6 +1,6 @@
fun foo() {
takeHandler1 {
takeHandler2({ (): String -> return@takeHandler2 <caret> })
takeHandler2({ -> return@takeHandler2 <caret> })
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ fun foo(a: Int, b: String) {}
fun f(p: (Int, String) -> Unit){}
fun bar() {
f { (a, b) -> foo(<caret>) }
f { a, b -> foo(<caret>) }
}
// EXIST: "a, b"
+1 -1
View File
@@ -7,5 +7,5 @@ fun <T, R> foo(a: A<T, R>) = a
fun test() {
foo { it }
foo { x -> x}
foo { (x: Int) -> x}
foo { x: Int -> x}
}
+1 -1
View File
@@ -1,6 +1,6 @@
fun foo() {
val (i :Int, s :String) = bar()
val h = {() :Unit -> bar() }
val h = { -> bar() }
for (i :Int in collection) {
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
fun foo() {
val (i: Int, s: String) = bar()
val h = {(): Unit -> bar() }
val h = { -> bar() }
for (i: Int in collection) {
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
fun foo() {
val (i:Int,s:String) = bar()
val h = {():Unit -> bar()}
val h = { -> bar()}
for (i:Int in collection) {
}
}
+3 -3
View File
@@ -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
+3 -3
View File
@@ -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
@@ -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 {}
+1 -1
View File
@@ -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 {}
+1 -1
View File
@@ -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 {}
@@ -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() {
@@ -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( ) {
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
fun foo(): Any {
return { (x: String<caret>) -> 42 }
return { x: String<caret> -> 42 }
}
@@ -1,3 +1,3 @@
fun f() {
val f = { (<caret>x: Int) -> x + x }
val f = { <caret>x: Int -> x + x }
}
@@ -1,3 +1,3 @@
fun f() {
val f = { (<caret>y: Int) -> y + y }
val f = { <caret>y: Int -> y + y }
}
+1 -1
View File
@@ -5,6 +5,6 @@ class C {
}
fun foo() {
val lambda = {() -> /* STATEMENT DELETED: x() */; C() }
val lambda = { -> /* STATEMENT DELETED: x() */; C() }
lambda().<caret>f()
}
+1 -1
View File
@@ -3,6 +3,6 @@ class C {
}
fun foo() {
val lambda = {() -> x(); C() }
val lambda = { -> x(); C() }
lambda().<caret>f()
}
@@ -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)
}
<selection>{ Int.(n: Int, s: String) ->
val q: Int.(Int, String) -> Unit = <selection>{ n: Int, s: String ->
val a = n + this
println(s)
f(a)
}</selection>
{ 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)
@@ -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)
@@ -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"
@@ -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)
@@ -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 {
@@ -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 {
@@ -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)
})
@@ -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";
@@ -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<String>("mama"))() != "mama") return "test 8 failed";
if ( (fooT2<String>("mama"))("papa") != "mamapapa") return "test 9 failed";
@@ -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)
@@ -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
@@ -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
@@ -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();
+1 -1
View File
@@ -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 {
@@ -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 {
@@ -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 })