Associate vararg of unsigned types with corresponding arrays

This is a first step, full support will be added later

 #KT-24880 In Progress
This commit is contained in:
Mikhail Zarechenskiy
2018-06-14 15:17:43 +03:00
parent 3e45a1529c
commit 333411c57d
13 changed files with 165 additions and 16 deletions
@@ -0,0 +1,34 @@
// !LANGUAGE: +InlineClasses
// !SKIP_METADATA_VERSION_CHECK
// WITH_UNSIGNED
fun uint(vararg us: UInt): UIntArray = us
fun nullableUInt(vararg us: UInt?): UIntArray {
val ls = us.filterNotNull()
return UIntArray(ls.size) { ls[it] }
}
inline fun inlinedUInt(vararg us: UInt): UIntArray = us
fun box(): String {
val uints = uint(1u, 2u, 3u)
if (sum(*uints) != 6u) return "Fail 1"
val nullableUInts = nullableUInt(1u, null, 2u, null)
if (sum(*nullableUInts) != 3u) return "Fail 2"
val inlinedUInts = inlinedUInt(1u, 3u)
if (sum(*inlinedUInts) != 4u) return "Fail 3"
return "OK"
}
fun sum(vararg us: UInt): UInt {
var sum = 0u
for (i in us) {
sum += i
}
return sum
}
@@ -1,22 +1,22 @@
package
public fun array(/*0*/ vararg a: kotlin.UIntArray /*kotlin.Array<out kotlin.UIntArray>*/): kotlin.Unit
public fun ubyte(/*0*/ vararg a: kotlin.UByte /*kotlin.Array<out kotlin.UByte>*/): kotlin.Unit
public fun uint(/*0*/ vararg a: kotlin.UInt /*kotlin.Array<out kotlin.UInt>*/): kotlin.Unit
public fun ulong(/*0*/ vararg a: kotlin.ULong /*kotlin.Array<out kotlin.ULong>*/): kotlin.Unit
public fun ushort(/*0*/ vararg a: kotlin.UShort /*kotlin.Array<out kotlin.UShort>*/): kotlin.Unit
public fun ubyte(/*0*/ vararg a: kotlin.UByte /*kotlin.UByteArray*/): kotlin.Unit
public fun uint(/*0*/ vararg a: kotlin.UInt /*kotlin.UIntArray*/): kotlin.Unit
public fun ulong(/*0*/ vararg a: kotlin.ULong /*kotlin.ULongArray*/): kotlin.Unit
public fun ushort(/*0*/ vararg a: kotlin.UShort /*kotlin.UShortArray*/): kotlin.Unit
public final annotation class Ann : kotlin.Annotation {
public constructor Ann(/*0*/ vararg a: kotlin.UInt /*kotlin.Array<out kotlin.UInt>*/)
public final val a: kotlin.Array<out kotlin.UInt>
public constructor Ann(/*0*/ vararg a: kotlin.UInt /*kotlin.UIntArray*/)
public final val a: kotlin.UIntArray
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class ValueParam {
public constructor ValueParam(/*0*/ vararg a: kotlin.ULong /*kotlin.Array<out kotlin.ULong>*/)
public final val a: kotlin.Array<out kotlin.ULong>
public constructor ValueParam(/*0*/ vararg a: kotlin.ULong /*kotlin.ULongArray*/)
public final val a: kotlin.ULongArray
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -0,0 +1,9 @@
// !LANGUAGE: +InlineClasses
// !SKIP_METADATA_VERSION_CHECK
fun ubyte(vararg a: UByte): UByteArray = a
fun ushort(vararg a: UShort): UShortArray = a
fun uint(vararg a: UInt): UIntArray = a
fun ulong(vararg a: ULong): ULongArray = a
fun rawUInt(vararg a: UInt): IntArray = <!TYPE_MISMATCH!>a<!>
@@ -0,0 +1,7 @@
package
public fun rawUInt(/*0*/ vararg a: kotlin.UInt /*kotlin.UIntArray*/): kotlin.IntArray
public fun ubyte(/*0*/ vararg a: kotlin.UByte /*kotlin.UByteArray*/): kotlin.UByteArray
public fun uint(/*0*/ vararg a: kotlin.UInt /*kotlin.UIntArray*/): kotlin.UIntArray
public fun ulong(/*0*/ vararg a: kotlin.ULong /*kotlin.ULongArray*/): kotlin.ULongArray
public fun ushort(/*0*/ vararg a: kotlin.UShort /*kotlin.UShortArray*/): kotlin.UShortArray
@@ -21323,6 +21323,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testUnsignedLiteralsWithSignedOverflow() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/unsignedLiteralsWithSignedOverflow.kt");
}
@TestMetadata("varargsOfUnsignedTypes.kt")
public void testVarargsOfUnsignedTypes() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/varargsOfUnsignedTypes.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/vararg")
@@ -58,4 +58,9 @@ public class DiagnosticsWithUnsignedTypesGenerated extends AbstractDiagnosticsWi
public void testUnsignedLiteralsTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/unsignedLiteralsTypeCheck.kt");
}
@TestMetadata("varargTypeToArrayTypeCheck.kt")
public void testVarargTypeToArrayTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/varargTypeToArrayTypeCheck.kt");
}
}
@@ -21323,6 +21323,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testUnsignedLiteralsWithSignedOverflow() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/unsignedLiteralsWithSignedOverflow.kt");
}
@TestMetadata("varargsOfUnsignedTypes.kt")
public void testVarargsOfUnsignedTypes() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/varargsOfUnsignedTypes.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/vararg")
@@ -21323,6 +21323,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testUnsignedLiteralsWithSignedOverflow() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/unsignedLiteralsWithSignedOverflow.kt");
}
@TestMetadata("varargsOfUnsignedTypes.kt")
public void testVarargsOfUnsignedTypes() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/varargsOfUnsignedTypes.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/vararg")