Support single-underscore variable names partially
Currently only parameters of lambdas/function expressions and destructuring entries are allowed #KT-3824 In Progress #KT-2783 In Progress
This commit is contained in:
+62
@@ -0,0 +1,62 @@
|
||||
// !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) ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a, _) ->
|
||||
a checkType { _<Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { (_, _) ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { (_: Int, b: String) ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, _: String) ->
|
||||
a checkType { _<Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { (_: Int, _: String) ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { (_, _): A ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { (`_`, _) ->
|
||||
_ checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { (_, `_`) ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (<!REDECLARATION!>`_`<!>, <!REDECLARATION!>`_`<!>) ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>_: String<!>, b) ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { <!EXPECTED_PARAMETER_TYPE_MISMATCH!>(_, b): B<!> ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<Short>() }
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
public fun foo(/*0*/ block: (A) -> kotlin.Unit): kotlin.Unit
|
||||
|
||||
public final data class A {
|
||||
public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String)
|
||||
public final val x: kotlin.Int
|
||||
public final val y: kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final operator /*synthesized*/ fun component2(): kotlin.String
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ...): A
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final data class B {
|
||||
public constructor B(/*0*/ u: kotlin.Double, /*1*/ w: kotlin.Short)
|
||||
public final val u: kotlin.Double
|
||||
public final val w: kotlin.Short
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.Double
|
||||
public final operator /*synthesized*/ fun component2(): kotlin.Short
|
||||
public final /*synthesized*/ fun copy(/*0*/ u: kotlin.Double = ..., /*1*/ w: kotlin.Short = ...): B
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(block: (Int, String) -> Unit) { }
|
||||
fun foobar(block: (Double) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { _, b ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a, _ ->
|
||||
a checkType { _<Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { _, _ ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { _: Int, b: String ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a: Int, _: String ->
|
||||
a checkType { _<Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { _: Int, _: String ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { `_`, _ ->
|
||||
_ checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { _, `_` ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { <!REDECLARATION, REDECLARATION!>`_`<!>, <!REDECLARATION, REDECLARATION!>`_`<!> ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo(fun(x: Int, _: String) {})
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
public fun foo(/*0*/ block: (kotlin.Int, kotlin.String) -> kotlin.Unit): kotlin.Unit
|
||||
public fun foobar(/*0*/ block: (kotlin.Double) -> kotlin.Unit): kotlin.Unit
|
||||
Reference in New Issue
Block a user