[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,17 @@
fun test(x: List<Int>): Int {
x myMap {
return@myMap
}
return 0
}
fun myMap(x: List<Int>): Int {
x myMap {
return@myMap
}
return 0
}
infix fun List<Int>.myMap(x: () -> Unit) {}
@@ -0,0 +1,15 @@
//KT-1703 Reference to label is unresolved
fun test() {
val ints = Array<Int?>(2, { null })
ints.forEach lit@ {
if (it == null) return@lit
use(it + 5)
}
}
fun <T> Array<out T>.forEach(operation: (T) -> Unit) {
for (element in this) operation(element)
}
fun use(a: Any?) = a
+11
View File
@@ -0,0 +1,11 @@
fun nonlocals(b : Boolean) {
a@{
fun foo() {
if (b) {
return@a 1 // The label must be resolved, but an error should be reported for a non-local return
}
}
return@a 5
}
}
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
//KT-3920 Labeling information is lost when passing through some expressions
fun test() {
run f@{
val x = if (1 > 2) return@f 1 else 2
2
}
}
@@ -0,0 +1,21 @@
//KT-3988 This@label for outer function not resolved
class Comment() {
var article = ""
}
class Comment2() {
var article2 = ""
}
fun new(body: Comment.() -> Unit) = body
fun new2(body: Comment2.() -> Unit) = body
fun main() {
new {
new2 {
this@new //UNRESOLVED REFERENCE
}
}
}
@@ -0,0 +1,11 @@
//KT-4247 LABEL_NAME_CLASH
fun foo(bar1: (String.() -> Int) -> Int) {
bar1 {
this.<!UNRESOLVED_REFERENCE!>length<!>
}
bar1 {
this@bar1.<!UNRESOLVED_REFERENCE!>length<!>
}
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
//KT-4586 this@ does not work for builders
fun string(init: StringBuilder.() -> Unit): String{
val answer = StringBuilder()
answer.<!UNRESOLVED_REFERENCE!>init<!>()
return answer.toString()
}
val str = string l@{
append("hello, ")
val sub = string {
append("world!")
this@l.append(this)
}
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
//KT-4603 Labeling information is lost when passing through local classes or objects
fun foo() {
val s: Int.() -> Unit = l@{
class Local(val y: Int = this@l) {
fun bar() {
val x: Int = this@l //unresolved
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
//KT-591 Unresolved label in valid code
fun test() {
val a: (Int?).() -> Unit = a@{
if (this != null) {
val b: String.() -> Unit = {
this@a.<!UNRESOLVED_REFERENCE!>times<!>(5) // a@ Unresolved
}
}
}
}
@@ -0,0 +1,27 @@
interface A {
fun foo()
}
interface B {
fun bar()
}
fun B.b() {
object : A {
override fun foo() {
this@b.bar()
}
}
}
fun test() {
fun <T> without(f: T.() -> Unit): Unit = (null!!).<!UNRESOLVED_REFERENCE!>f<!>()
without<B>() b@ {
object : A {
override fun foo() {
this@b.bar()
}
}
}
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
val funLit = lambda@ fun String.() {
val d1 = this@lambda
}
fun test() {
val funLit = lambda@ fun String.(): String {
return this@lambda
}
}
fun lambda() {
val funLit = lambda@ fun String.(): String {
return this@lambda
}
}
@@ -0,0 +1,36 @@
fun foo(a: Any?): Int {
<!SYNTAX!>@<!>{ ->
return<!SYNTAX!>@<!>
}
<!SYNTAX!>@<!> while(a == null) {
if (true) {
break<!SYNTAX!>@<!>
}
else {
continue<!SYNTAX!>@<!>
}
}
var b = 1
(<!SYNTAX!>@<!> b) = 2
return<!SYNTAX!>@<!> 1
}
open class A {
fun foo() {}
}
class B : A() {
fun bar() {
this<!SYNTAX!>@<!>.foo()
super<!SYNTAX!>@<!>.foo()
}
}
fun bar(f: () -> Unit) = f
fun test() {
bar <!SYNTAX!>@<!>{}
}