Varargs.
This commit is contained in:
committed by
Dmitry Petrov
parent
d45811a5da
commit
b17e3b0299
+8
-4
@@ -3,8 +3,10 @@ FILE /arrayAssignment.kt
|
||||
BLOCK_BODY
|
||||
VAR val x: kotlin.IntArray
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray
|
||||
DUMMY vararg type=kotlin.Int
|
||||
elements: VARARG type=IntArray varargElementType=Int
|
||||
CONST Int type=kotlin.Int value='1'
|
||||
CONST Int type=kotlin.Int value='2'
|
||||
CONST Int type=kotlin.Int value='3'
|
||||
CALL .set type=kotlin.Unit operator=EQ
|
||||
$this: GET_VAR x type=kotlin.IntArray operator=null
|
||||
index: CONST Int type=kotlin.Int value='1'
|
||||
@@ -17,7 +19,9 @@ FILE /arrayAssignment.kt
|
||||
BLOCK_BODY
|
||||
CALL .set type=kotlin.Unit operator=EQ
|
||||
$this: CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray
|
||||
DUMMY vararg type=kotlin.Int
|
||||
elements: VARARG type=IntArray varargElementType=Int
|
||||
CONST Int type=kotlin.Int value='1'
|
||||
CONST Int type=kotlin.Int value='2'
|
||||
CONST Int type=kotlin.Int value='3'
|
||||
index: CALL .foo type=kotlin.Int operator=null
|
||||
value: CONST Int type=kotlin.Int value='1'
|
||||
|
||||
@@ -3,8 +3,10 @@ FILE /arrayAugmentedAssignment1.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray
|
||||
DUMMY vararg type=kotlin.Int
|
||||
elements: VARARG type=IntArray varargElementType=Int
|
||||
CONST Int type=kotlin.Int value='1'
|
||||
CONST Int type=kotlin.Int value='2'
|
||||
CONST Int type=kotlin.Int value='3'
|
||||
FUN public fun bar(): kotlin.Int
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing
|
||||
|
||||
+4
-2
@@ -5,8 +5,10 @@ FILE /incrementDecrement.kt
|
||||
PROPERTY public val arr: kotlin.IntArray getter=null setter=null
|
||||
EXPRESSION_BODY
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray
|
||||
DUMMY vararg type=kotlin.Int
|
||||
elements: VARARG type=IntArray varargElementType=Int
|
||||
CONST Int type=kotlin.Int value='1'
|
||||
CONST Int type=kotlin.Int value='2'
|
||||
CONST Int type=kotlin.Int value='3'
|
||||
FUN public fun testVarPrefix(): kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR var x: kotlin.Int
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
val test1 = arrayOf<String>()
|
||||
val test2 = arrayOf("1", "2", "3")
|
||||
val test3 = arrayOf("0", *test2, *test1, "4")
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
FILE /vararg.kt
|
||||
PROPERTY public val test1: kotlin.Array<kotlin.String> getter=null setter=null
|
||||
EXPRESSION_BODY
|
||||
CALL .arrayOf type=kotlin.Array<kotlin.String> operator=null
|
||||
PROPERTY public val test2: kotlin.Array<kotlin.String> getter=null setter=null
|
||||
EXPRESSION_BODY
|
||||
CALL .arrayOf type=kotlin.Array<kotlin.String> operator=null
|
||||
elements: VARARG type=Array<out String> varargElementType=String
|
||||
CONST String type=kotlin.String value='1'
|
||||
CONST String type=kotlin.String value='2'
|
||||
CONST String type=kotlin.String value='3'
|
||||
PROPERTY public val test3: kotlin.Array<kotlin.String> getter=null setter=null
|
||||
EXPRESSION_BODY
|
||||
CALL .arrayOf type=kotlin.Array<kotlin.String> operator=null
|
||||
elements: VARARG type=Array<out String> varargElementType=String
|
||||
CONST String type=kotlin.String value='0'
|
||||
SPREAD_ELEMENT
|
||||
CALL .<get-test2> type=kotlin.Array<kotlin.String> operator=GET_PROPERTY
|
||||
SPREAD_ELEMENT
|
||||
CALL .<get-test1> type=kotlin.Array<kotlin.String> operator=GET_PROPERTY
|
||||
CONST String type=kotlin.String value='4'
|
||||
@@ -0,0 +1,9 @@
|
||||
fun testScalar(a: Any): IntArray {
|
||||
if (a !is Int) return intArrayOf()
|
||||
return intArrayOf(a)
|
||||
}
|
||||
|
||||
fun testSpread(a: Any): IntArray {
|
||||
if (a !is IntArray) return intArrayOf()
|
||||
return intArrayOf(*a)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
FILE /varargWithImplicitCast.kt
|
||||
FUN public fun testScalar(/*0*/ a: kotlin.Any): kotlin.IntArray
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit operator=IF
|
||||
if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.Int
|
||||
GET_VAR a type=kotlin.Any operator=null
|
||||
then: RETURN type=kotlin.Nothing
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
RETURN type=kotlin.Nothing
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
elements: VARARG type=IntArray varargElementType=Int
|
||||
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Int
|
||||
GET_VAR a type=kotlin.Any operator=null
|
||||
FUN public fun testSpread(/*0*/ a: kotlin.Any): kotlin.IntArray
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit operator=IF
|
||||
if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.IntArray
|
||||
GET_VAR a type=kotlin.Any operator=null
|
||||
then: RETURN type=kotlin.Nothing
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
RETURN type=kotlin.Nothing
|
||||
CALL .intArrayOf type=kotlin.IntArray operator=null
|
||||
elements: VARARG type=IntArray varargElementType=Int
|
||||
SPREAD_ELEMENT
|
||||
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray
|
||||
GET_VAR a type=kotlin.Any operator=null
|
||||
Reference in New Issue
Block a user