[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
val receiver = { Int.(<!SYNTAX!><!>) <!SYNTAX!>-><!> }
|
||||
val receiverWithParameter = { Int.(<!UNRESOLVED_REFERENCE!>a<!>) <!SYNTAX!>-><!> }
|
||||
|
||||
val receiverAndReturnType = { Int.(<!SYNTAX!><!>)<!SYNTAX!>: Int -> 5<!> }
|
||||
val receiverAndReturnTypeWithParameter = { Int.(<!UNRESOLVED_REFERENCE!>a<!><!SYNTAX!><!SYNTAX!><!>: Int): Int -> 5<!> }
|
||||
|
||||
val returnType = { (<!SYNTAX!><!>): Int -> 5 }
|
||||
val returnTypeWithParameter = { (<!UNRESOLVED_REFERENCE!>b: Int<!>): Int -> 5 }
|
||||
|
||||
val receiverWithFunctionType = { ((Int)<!SYNTAX!><!> <!SYNTAX!>-> Int).() -><!> }
|
||||
|
||||
val parenthesizedParameters = { (<!UNRESOLVED_REFERENCE!>a: Int<!>) -> }
|
||||
val parenthesizedParameters2 = { (<!UNRESOLVED_REFERENCE!>b<!>) -> }
|
||||
|
||||
val none = { -> }
|
||||
|
||||
|
||||
val parameterWithFunctionType = { a: ((Int) -> Int) -> <!SYNTAX!><!>} // todo fix parser
|
||||
|
||||
val newSyntax = { a: Int -> }
|
||||
val newSyntax1 = { a, b -> }
|
||||
val newSyntax2 = { a: Int, b: Int -> }
|
||||
val newSyntax3 = { a, b: Int -> }
|
||||
val newSyntax4 = { a: Int, b -> }
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER
|
||||
package a
|
||||
|
||||
interface Super
|
||||
interface Trait : Super
|
||||
class Sub : Trait
|
||||
|
||||
fun foo(f: (Trait) -> Trait) = f
|
||||
|
||||
fun test(s: Sub) {
|
||||
foo {
|
||||
t: Super -> s
|
||||
}
|
||||
foo {
|
||||
t: Trait -> s
|
||||
}
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(fun(t: Sub) = s)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(fun(t): Super = s)
|
||||
}
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package a
|
||||
|
||||
fun foo0(f: () -> String) = f
|
||||
fun foo1(f: (Int) -> String) = f
|
||||
fun foo2(f: (Int, String) -> String) = f
|
||||
|
||||
fun test1() {
|
||||
foo0 {
|
||||
""
|
||||
}
|
||||
<!INAPPLICABLE_CANDIDATE!>foo0<!> {
|
||||
s: String-> ""
|
||||
}
|
||||
<!INAPPLICABLE_CANDIDATE!>foo0<!> {
|
||||
x, y -> ""
|
||||
}
|
||||
|
||||
foo1 {
|
||||
""
|
||||
}
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!> {
|
||||
s: String -> ""
|
||||
}
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!> {
|
||||
x, y -> ""
|
||||
}
|
||||
foo1 {
|
||||
-> 42
|
||||
}
|
||||
|
||||
|
||||
foo2 {
|
||||
""
|
||||
}
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!> {
|
||||
s: String -> ""
|
||||
}
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!> {
|
||||
x -> ""
|
||||
}
|
||||
foo2 {
|
||||
-> 42
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package h
|
||||
|
||||
//traits to make ambiguity with function literal as an argument
|
||||
interface A
|
||||
interface B
|
||||
interface C: A, B
|
||||
|
||||
fun <T> foo(a: A, f: () -> T): T = f()
|
||||
fun <T> foo(b: B, f: () -> T): T = f()
|
||||
|
||||
fun test(c: C) {
|
||||
<!AMBIGUITY!>foo<!>(c) f@ {
|
||||
c!!
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test(bal: Array<Int>) {
|
||||
var bar = 4
|
||||
|
||||
val a = { bar += 4 }
|
||||
checkSubtype<() -> Unit>(a)
|
||||
|
||||
val b = { bar = 4 }
|
||||
checkSubtype<() -> Unit>(b)
|
||||
|
||||
val c = { bal[2] = 3 }
|
||||
checkSubtype<() -> Unit>(c)
|
||||
|
||||
val d = run { bar += 4 }
|
||||
checkSubtype<Unit>(d)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
fun test(bal: Array<Int>) {
|
||||
var bar = 4
|
||||
|
||||
val a: () -> Unit = { bar += 4 }
|
||||
|
||||
val b: () -> Int = { bar = 4 }
|
||||
|
||||
val c: () -> UNRESOLVED = { bal[2] = 3 }
|
||||
|
||||
val d: () -> Int = { bar += 4 }
|
||||
|
||||
val e: Unit = run { bar += 4 }
|
||||
|
||||
val f: Int = run { bar += 4 }
|
||||
}
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
// first parameter of the functional type of 'x' can only be inferred from a lambda parameter explicit type specification
|
||||
fun <X, Y> foo(y: Y, x: (X, Y) -> Unit) {}
|
||||
|
||||
fun bar(aInstance: A, bInstance: B) {
|
||||
foo("") {
|
||||
(<!UNRESOLVED_REFERENCE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>): A, c ->
|
||||
a <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo(aInstance) {
|
||||
a: String, (b, c) ->
|
||||
a checkType { _<String>() }
|
||||
b checkType { _<Int>() }
|
||||
c checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo(bInstance) {
|
||||
(a, b): A, (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo(bInstance) {
|
||||
(a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo<A, B>(bInstance) {
|
||||
(a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class A
|
||||
|
||||
operator fun A.component1() = 1
|
||||
operator fun A.component2() = ""
|
||||
|
||||
class B
|
||||
|
||||
class D {
|
||||
operator fun A.component1() = 1.0
|
||||
operator fun A.component2() = ' '
|
||||
|
||||
operator fun B.component1() = 1.0
|
||||
operator fun B.component2() = ' '
|
||||
}
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
fun foobaz(block: D.(B) -> Unit) { }
|
||||
fun foobar(block: D.(A) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the same scope as the first statement of the lambda
|
||||
foobaz { (a, b) ->
|
||||
a checkType { _<Double>() }
|
||||
b checkType { _<Char>() }
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the same scope as the first statement of the lambda
|
||||
// So `component1`/`component2` for lambda parameters were resolved to member extensions
|
||||
foobar { (a, b) ->
|
||||
a checkType { _<Double>() }
|
||||
b checkType { _<Char>() }
|
||||
}
|
||||
|
||||
// the following code fails with exception, see KT-13873
|
||||
// foobarbaz {
|
||||
// component1: B.() -> Int,
|
||||
// component2: B.() -> String,
|
||||
// (a, b): B ->
|
||||
//
|
||||
// }
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
fun <T> Iterable<T>.foo(x: (T) -> Unit) {}
|
||||
|
||||
fun bar(aList: List<A>) {
|
||||
aList.foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (a, b): A ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (a: String, b) ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (a, b): B ->
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER)
|
||||
annotation class Ann
|
||||
|
||||
fun bar() {
|
||||
foo { (private inline a, @Ann b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun bar() {
|
||||
val x = { (<!UNRESOLVED_REFERENCE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
|
||||
val y = { (<!UNRESOLVED_REFERENCE!>a: Int<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
y checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
|
||||
val y2 = { (<!UNRESOLVED_REFERENCE!>a: Number<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
y2 checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
|
||||
val z = { (<!UNRESOLVED_REFERENCE!>a: Int<!>, <!UNRESOLVED_REFERENCE!>b: String<!>) ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
fun foo(block: (A, B) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, a), b ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (a, b), a ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a, (a, b) ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (a, b), (c, b) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
c checkType { <!INAPPLICABLE_CANDIDATE!>_<!><B>() }
|
||||
}
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
fun bar(a: Double) {
|
||||
val b = 1.toShort()
|
||||
// Do not report NAME_SHADOWING on lambda destructured parameter, the same way as for common parameters
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (c, d) ->
|
||||
c checkType { _<Int>() }
|
||||
d checkType { _<String>() }
|
||||
|
||||
foo { (a, c) ->
|
||||
a checkType { _<Int>() }
|
||||
c checkType { _<String>() }
|
||||
d checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
fun foobar(block: (A, B) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a, b): A ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), c ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
c checkType { _<B>() }
|
||||
}
|
||||
|
||||
foobar { a, (b, c) ->
|
||||
a checkType { _<A>() }
|
||||
b checkType { _<Double>() }
|
||||
c checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo { (a: String, b) ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a, b): B ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Double>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Short>() }
|
||||
}
|
||||
}
|
||||
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (_, b) ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a, _) ->
|
||||
a checkType { _<Int>() }
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_, _) ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_: Int, b: String) ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, _: String) ->
|
||||
a checkType { _<Int>() }
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_: Int, _: String) ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_, _): A ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (`_`, _) ->
|
||||
_ checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
}
|
||||
|
||||
foo { (_, `_`) ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (`_`, `_`) ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (_: String, b) ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (_, b): B ->
|
||||
_.hashCode()
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Short>() }
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: -DestructuringLambdaParameters
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
fun foobar(block: (A, B) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { (a, b) ->
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), c ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foobar { a, (b, c) ->
|
||||
c checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
fun test123() {
|
||||
val g: (Int) -> Unit = if (true) {
|
||||
val set = HashSet<Int>()
|
||||
fun (i: Int) {
|
||||
set.add(i)
|
||||
}
|
||||
}
|
||||
else {
|
||||
{ it -> it }
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// !CHECK_TYPE
|
||||
fun test() {
|
||||
val a = if (true) {
|
||||
val x = 1
|
||||
({ x })
|
||||
} else {
|
||||
{ 2 }
|
||||
}
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><() -> Int>() }
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
class Log
|
||||
|
||||
data class CalculatedVariable(
|
||||
val idString: String,
|
||||
val presentableName: String,
|
||||
val units: String,
|
||||
val function: (Log) -> ((TimeIndex) -> Any?)?,
|
||||
val converter: (Any) -> Double
|
||||
) {
|
||||
constructor(idString: String, presentableName: String, units: String, function: (Log) -> ((TimeIndex) -> Double?)?)
|
||||
: this(idString, presentableName, units, function, { it as Double })
|
||||
}
|
||||
|
||||
object CalculatedVariables {
|
||||
val x = CalculatedVariable(
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
fun(log: Log): ((TimeIndex) -> Double?)? {
|
||||
return { 0.0 }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class TimeIndex
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
fun test123() {
|
||||
val g: (Int) -> Unit = if (true) {
|
||||
val set = HashSet<Int>();
|
||||
{ i ->
|
||||
set.add(i)
|
||||
}
|
||||
}
|
||||
else {
|
||||
{ it -> it }
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// !CHECK_TYPE
|
||||
fun <T> id(t: T) = t
|
||||
|
||||
fun foo() {
|
||||
val i = id { 22 } //type inference error: no information for parameter
|
||||
i checkType { <!UNRESOLVED_REFERENCE!>_<!><()->Int>() }
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T> = TODO()
|
||||
operator fun <T> Collection<T>.plus(elements: Iterable<T>): List<T> = TODO()
|
||||
|
||||
fun stringCollection(): Collection<String> = TODO()
|
||||
|
||||
fun <K> test(c: Collection<K>) {
|
||||
var variants = stringCollection()
|
||||
variants += variants.filter { true }
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// See KT-7813: Call to functional parameter with missing argument: no error detected but compiler crashes
|
||||
|
||||
fun foo(p: (Int, () -> Int) -> Unit) {
|
||||
// Errors except last call
|
||||
<!INAPPLICABLE_CANDIDATE!>p<!> { 1 }
|
||||
<!INAPPLICABLE_CANDIDATE!>p<!>() { 2 }
|
||||
p(3) { 4 }
|
||||
}
|
||||
|
||||
fun bar(p: (String, Any, () -> String) -> Unit) {
|
||||
// Errors except last call
|
||||
<!INAPPLICABLE_CANDIDATE!>p<!> { "" }
|
||||
<!INAPPLICABLE_CANDIDATE!>p<!>() { "x" }
|
||||
<!INAPPLICABLE_CANDIDATE!>p<!>("y") { "z" }
|
||||
p("v", Any()) { "w" }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface Predicate<T>
|
||||
|
||||
fun <T> Predicate(x: (T?) -> Boolean): Predicate<T> = null!!
|
||||
|
||||
fun foo() {
|
||||
process(Predicate {
|
||||
x -> x checkType { _<String?>() }
|
||||
|
||||
true
|
||||
})
|
||||
}
|
||||
|
||||
fun process(x: Predicate<String>) {}
|
||||
@@ -0,0 +1,16 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: Predicate.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface Predicate<T extends CharSequence> {
|
||||
// Same effect with @Nullable here
|
||||
boolean invoke(@NotNull T t);
|
||||
}
|
||||
// FILE: Main.kt
|
||||
fun process(x: Predicate<String>) {}
|
||||
fun main() {
|
||||
process(Predicate { x -> x checkType { _<String>() }
|
||||
true
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
val la = { a -> }
|
||||
val las = { a: Int -> }
|
||||
|
||||
val larg = <!UNRESOLVED_REFERENCE!>{ a -> }(123)<!>
|
||||
val twoarg = <!UNRESOLVED_REFERENCE!>{ a, b: String, c -> }(123, "asdf", 123)<!>
|
||||
@@ -0,0 +1,22 @@
|
||||
//KT-2906 If function parameter/variable is invoked in closure using parenthesis syntax, in IDEA it is not highlighted as captured in closure
|
||||
|
||||
package bug
|
||||
|
||||
public fun foo1(bar: () -> Unit) {
|
||||
run {
|
||||
bar() // ERROR: not highlighted as "captured in closure"
|
||||
}
|
||||
}
|
||||
|
||||
public fun foo2(bar: () -> Unit) {
|
||||
run {
|
||||
bar.invoke() // CORRECT: highlighted as "captured in closure"
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
foo1 { println ("foo1")} // prints "foo1"
|
||||
foo2 { println ("foo2")} // prints "foo2"
|
||||
}
|
||||
|
||||
fun println(s: String) = s
|
||||
@@ -0,0 +1,25 @@
|
||||
// KT-3343 Type mismatch when function literal consists of try-catch with Int returning call, and Unit is expected
|
||||
|
||||
fun main() {
|
||||
"hello world".prt{
|
||||
try{
|
||||
print(it)
|
||||
log("we are printing")
|
||||
}
|
||||
catch(e : Exception){
|
||||
log("Exception")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun log(str : String) : Int{
|
||||
print("logging $str")
|
||||
return 0
|
||||
}
|
||||
|
||||
fun print(obj: Any) {}
|
||||
|
||||
|
||||
fun String.prt(action : (String) -> Unit){
|
||||
action(this)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//KT-4529 Lambdas are analyzed improperly in an infix call nested inside a println
|
||||
|
||||
class G {
|
||||
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun foo(bar: (Int) -> Int) = bar<!>
|
||||
}
|
||||
|
||||
fun main() {
|
||||
use(
|
||||
G().foo {it + 11} // no error
|
||||
)
|
||||
use(
|
||||
G() foo {it + 11} // ERROR
|
||||
)
|
||||
use(
|
||||
G() foo ({it + 1}) // 2 ERRORs
|
||||
)
|
||||
}
|
||||
|
||||
fun use(a: Any?) = a
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Foo
|
||||
fun (Foo.() -> Unit).invoke(b : Foo.() -> Unit) {}
|
||||
|
||||
object Z {
|
||||
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun add(b : Foo.() -> Unit) : Z = Z<!>
|
||||
}
|
||||
|
||||
val t2 = Z <!INAPPLICABLE_CANDIDATE!>add<!> { } { }
|
||||
@@ -0,0 +1,10 @@
|
||||
fun main() {
|
||||
var list = listOf(1)
|
||||
|
||||
val a: Int? = 2
|
||||
|
||||
a?.let { list += it }
|
||||
}
|
||||
|
||||
operator fun <T> Iterable<T>.plus(element: T): List<T> = null!!
|
||||
fun <T> listOf(vararg values: T): List<T> = null!!
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// KT-7383 Assertion failed when a star-projection of function type is used
|
||||
|
||||
fun foo() {
|
||||
val f : Function1<*, *> = { x -> x.toString() }
|
||||
f(1)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
// SKIP_TXT
|
||||
// Issue: KT-35168
|
||||
|
||||
class Inv<T>
|
||||
|
||||
// Before the fix, here we had an exception while fixing a type variable for Inv due to prematurely analyzing a lambda
|
||||
// The exception was: "UninitializedPropertyAccessException: lateinit property subResolvedAtoms has not been initialized"
|
||||
class Foo<T>(x: (T) -> T, y: Inv<Any>)
|
||||
|
||||
fun bar() {
|
||||
Foo<Any>({}, Inv())
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
fun f() {
|
||||
foo {
|
||||
return@foo 1
|
||||
}
|
||||
foo({
|
||||
return@foo 1
|
||||
}
|
||||
)
|
||||
foo(a = {
|
||||
return@foo 1
|
||||
})
|
||||
|
||||
foo {
|
||||
foo {
|
||||
return@foo 1
|
||||
}
|
||||
return@foo 1
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(a: Any) {}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun f() {
|
||||
foo {
|
||||
bar {
|
||||
return@foo 1
|
||||
}
|
||||
return@foo 1
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(a: Any) {}
|
||||
fun bar(a: Any) {}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
fun test() {
|
||||
run {return}
|
||||
run {}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
run {return@test2}
|
||||
run {}
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
fun test4() {
|
||||
run {return@test3}
|
||||
run {}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
val flag = true
|
||||
|
||||
interface I
|
||||
class A(): I
|
||||
class B(): I
|
||||
|
||||
val a = l@ {
|
||||
return@l if (flag) A() else B()
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
val flag = true
|
||||
|
||||
// type of a was checked by txt
|
||||
val a/*: () -> Any*/ = l@ {
|
||||
if (flag) return@l 4
|
||||
}
|
||||
|
||||
val b/*: () -> Int */ = l@ {
|
||||
if (flag) return@l 4
|
||||
5
|
||||
}
|
||||
|
||||
val c/*: () -> Unit */ = l@ {
|
||||
if (flag) 4
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
val flag = true
|
||||
|
||||
val a: () -> Int = l@ {
|
||||
if (flag) return@l 4
|
||||
}
|
||||
|
||||
val b: () -> Unit = l@ {
|
||||
if (flag) return@l 4
|
||||
}
|
||||
|
||||
val c: () -> Any = l@ {
|
||||
if (flag) return@l 4
|
||||
}
|
||||
|
||||
val d: () -> Int = l@ {
|
||||
if (flag) return@l 4
|
||||
5
|
||||
}
|
||||
|
||||
val e: () -> Int = l@ {
|
||||
if (flag) 4
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
val flag = true
|
||||
|
||||
val a /*: (Int) -> String */ = l@ {
|
||||
i: Int ->
|
||||
if (i == 0) return@l i.toString()
|
||||
|
||||
"Ok"
|
||||
}
|
||||
|
||||
fun <T> foo(f: (Int) -> T): T = f(0)
|
||||
|
||||
val b /*:String */ = foo {
|
||||
i ->
|
||||
if (i == 0) return@foo i.toString()
|
||||
|
||||
"Ok"
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test2(a: Int) {
|
||||
val x = run f@{
|
||||
if (a > 0) return
|
||||
return@f 1
|
||||
}
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
fun <T> run(f: () -> T): T { return f() }
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test2() {
|
||||
val x = run f@{return@f 1}
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
val x = run(f@{return@f 1})
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
|
||||
fun test1() {
|
||||
val x = run(l@{return@l 1})
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
run f@{
|
||||
checkSubtype<Nothing>(return@f 1)
|
||||
}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
val x = run f@{
|
||||
fun local(a: Int): String {
|
||||
if (a > 0) return "2"
|
||||
return@local "3"
|
||||
}
|
||||
return@f 1
|
||||
}
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
val x = run f@{
|
||||
run ff@ {
|
||||
return@ff "2"
|
||||
}
|
||||
return@f 1
|
||||
}
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
fun test(a: Int) {
|
||||
run f@{
|
||||
if (a > 0) return@f
|
||||
else return@f 1
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class A
|
||||
val flag = true
|
||||
|
||||
val a /*: () -> A?*/ = l@ {
|
||||
if (flag) return@l null
|
||||
|
||||
A()
|
||||
}
|
||||
|
||||
val b /*: () -> A?*/ = l@ {
|
||||
if (flag) return@l null
|
||||
|
||||
return@l A()
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
val flag = true
|
||||
|
||||
val a = b@ {
|
||||
if (flag) return@b 4
|
||||
return@b
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test(a: Int) {
|
||||
val x = run f@{
|
||||
if (a > 0) return@f
|
||||
else return@f Unit
|
||||
}
|
||||
checkSubtype<Unit>(x)
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
val flag = true
|
||||
|
||||
// type of a was checked by txt
|
||||
val a = run { // () -> Unit
|
||||
return@run
|
||||
}
|
||||
|
||||
// Unit
|
||||
val b = run {
|
||||
if (flag) return@run
|
||||
5
|
||||
}
|
||||
|
||||
// Unit
|
||||
val c = run {
|
||||
if (flag) return@run
|
||||
|
||||
return@run 4
|
||||
}
|
||||
compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.fir.kt
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
val flag = true
|
||||
|
||||
// type of lambda was checked by txt
|
||||
val a = b@ { // () -> Unit
|
||||
if (flag) return@b
|
||||
else 54
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
fun <T> listOf(): List<T> = null!!
|
||||
fun <T> listOf(vararg values: T): List<T> = null!!
|
||||
|
||||
val flag = true
|
||||
|
||||
val a: () -> List<Int> = l@ {
|
||||
if (flag) return@l listOf()
|
||||
listOf(5)
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
val flag = true
|
||||
|
||||
// type of lambda was checked by txt
|
||||
val a = l@ { // () -> Any
|
||||
if (flag) return@l 4
|
||||
return@l Unit
|
||||
}
|
||||
|
||||
val b = l@ { // () -> Any
|
||||
if (flag) return@l Unit
|
||||
5
|
||||
}
|
||||
|
||||
val c = l@ { // () -> Unit
|
||||
if (flag) return@l Unit
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
fun test(a: Int) {
|
||||
run<Int>f@{
|
||||
if (a > 0) return@f ""
|
||||
return@f 1
|
||||
}
|
||||
|
||||
run<Int>{ "" }
|
||||
run<Int>{ 1 }
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface A
|
||||
interface B: A
|
||||
interface C: A
|
||||
|
||||
|
||||
fun test(a: C, b: B) {
|
||||
val x = run f@{
|
||||
if (a != b) return@f a
|
||||
b
|
||||
}
|
||||
checkSubtype<A>(x)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> = null!!
|
||||
fun <T> listOf(): List<T> = null!!
|
||||
fun <T> listOf(vararg values: T): List<T> = null!!
|
||||
|
||||
fun commonSystemFailed(a: List<Int>) {
|
||||
a.map {
|
||||
if (it == 0) return@map listOf(it)
|
||||
listOf()
|
||||
}
|
||||
a.map {
|
||||
if (it == 0) return@map listOf()
|
||||
listOf(it)
|
||||
}
|
||||
a.map {
|
||||
if (it == 0) listOf()
|
||||
else listOf(it)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
// KT-6822 Smart cast doesn't work inside local returned expression in lambda
|
||||
|
||||
val a /* :(Int?) -> Int? */ = l@ { it: Int? -> // but must be (Int?) -> Int
|
||||
if (it != null) return@l it
|
||||
5
|
||||
}
|
||||
|
||||
fun <R> let(f: (Int?) -> R): R = null!!
|
||||
|
||||
val b /*: Int? */ = let { // but must be Int
|
||||
if (it != null) return@let it
|
||||
5
|
||||
}
|
||||
|
||||
val c /*: Int*/ = let {
|
||||
if (it != null) it else 5
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// KT-6822 Smart cast doesn't work inside local returned expression in lambda
|
||||
|
||||
val a : (Int?) -> Int = l@ {
|
||||
if (it != null) return@l it
|
||||
5
|
||||
}
|
||||
|
||||
fun <R> let(f: (Int?) -> R): R = null!!
|
||||
|
||||
val b: Int = let {
|
||||
if (it != null) return@let it
|
||||
5
|
||||
}
|
||||
|
||||
val c: Int = let {
|
||||
if (it != null) it else 5
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
val a = l@ {
|
||||
return@l <!UNRESOLVED_REFERENCE!>r<!>
|
||||
}
|
||||
|
||||
val b = l@ {
|
||||
if ("" == "OK") return@l
|
||||
|
||||
return@l <!UNRESOLVED_REFERENCE!>r<!>
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package m
|
||||
|
||||
interface Element
|
||||
|
||||
fun test(handlers: Map<String, Element.()->Unit>) {
|
||||
|
||||
handlers.getOrElse("name", { null })
|
||||
}
|
||||
|
||||
fun <K,V> Map<K,V>.getOrElse(key: K, defaultValue: ()-> V) : V = throw Exception("$key $defaultValue")
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package m
|
||||
|
||||
interface Element
|
||||
|
||||
fun test(handlers: Map<String, Element.()->Unit>) {
|
||||
|
||||
handlers.getOrElse("name", l@ { return@l null })
|
||||
}
|
||||
|
||||
fun <K,V> Map<K,V>.getOrElse(key: K, defaultValue: ()-> V) : V = throw Exception("$key $defaultValue")
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun foo(block: (Int, String) -> Unit) { }
|
||||
fun foobar(block: (Double) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { _, b ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a, _ ->
|
||||
a checkType { _<Int>() }
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { _, _ ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { _: Int, b: String ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a: Int, _: String ->
|
||||
a checkType { _<Int>() }
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { _: Int, _: String ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { `_`, _ ->
|
||||
_ checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
}
|
||||
|
||||
foo { _, `_` ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { `_`, `_` ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo(fun(x: Int, _: String) {})
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun unusedLiteral(){
|
||||
{ ->
|
||||
val i = 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun unusedLiteralInDoWhile(){
|
||||
do{ ->
|
||||
val i = 1
|
||||
} while(false)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun main() {
|
||||
"".run {
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun <T> T.run(f: (T) -> Unit): Unit = f(this)
|
||||
Reference in New Issue
Block a user