From d54fb97c5d96ad09be83a310587d5997ac6959cd Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 4 Apr 2014 15:27:24 +0400 Subject: [PATCH] Make all *Array.fill() extensions returning an array #KT-4760 Fixed --- libraries/stdlib/src/generated/_SpecialJVM.kt | 36 ++++++++++++++----- .../src/templates/SpecialJVM.kt | 8 +++-- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/libraries/stdlib/src/generated/_SpecialJVM.kt b/libraries/stdlib/src/generated/_SpecialJVM.kt index 292c6b9238e..d87041b41f6 100644 --- a/libraries/stdlib/src/generated/_SpecialJVM.kt +++ b/libraries/stdlib/src/generated/_SpecialJVM.kt @@ -255,64 +255,82 @@ public fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray { /** * Fills original array with the provided value */ -public fun Array.fill(element: T) : Unit { +public fun Array.fill(element: T) : Array { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun BooleanArray.fill(element: Boolean) : Unit { +public fun BooleanArray.fill(element: Boolean) : BooleanArray { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun ByteArray.fill(element: Byte) : Unit { +public fun ByteArray.fill(element: Byte) : ByteArray { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun CharArray.fill(element: Char) : Unit { +public fun CharArray.fill(element: Char) : CharArray { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun DoubleArray.fill(element: Double) : Unit { +public fun DoubleArray.fill(element: Double) : DoubleArray { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun FloatArray.fill(element: Float) : Unit { +public fun FloatArray.fill(element: Float) : FloatArray { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun IntArray.fill(element: Int) : Unit { +public fun IntArray.fill(element: Int) : IntArray { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun LongArray.fill(element: Long) : Unit { +public fun LongArray.fill(element: Long) : LongArray { Arrays.fill(this, element) + return this + } /** * Fills original array with the provided value */ -public fun ShortArray.fill(element: Short) : Unit { +public fun ShortArray.fill(element: Short) : ShortArray { Arrays.fill(this, element) + return this + } /** diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index b670749f4e5..38ae49d9ec2 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -43,9 +43,13 @@ fun specialJVM(): List { templates add f("fill(element: T)") { only(ArraysOfObjects, ArraysOfPrimitives) doc { "Fills original array with the provided value" } - returns("Unit") + returns { "SELF" } + returns(ArraysOfObjects) { "Array" } body { - "Arrays.fill(this, element)" + """ + Arrays.fill(this, element) + return this + """ } }