KT-16553 Underscore variable values shall not be evaluated
Do not generate 'componentN' calls for '_' in destructuring assignment.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
object A
|
||||
|
||||
object B {
|
||||
operator fun A.component1() = 1
|
||||
operator fun A.component2() = 2
|
||||
operator fun A.component3() = 3
|
||||
}
|
||||
|
||||
fun B.test() {
|
||||
val (x, _, z) = A
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
FILE /destructuringWithUnderscore.kt
|
||||
CLASS OBJECT A
|
||||
CONSTRUCTOR private constructor A()
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='A'
|
||||
CLASS OBJECT B
|
||||
CONSTRUCTOR private constructor B()
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='B'
|
||||
FUN public final operator fun A.component1(): kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='component1() on A: Int'
|
||||
CONST Int type=kotlin.Int value='1'
|
||||
FUN public final operator fun A.component2(): kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='component2() on A: Int'
|
||||
CONST Int type=kotlin.Int value='2'
|
||||
FUN public final operator fun A.component3(): kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='component3() on A: Int'
|
||||
CONST Int type=kotlin.Int value='3'
|
||||
FUN public fun B.test(): kotlin.Unit
|
||||
BLOCK_BODY
|
||||
COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION
|
||||
VAR IR_TEMPORARY_VARIABLE val tmp0_container: A
|
||||
GET_OBJECT 'A' type=A
|
||||
VAR val x: kotlin.Int
|
||||
CALL 'component1() on A: Int' type=kotlin.Int origin=COMPONENT_N(index=1)
|
||||
$this: GET_VAR '<receiver: test() on B: Unit>' type=B origin=null
|
||||
$receiver: GET_VAR 'tmp0_container: A' type=A origin=null
|
||||
VAR val z: kotlin.Int
|
||||
CALL 'component3() on A: Int' type=kotlin.Int origin=COMPONENT_N(index=3)
|
||||
$this: GET_VAR '<receiver: test() on B: Unit>' type=B origin=null
|
||||
$receiver: GET_VAR 'tmp0_container: A' type=A origin=null
|
||||
Reference in New Issue
Block a user