K2 Scripting: support script top-level destructuring declarations
This commit is contained in:
committed by
Space Team
parent
02e2438d37
commit
bf3a6f7678
@@ -0,0 +1,67 @@
|
||||
FILE fqName:<root> fileName:/destructuringDeclaration.kts
|
||||
SCRIPT
|
||||
COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.<script-destructuringDeclaration.kts>.A [val]
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.<script-destructuringDeclaration.kts>.A' type=<root>.<script-destructuringDeclaration.kts>.A origin=null
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:abc type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null
|
||||
value: CALL 'public final fun component1 (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>.A' type=kotlin.Int origin=COMPONENT_N(index=1)
|
||||
$this: GET_VAR 'val tmp_0: <root>.<script-destructuringDeclaration.kts>.A declared in <root>.<script-destructuringDeclaration.kts>' type=<root>.<script-destructuringDeclaration.kts>.A origin=null
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:def type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null
|
||||
value: CALL 'public final fun component2 (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>.A' type=kotlin.Int origin=COMPONENT_N(index=2)
|
||||
$this: GET_VAR 'val tmp_0: <root>.<script-destructuringDeclaration.kts>.A declared in <root>.<script-destructuringDeclaration.kts>' type=<root>.<script-destructuringDeclaration.kts>.A origin=null
|
||||
PROPERTY name:abc visibility:local modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:abc type:kotlin.Int visibility:private [final]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-abc> visibility:local modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:abc visibility:local modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <get-abc> (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:abc type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
PROPERTY name:def visibility:local modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:def type:kotlin.Int visibility:private [final]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-def> visibility:local modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:def visibility:local modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <get-def> (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:def type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
PROPERTY name:rv visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:rv type:kotlin.Int visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUS
|
||||
$this: CALL 'local final fun <get-abc> (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>' type=kotlin.Int origin=GET_PROPERTY
|
||||
other: CALL 'local final fun <get-def> (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>' type=kotlin.Int origin=GET_PROPERTY
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-rv> visibility:public modality:FINAL <> () returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY name:rv visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-rv> (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rv type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
|
||||
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.<script-destructuringDeclaration.kts>.A
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.<script-destructuringDeclaration.kts>.A [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||
FUN name:component1 visibility:public modality:FINAL <> ($this:<root>.<script-destructuringDeclaration.kts>.A) returnType:kotlin.Int [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.<script-destructuringDeclaration.kts>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>.A'
|
||||
CONST Int type=kotlin.Int value=123
|
||||
FUN name:component2 visibility:public modality:FINAL <> ($this:<root>.<script-destructuringDeclaration.kts>.A) returnType:kotlin.Int [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.<script-destructuringDeclaration.kts>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int declared in <root>.<script-destructuringDeclaration.kts>.A'
|
||||
CONST Int type=kotlin.Int value=2
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:kotlin.script.templates.standard.ScriptTemplateWithArgs
|
||||
VAR SCRIPT_CALL_PARAMETER name:args type:kotlin.Array<kotlin.String> [val]
|
||||
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
// DUMP_IR
|
||||
|
||||
val (abc, def) = A()
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
|
||||
val (_, b, _) = A()
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
|
||||
data class Pair(val first: Int, val second: Int)
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
val (a, b) = A()
|
||||
val (c, d) = B()
|
||||
|
||||
val rv = (a + b) * (c + d)
|
||||
|
||||
class A {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = 5
|
||||
}
|
||||
|
||||
class B {
|
||||
operator fun component1() = 3
|
||||
operator fun component2() = 4
|
||||
}
|
||||
|
||||
// expected: rv: 42
|
||||
Reference in New Issue
Block a user