From 793d34b913d40c1f018040450bddd9f6abfa114a Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 9 May 2018 04:45:13 +0300 Subject: [PATCH] Suppress errors about non-public primary constructor and forbidden varargs --- generators/builtins/unsignedTypes.kt | 3 +++ libraries/stdlib/unsigned/src/kotlin/UByte.kt | 1 + libraries/stdlib/unsigned/src/kotlin/UByteArray.kt | 2 ++ libraries/stdlib/unsigned/src/kotlin/UInt.kt | 1 + libraries/stdlib/unsigned/src/kotlin/UIntArray.kt | 2 ++ libraries/stdlib/unsigned/src/kotlin/ULong.kt | 1 + libraries/stdlib/unsigned/src/kotlin/ULongArray.kt | 2 ++ libraries/stdlib/unsigned/src/kotlin/UShort.kt | 1 + libraries/stdlib/unsigned/src/kotlin/UShortArray.kt | 2 ++ 9 files changed, 15 insertions(+) diff --git a/generators/builtins/unsignedTypes.kt b/generators/builtins/unsignedTypes.kt index a8dcb204e87..96766d46b6f 100644 --- a/generators/builtins/unsignedTypes.kt +++ b/generators/builtins/unsignedTypes.kt @@ -41,6 +41,7 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns out.println("import kotlin.experimental.*") out.println() + out.println("@Suppress(\"NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS\")") out.println("public inline class $className internal constructor(private val data: $storageType) : Comparable<$className> {") out.println() out.println(""" companion object { @@ -256,6 +257,7 @@ class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIn val storageElementType = type.asSigned.capitalized val storageArrayType = storageElementType + "Array" override fun generateBody() { + out.println("@Suppress(\"NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS\")") out.println("public inline class $arrayType internal constructor(private val storage: $storageArrayType) : Collection<$elementType> {") out.println( """ @@ -293,6 +295,7 @@ public /*inline*/ fun $arrayType(size: Int, init: (Int) -> $elementType): $array return $arrayType($storageArrayType(size) { index -> init(index).to$storageElementType() }) } +@Suppress("FORBIDDEN_VARARG_PARAMETER_TYPE") public fun $arrayTypeOf(vararg elements: $elementType): $arrayType { return $arrayType(elements.size) { index -> elements[index] } }""" diff --git a/libraries/stdlib/unsigned/src/kotlin/UByte.kt b/libraries/stdlib/unsigned/src/kotlin/UByte.kt index 1f466993a92..d53f29bcdb5 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UByte.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UByte.kt @@ -9,6 +9,7 @@ package kotlin import kotlin.experimental.* +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class UByte internal constructor(private val data: Byte) : Comparable { companion object { diff --git a/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt b/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt index f5b44712b52..6865e9f33f0 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt @@ -7,6 +7,7 @@ package kotlin +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class UByteArray internal constructor(private val storage: ByteArray) : Collection { /** Returns the array element at the given [index]. This method can be called using the index operator. */ @@ -40,6 +41,7 @@ public /*inline*/ fun UByteArray(size: Int, init: (Int) -> UByte): UByteArray { return UByteArray(ByteArray(size) { index -> init(index).toByte() }) } +@Suppress("FORBIDDEN_VARARG_PARAMETER_TYPE") public fun ubyteArrayOf(vararg elements: UByte): UByteArray { return UByteArray(elements.size) { index -> elements[index] } } diff --git a/libraries/stdlib/unsigned/src/kotlin/UInt.kt b/libraries/stdlib/unsigned/src/kotlin/UInt.kt index bb423b57996..95b8d20b092 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UInt.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UInt.kt @@ -9,6 +9,7 @@ package kotlin import kotlin.experimental.* +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class UInt internal constructor(private val data: Int) : Comparable { companion object { diff --git a/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt b/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt index b6afcd3d4be..840c3cb8fde 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt @@ -7,6 +7,7 @@ package kotlin +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class UIntArray internal constructor(private val storage: IntArray) : Collection { /** Returns the array element at the given [index]. This method can be called using the index operator. */ @@ -40,6 +41,7 @@ public /*inline*/ fun UIntArray(size: Int, init: (Int) -> UInt): UIntArray { return UIntArray(IntArray(size) { index -> init(index).toInt() }) } +@Suppress("FORBIDDEN_VARARG_PARAMETER_TYPE") public fun uintArrayOf(vararg elements: UInt): UIntArray { return UIntArray(elements.size) { index -> elements[index] } } diff --git a/libraries/stdlib/unsigned/src/kotlin/ULong.kt b/libraries/stdlib/unsigned/src/kotlin/ULong.kt index 6b7b0c3fa0f..6cedd768c09 100644 --- a/libraries/stdlib/unsigned/src/kotlin/ULong.kt +++ b/libraries/stdlib/unsigned/src/kotlin/ULong.kt @@ -9,6 +9,7 @@ package kotlin import kotlin.experimental.* +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class ULong internal constructor(private val data: Long) : Comparable { companion object { diff --git a/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt b/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt index 6dadead7316..4a8464b368f 100644 --- a/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt @@ -7,6 +7,7 @@ package kotlin +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class ULongArray internal constructor(private val storage: LongArray) : Collection { /** Returns the array element at the given [index]. This method can be called using the index operator. */ @@ -40,6 +41,7 @@ public /*inline*/ fun ULongArray(size: Int, init: (Int) -> ULong): ULongArray { return ULongArray(LongArray(size) { index -> init(index).toLong() }) } +@Suppress("FORBIDDEN_VARARG_PARAMETER_TYPE") public fun ulongArrayOf(vararg elements: ULong): ULongArray { return ULongArray(elements.size) { index -> elements[index] } } diff --git a/libraries/stdlib/unsigned/src/kotlin/UShort.kt b/libraries/stdlib/unsigned/src/kotlin/UShort.kt index be63b42cc43..3b4e2ec08d7 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UShort.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UShort.kt @@ -9,6 +9,7 @@ package kotlin import kotlin.experimental.* +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class UShort internal constructor(private val data: Short) : Comparable { companion object { diff --git a/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt b/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt index 0dd3a113a37..7be43d7bb7a 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt @@ -7,6 +7,7 @@ package kotlin +@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") public inline class UShortArray internal constructor(private val storage: ShortArray) : Collection { /** Returns the array element at the given [index]. This method can be called using the index operator. */ @@ -40,6 +41,7 @@ public /*inline*/ fun UShortArray(size: Int, init: (Int) -> UShort): UShortArray return UShortArray(ShortArray(size) { index -> init(index).toShort() }) } +@Suppress("FORBIDDEN_VARARG_PARAMETER_TYPE") public fun ushortArrayOf(vararg elements: UShort): UShortArray { return UShortArray(elements.size) { index -> elements[index] } }