From 382b2d4a967cc210c9d60a3e7a51aa40365ff93f Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Fri, 29 Nov 2013 11:43:45 +0400 Subject: [PATCH] Fix compilation warnings with redundant inline annotation --- libraries/stdlib/src/kotlin/Arrays.kt | 22 ++-- libraries/stdlib/src/kotlin/ArraysJVM.kt | 120 +++++++++--------- libraries/stdlib/src/kotlin/Char.kt | 24 ++-- .../stdlib/src/kotlin/IterablesSpecial.kt | 6 +- libraries/stdlib/src/kotlin/Iterators.kt | 2 +- libraries/stdlib/src/kotlin/JLangJVM.kt | 2 +- libraries/stdlib/src/kotlin/JUtil.kt | 10 +- libraries/stdlib/src/kotlin/Lists.kt | 10 +- libraries/stdlib/src/kotlin/Maps.kt | 8 +- libraries/stdlib/src/kotlin/MapsJVM.kt | 6 +- libraries/stdlib/src/kotlin/OrderingJVM.kt | 4 +- libraries/stdlib/src/kotlin/Standard.kt | 6 +- libraries/stdlib/src/kotlin/StandardJVM.kt | 8 +- libraries/stdlib/src/kotlin/Strings.kt | 12 +- libraries/stdlib/src/kotlin/StringsJVM.kt | 32 ++--- libraries/stdlib/src/kotlin/dom/Dom.kt | 26 ++-- libraries/stdlib/src/kotlin/io/Files.kt | 2 +- libraries/stdlib/src/kotlin/io/JIO.kt | 46 +++---- 18 files changed, 173 insertions(+), 173 deletions(-) diff --git a/libraries/stdlib/src/kotlin/Arrays.kt b/libraries/stdlib/src/kotlin/Arrays.kt index 1623355c67c..814648726d4 100644 --- a/libraries/stdlib/src/kotlin/Arrays.kt +++ b/libraries/stdlib/src/kotlin/Arrays.kt @@ -1,34 +1,34 @@ package kotlin /** Returns true if the array is not empty */ -public inline fun Array.isNotEmpty() : Boolean = !this.isEmpty() +public fun Array.isNotEmpty() : Boolean = !this.isEmpty() /** Returns true if the array is empty */ -public inline fun Array.isEmpty() : Boolean = this.size == 0 +public fun Array.isEmpty() : Boolean = this.size == 0 -public inline val BooleanArray.lastIndex : Int +public val BooleanArray.lastIndex : Int get() = this.size - 1 -public inline val ByteArray.lastIndex : Int +public val ByteArray.lastIndex : Int get() = this.size - 1 -public inline val ShortArray.lastIndex : Int +public val ShortArray.lastIndex : Int get() = this.size - 1 -public inline val IntArray.lastIndex : Int +public val IntArray.lastIndex : Int get() = this.size - 1 -public inline val LongArray.lastIndex : Int +public val LongArray.lastIndex : Int get() = this.size - 1 -public inline val FloatArray.lastIndex : Int +public val FloatArray.lastIndex : Int get() = this.size - 1 -public inline val DoubleArray.lastIndex : Int +public val DoubleArray.lastIndex : Int get() = this.size - 1 -public inline val CharArray.lastIndex : Int +public val CharArray.lastIndex : Int get() = this.size - 1 -public inline val Array.lastIndex : Int +public val Array.lastIndex : Int get() = this.size - 1 diff --git a/libraries/stdlib/src/kotlin/ArraysJVM.kt b/libraries/stdlib/src/kotlin/ArraysJVM.kt index caf5c9898bc..9534db8647c 100644 --- a/libraries/stdlib/src/kotlin/ArraysJVM.kt +++ b/libraries/stdlib/src/kotlin/ArraysJVM.kt @@ -6,40 +6,40 @@ import java.util.Arrays import jet.runtime.Intrinsic // Array "constructor" -[Intrinsic("kotlin.arrays.array")] public inline fun array(vararg t : T) : Array = t +[Intrinsic("kotlin.arrays.array")] public fun array(vararg t : T) : Array = t // "constructors" for primitive types array -[Intrinsic("kotlin.arrays.array")] public inline fun doubleArray(vararg content : Double) : DoubleArray = content +[Intrinsic("kotlin.arrays.array")] public fun doubleArray(vararg content : Double) : DoubleArray = content -[Intrinsic("kotlin.arrays.array")] public inline fun floatArray(vararg content : Float) : FloatArray = content +[Intrinsic("kotlin.arrays.array")] public fun floatArray(vararg content : Float) : FloatArray = content -[Intrinsic("kotlin.arrays.array")] public inline fun longArray(vararg content : Long) : LongArray = content +[Intrinsic("kotlin.arrays.array")] public fun longArray(vararg content : Long) : LongArray = content -[Intrinsic("kotlin.arrays.array")] public inline fun intArray(vararg content : Int) : IntArray = content +[Intrinsic("kotlin.arrays.array")] public fun intArray(vararg content : Int) : IntArray = content -[Intrinsic("kotlin.arrays.array")] public inline fun charArray(vararg content : Char) : CharArray = content +[Intrinsic("kotlin.arrays.array")] public fun charArray(vararg content : Char) : CharArray = content -[Intrinsic("kotlin.arrays.array")] public inline fun shortArray(vararg content : Short) : ShortArray = content +[Intrinsic("kotlin.arrays.array")] public fun shortArray(vararg content : Short) : ShortArray = content -[Intrinsic("kotlin.arrays.array")] public inline fun byteArray(vararg content : Byte) : ByteArray = content +[Intrinsic("kotlin.arrays.array")] public fun byteArray(vararg content : Byte) : ByteArray = content -[Intrinsic("kotlin.arrays.array")] public inline fun booleanArray(vararg content : Boolean) : BooleanArray = content +[Intrinsic("kotlin.arrays.array")] public fun booleanArray(vararg content : Boolean) : BooleanArray = content -public inline fun ByteArray.binarySearch(key: Byte) : Int = Arrays.binarySearch(this, key) -public inline fun ShortArray.binarySearch(key: Short) : Int = Arrays.binarySearch(this, key) -public inline fun IntArray.binarySearch(key: Int) : Int = Arrays.binarySearch(this, key) -public inline fun LongArray.binarySearch(key: Long) : Int = Arrays.binarySearch(this, key) -public inline fun FloatArray.binarySearch(key: Float) : Int = Arrays.binarySearch(this, key) -public inline fun DoubleArray.binarySearch(key: Double) : Int = Arrays.binarySearch(this, key) -public inline fun CharArray.binarySearch(key: Char) : Int = Arrays.binarySearch(this, key) +public fun ByteArray.binarySearch(key: Byte) : Int = Arrays.binarySearch(this, key) +public fun ShortArray.binarySearch(key: Short) : Int = Arrays.binarySearch(this, key) +public fun IntArray.binarySearch(key: Int) : Int = Arrays.binarySearch(this, key) +public fun LongArray.binarySearch(key: Long) : Int = Arrays.binarySearch(this, key) +public fun FloatArray.binarySearch(key: Float) : Int = Arrays.binarySearch(this, key) +public fun DoubleArray.binarySearch(key: Double) : Int = Arrays.binarySearch(this, key) +public fun CharArray.binarySearch(key: Char) : Int = Arrays.binarySearch(this, key) -public inline fun ByteArray.binarySearch(fromIndex: Int, toIndex: Int, key: Byte) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun ShortArray.binarySearch(fromIndex: Int, toIndex: Int, key: Short) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun IntArray.binarySearch(fromIndex: Int, toIndex: Int, key: Int) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun LongArray.binarySearch(fromIndex: Int, toIndex: Int, key: Long) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun FloatArray.binarySearch(fromIndex: Int, toIndex: Int, key: Float) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun DoubleArray.binarySearch(fromIndex: Int, toIndex: Int, key: Double) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun CharArray.binarySearch(fromIndex: Int, toIndex: Int, key: Char) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public fun ByteArray.binarySearch(fromIndex: Int, toIndex: Int, key: Byte) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public fun ShortArray.binarySearch(fromIndex: Int, toIndex: Int, key: Short) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public fun IntArray.binarySearch(fromIndex: Int, toIndex: Int, key: Int) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public fun LongArray.binarySearch(fromIndex: Int, toIndex: Int, key: Long) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public fun FloatArray.binarySearch(fromIndex: Int, toIndex: Int, key: Float) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public fun DoubleArray.binarySearch(fromIndex: Int, toIndex: Int, key: Double) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public fun CharArray.binarySearch(fromIndex: Int, toIndex: Int, key: Char) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) /* public inline fun Array.binarySearch(key: T, comparator: public fun(T,T):Int) = Arrays.binarySearch(this, key, object: java.util.Comparator { @@ -48,32 +48,32 @@ public inline fun Array.binarySearch(key: T, comparator: public fun(T,T): public override fun equals(obj: Any?) = obj.identityEquals(this) }) */ -public inline fun BooleanArray.fill(value: Boolean) : Unit = Arrays.fill(this, value) -public inline fun ByteArray.fill(value: Byte) : Unit = Arrays.fill(this, value) -public inline fun ShortArray.fill(value: Short) : Unit = Arrays.fill(this, value) -public inline fun IntArray.fill(value: Int) : Unit = Arrays.fill(this, value) -public inline fun LongArray.fill(value: Long) : Unit = Arrays.fill(this, value) -public inline fun FloatArray.fill(value: Float) : Unit = Arrays.fill(this, value) -public inline fun DoubleArray.fill(value: Double) : Unit = Arrays.fill(this, value) -public inline fun CharArray.fill(value: Char) : Unit = Arrays.fill(this, value) +public fun BooleanArray.fill(value: Boolean) : Unit = Arrays.fill(this, value) +public fun ByteArray.fill(value: Byte) : Unit = Arrays.fill(this, value) +public fun ShortArray.fill(value: Short) : Unit = Arrays.fill(this, value) +public fun IntArray.fill(value: Int) : Unit = Arrays.fill(this, value) +public fun LongArray.fill(value: Long) : Unit = Arrays.fill(this, value) +public fun FloatArray.fill(value: Float) : Unit = Arrays.fill(this, value) +public fun DoubleArray.fill(value: Double) : Unit = Arrays.fill(this, value) +public fun CharArray.fill(value: Char) : Unit = Arrays.fill(this, value) -public inline fun Array.fill(value: T) : Unit = Arrays.fill(this, value) +public fun Array.fill(value: T) : Unit = Arrays.fill(this, value) -public inline fun ByteArray.sort() : Unit = Arrays.sort(this) -public inline fun ShortArray.sort() : Unit = Arrays.sort(this) -public inline fun IntArray.sort() : Unit = Arrays.sort(this) -public inline fun LongArray.sort() : Unit = Arrays.sort(this) -public inline fun FloatArray.sort() : Unit = Arrays.sort(this) -public inline fun DoubleArray.sort() : Unit = Arrays.sort(this) -public inline fun CharArray.sort() : Unit = Arrays.sort(this) +public fun ByteArray.sort() : Unit = Arrays.sort(this) +public fun ShortArray.sort() : Unit = Arrays.sort(this) +public fun IntArray.sort() : Unit = Arrays.sort(this) +public fun LongArray.sort() : Unit = Arrays.sort(this) +public fun FloatArray.sort() : Unit = Arrays.sort(this) +public fun DoubleArray.sort() : Unit = Arrays.sort(this) +public fun CharArray.sort() : Unit = Arrays.sort(this) -public inline fun ByteArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun ShortArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun IntArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun LongArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun FloatArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun DoubleArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun CharArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public fun ByteArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public fun ShortArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public fun IntArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public fun LongArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public fun FloatArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public fun DoubleArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public fun CharArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) public fun BooleanArray.copyOf(newLength: Int = this.size) : BooleanArray = Arrays.copyOf(this, newLength) public fun ByteArray.copyOf(newLength: Int = this.size) : ByteArray = Arrays.copyOf(this, newLength) @@ -87,27 +87,27 @@ public fun CharArray.copyOf(newLength: Int = this.size) : CharArray = Arra // TODO: resuling array may contain nulls even if T is non-nullable public fun Array.copyOf(newLength: Int = this.size) : Array = Arrays.copyOf(this, newLength) as Array -public inline fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to) -public inline fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to) -public inline fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to) -public inline fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to) -public inline fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to) -public inline fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to) -public inline fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to) -public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to) +public fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to) +public fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to) +public fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to) +public fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to) +public fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to) +public fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to) +public fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to) +public fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to) // TODO: resuling array may contain nulls even if T is non-nullable -public inline fun Array.copyOfRange(from: Int, to: Int) : Array = Arrays.copyOfRange(this, from, to) as Array +public fun Array.copyOfRange(from: Int, to: Int) : Array = Arrays.copyOfRange(this, from, to) as Array -public inline val ByteArray.inputStream : ByteArrayInputStream +public val ByteArray.inputStream : ByteArrayInputStream get() = ByteArrayInputStream(this) -public inline fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length) +public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length) -public inline fun ByteArray.toString(encoding: String): String = String(this, encoding) -public inline fun ByteArray.toString(): String = String(this) +public fun ByteArray.toString(encoding: String): String = String(this, encoding) +public fun ByteArray.toString(): String = String(this) -public inline fun ByteArray.toString(encoding: Charset) : String = String(this, encoding) +public fun ByteArray.toString(encoding: Charset) : String = String(this, encoding) [Intrinsic("kotlin.collections.copyToArray")] public fun Collection.copyToArray(): Array = throw UnsupportedOperationException() diff --git a/libraries/stdlib/src/kotlin/Char.kt b/libraries/stdlib/src/kotlin/Char.kt index de43e12b254..f7153545d83 100644 --- a/libraries/stdlib/src/kotlin/Char.kt +++ b/libraries/stdlib/src/kotlin/Char.kt @@ -1,36 +1,36 @@ package kotlin -public inline fun Char.isDefined(): Boolean = Character.isDefined(this) +public fun Char.isDefined(): Boolean = Character.isDefined(this) -public inline fun Char.isDigit(): Boolean = Character.isDigit(this) +public fun Char.isDigit(): Boolean = Character.isDigit(this) -public inline fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this) +public fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this) -public inline fun Char.isIdentifierIgnorable(): Boolean = Character.isIdentifierIgnorable(this) +public fun Char.isIdentifierIgnorable(): Boolean = Character.isIdentifierIgnorable(this) -public inline fun Char.isISOControl(): Boolean = Character.isISOControl(this) +public fun Char.isISOControl(): Boolean = Character.isISOControl(this) -public inline fun Char.isJavaIdentifierPart(): Boolean = Character.isJavaIdentifierPart(this) +public fun Char.isJavaIdentifierPart(): Boolean = Character.isJavaIdentifierPart(this) -public inline fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdentifierStart(this) +public fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdentifierStart(this) -public inline fun Char.isJavaLetter(): Boolean = Character.isJavaLetter(this) +public fun Char.isJavaLetter(): Boolean = Character.isJavaLetter(this) -public inline fun Char.isJavaLetterOrDigit(): Boolean = Character.isJavaLetterOrDigit(this) +public fun Char.isJavaLetterOrDigit(): Boolean = Character.isJavaLetterOrDigit(this) /** * Returns true if the character is whitespace * * @includeFunctionBody ../../test/StringTest.kt count */ -public inline fun Char.isWhitespace(): Boolean = Character.isWhitespace(this) +public fun Char.isWhitespace(): Boolean = Character.isWhitespace(this) /** * Returns true if this character is upper case */ -public inline fun Char.isUpperCase(): Boolean = Character.isUpperCase(this) +public fun Char.isUpperCase(): Boolean = Character.isUpperCase(this) /** * Returns true if this character is lower case */ -public inline fun Char.isLowerCase(): Boolean = Character.isLowerCase(this) +public fun Char.isLowerCase(): Boolean = Character.isLowerCase(this) diff --git a/libraries/stdlib/src/kotlin/IterablesSpecial.kt b/libraries/stdlib/src/kotlin/IterablesSpecial.kt index 347e1ecc7bd..eb5a8a13c92 100644 --- a/libraries/stdlib/src/kotlin/IterablesSpecial.kt +++ b/libraries/stdlib/src/kotlin/IterablesSpecial.kt @@ -34,7 +34,7 @@ public fun countTo(n: Int): (T) -> Boolean { * * Will throw an exception if there are no elements */ -public inline fun Iterable.first() : T { +public fun Iterable.first() : T { if (this is List) { return this.first() } @@ -64,13 +64,13 @@ public fun Iterable.containsItem(item : T) : Boolean { } -public inline fun > Iterable.sort() : List { +public fun > Iterable.sort() : List { val list = toCollection(ArrayList()) java.util.Collections.sort(list) return list } -public inline fun Iterable.sort(comparator: java.util.Comparator) : List { +public fun Iterable.sort(comparator: java.util.Comparator) : List { val list = toCollection(ArrayList()) java.util.Collections.sort(list, comparator) return list diff --git a/libraries/stdlib/src/kotlin/Iterators.kt b/libraries/stdlib/src/kotlin/Iterators.kt index d44266ca9bb..1a900359b2d 100644 --- a/libraries/stdlib/src/kotlin/Iterators.kt +++ b/libraries/stdlib/src/kotlin/Iterators.kt @@ -21,7 +21,7 @@ public /*inline*/ fun iterate(initialValue: T, nextFunction: (T) -> T?) /** * Returns an iterator whose values are pairs composed of values produced by given pair of iterators */ -public inline fun Iterator.zip(iterator: Iterator): Iterator> = PairIterator(this, iterator) +public fun Iterator.zip(iterator: Iterator): Iterator> = PairIterator(this, iterator) /** * Returns an iterator shifted to right by the given number of elements diff --git a/libraries/stdlib/src/kotlin/JLangJVM.kt b/libraries/stdlib/src/kotlin/JLangJVM.kt index 6e16ba6f8a0..6f72fc37919 100644 --- a/libraries/stdlib/src/kotlin/JLangJVM.kt +++ b/libraries/stdlib/src/kotlin/JLangJVM.kt @@ -15,7 +15,7 @@ import jet.runtime.Intrinsic * A helper method for calling hashCode() on Kotlin objects * TODO remove when Any supports equals() and hashCode() */ -[Intrinsic("kotlin.hashCode")] public inline fun Any.hashCode(): Int = (this as java.lang.Object).hashCode() +[Intrinsic("kotlin.hashCode")] public fun Any.hashCode(): Int = (this as java.lang.Object).hashCode() /** * A helper method for calling toString() on Kotlin primitives diff --git a/libraries/stdlib/src/kotlin/JUtil.kt b/libraries/stdlib/src/kotlin/JUtil.kt index e68d39890c7..0b5c3176933 100644 --- a/libraries/stdlib/src/kotlin/JUtil.kt +++ b/libraries/stdlib/src/kotlin/JUtil.kt @@ -17,27 +17,27 @@ public val Int.indices: IntRange get() = 0..this-1 /** Returns true if the collection is not empty */ -public inline fun Collection.isNotEmpty() : Boolean = !this.isEmpty() +public fun Collection.isNotEmpty() : Boolean = !this.isEmpty() /** Returns true if this collection is not empty */ val Collection<*>.notEmpty : Boolean get() = isNotEmpty() /** Returns the Collection if its not null otherwise it returns the empty list */ -public inline fun Collection?.orEmpty() : Collection +public fun Collection?.orEmpty() : Collection = if (this != null) this else Collections.emptyList() as Collection /** TODO these functions don't work when they generate the Array versions when they are in JLIterables */ -public inline fun > Iterable.toSortedList() : List = toCollection(ArrayList()).sort() +public fun > Iterable.toSortedList() : List = toCollection(ArrayList()).sort() -public inline fun > Iterable.toSortedList(comparator: java.util.Comparator) : List = toList().sort(comparator) +public fun > Iterable.toSortedList(comparator: java.util.Comparator) : List = toList().sort(comparator) // List APIs /** Returns the List if its not null otherwise returns the empty list */ -public inline fun List?.orEmpty() : List +public fun List?.orEmpty() : List = if (this != null) this else Collections.emptyList() as List /** diff --git a/libraries/stdlib/src/kotlin/Lists.kt b/libraries/stdlib/src/kotlin/Lists.kt index 8c4c0dabac1..f5c65acbb14 100644 --- a/libraries/stdlib/src/kotlin/Lists.kt +++ b/libraries/stdlib/src/kotlin/Lists.kt @@ -3,21 +3,21 @@ package kotlin /** * Get the first element in the list or throws [[EmptyIterableException]] if list is empty. */ -public inline fun List.first() : T { +public fun List.first() : T { return if (size() > 0) get(0) else throw EmptyIterableException(this) } /** * Get the first element in the list or *null* if list is empty. */ -public inline fun List.firstOrNull() : T? { +public fun List.firstOrNull() : T? { return if (size() > 0) get(0) else null } /** * Get the last element in the list or throws [[EmptyIterableException]] if list is empty. */ -public inline fun List.last() : T { +public fun List.last() : T { val s = size() return if (s > 0) get(s - 1) else throw EmptyIterableException(this) } @@ -25,7 +25,7 @@ public inline fun List.last() : T { /** * Get the last element in the list or *null* if list is empty. */ -public inline fun List.lastOrNull() : T? { +public fun List.lastOrNull() : T? { val s = size() return if (s > 0) get(s - 1) else null } @@ -71,7 +71,7 @@ public inline fun List.reduceRight(operation: (T, T) -> T) : T { /** * Returns a original Iterable containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements */ -public inline fun List.requireNoNulls() : List { +public fun List.requireNoNulls() : List { for (element in this) { if (element == null) { throw IllegalArgumentException("null element found in $this") diff --git a/libraries/stdlib/src/kotlin/Maps.kt b/libraries/stdlib/src/kotlin/Maps.kt index 72642535184..cb100563b63 100644 --- a/libraries/stdlib/src/kotlin/Maps.kt +++ b/libraries/stdlib/src/kotlin/Maps.kt @@ -17,7 +17,7 @@ get() = isEmpty() public fun MutableMap.set(key : K, value : V) : V? = this.put(key, value) /** Returns the [[Map]] if its not null otherwise it returns the empty [[Map]] */ -public inline fun Map?.orEmpty() : Map +public fun Map?.orEmpty() : Map = if (this != null) this else Collections.emptyMap() as Map @@ -73,7 +73,7 @@ public inline fun MutableMap.getOrPut(key: K, defaultValue: ()-> V) : * * @includeFunctionBody ../../test/MapTest.kt iterateWithProperties */ -public inline fun Map.iterator(): Iterator> { +public fun Map.iterator(): Iterator> { val entrySet = this.entrySet() return entrySet.iterator() } @@ -102,7 +102,7 @@ public inline fun > Map.mapValuesTo(result: C, tra /** * Puts all the entries into this [[MutableMap]] with the first value in the pair being the key and the second the value */ -public inline fun MutableMap.putAll(vararg values: Pair): Unit { +public fun MutableMap.putAll(vararg values: Pair): Unit { for (v in values) { put(v.first, v.second) } @@ -111,7 +111,7 @@ public inline fun MutableMap.putAll(vararg values: Pair): Unit /** * Copies the entries in this [[Map]] to the given mutable *map* */ -public inline fun Map.toMap(map: MutableMap): Map { +public fun Map.toMap(map: MutableMap): Map { map.putAll(this) return map } diff --git a/libraries/stdlib/src/kotlin/MapsJVM.kt b/libraries/stdlib/src/kotlin/MapsJVM.kt index 86b4a201efa..aaa347132b3 100644 --- a/libraries/stdlib/src/kotlin/MapsJVM.kt +++ b/libraries/stdlib/src/kotlin/MapsJVM.kt @@ -11,14 +11,14 @@ import java.util.Properties /** * Converts this [[Map]] to a [[LinkedHashMap]] so future insertion orders are maintained */ -public inline fun Map.toLinkedMap(): LinkedHashMap = toMap(LinkedHashMap(size)) as LinkedHashMap +public fun Map.toLinkedMap(): LinkedHashMap = toMap(LinkedHashMap(size)) as LinkedHashMap /** * Converts this [[Map]] to a [[SortedMap]] so iteration order will be in key order * * @includeFunctionBody ../../test/MapTest.kt toSortedMap */ -public inline fun Map.toSortedMap(): SortedMap = toMap(TreeMap()) as SortedMap +public fun Map.toSortedMap(): SortedMap = toMap(TreeMap()) as SortedMap /** * Converts this [[Map]] to a [[SortedMap]] using the given *comparator* so that iteration order will be in the order @@ -26,7 +26,7 @@ public inline fun Map.toSortedMap(): SortedMap = toMap(Tree * * @includeFunctionBody ../../test/MapTest.kt toSortedMapWithComparator */ -public inline fun Map.toSortedMap(comparator: Comparator): SortedMap = toMap(TreeMap(comparator)) as SortedMap +public fun Map.toSortedMap(comparator: Comparator): SortedMap = toMap(TreeMap(comparator)) as SortedMap /** diff --git a/libraries/stdlib/src/kotlin/OrderingJVM.kt b/libraries/stdlib/src/kotlin/OrderingJVM.kt index 47e54c154b1..9c6050accfb 100644 --- a/libraries/stdlib/src/kotlin/OrderingJVM.kt +++ b/libraries/stdlib/src/kotlin/OrderingJVM.kt @@ -6,7 +6,7 @@ import java.util.Comparator * Helper method for implementing [[Comparable]] methods using a list of functions * to calculate the values to compare */ -inline fun compareBy(a: T?, b: T?, vararg functions: T.() -> Comparable<*>?): Int { +fun compareBy(a: T?, b: T?, vararg functions: T.() -> Comparable<*>?): Int { require(functions.size > 0) if (a === b) return 0 if (a == null) return - 1 @@ -25,7 +25,7 @@ inline fun compareBy(a: T?, b: T?, vararg functions: T.() -> Comparabl * they are compared via [[#equals()]] and if they are not the same then * the [[#hashCode()]] method is used as the difference */ -public inline fun > compareValues(a: T?, b: T?): Int { +public fun > compareValues(a: T?, b: T?): Int { if (a === b) return 0 if (a == null) return - 1 if (b == null) return 1 diff --git a/libraries/stdlib/src/kotlin/Standard.kt b/libraries/stdlib/src/kotlin/Standard.kt index 081f9b85fdb..70cdcc0d480 100644 --- a/libraries/stdlib/src/kotlin/Standard.kt +++ b/libraries/stdlib/src/kotlin/Standard.kt @@ -31,12 +31,12 @@ public fun > Iterator.toCollection(container: U) : U { /** Add iterated elements to java.util.ArrayList */ -public inline fun Iterator.toArrayList() : ArrayList = toCollection(ArrayList()) +public fun Iterator.toArrayList() : ArrayList = toCollection(ArrayList()) /** Add iterated elements to java.util.HashSet */ -public inline fun Iterator.toHashSet() : HashSet = toCollection(HashSet()) +public fun Iterator.toHashSet() : HashSet = toCollection(HashSet()) /** @@ -45,7 +45,7 @@ public inline fun Iterator.toHashSet() : HashSet = toCollection(HashSe * @includeFunctionBody ../../test/MapTest.kt createUsingTo */ -public inline fun A.to(that: B): Pair = Pair(this, that) +public fun A.to(that: B): Pair = Pair(this, that) /** Run function f diff --git a/libraries/stdlib/src/kotlin/StandardJVM.kt b/libraries/stdlib/src/kotlin/StandardJVM.kt index 65031ead58f..5d70f6ead87 100644 --- a/libraries/stdlib/src/kotlin/StandardJVM.kt +++ b/libraries/stdlib/src/kotlin/StandardJVM.kt @@ -14,18 +14,18 @@ import java.util.concurrent.Callable /** * Add iterated elements to a [[LinkedHashSet]] to preserve insertion order */ -public inline fun Iterator.toLinkedSet() : LinkedHashSet = toCollection(LinkedHashSet()) +public fun Iterator.toLinkedSet() : LinkedHashSet = toCollection(LinkedHashSet()) /** * Add iterated elements to [[SortedSet]] with the given *comparator* to ensure iteration is in the order of the given comparator */ -public inline fun Iterator.toSortedSet(comparator: Comparator) : SortedSet = toCollection(TreeSet(comparator)) +public fun Iterator.toSortedSet(comparator: Comparator) : SortedSet = toCollection(TreeSet(comparator)) /** * Allows a stack trace to be printed from Kotlin's [[Throwable]] */ -public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit { +public fun Throwable.printStackTrace(writer: PrintWriter): Unit { val jlt = this as java.lang.Throwable jlt.printStackTrace(writer) } @@ -33,7 +33,7 @@ public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit { /** * Allows a stack trace to be printed from Kotlin's [[Throwable]] */ -public inline fun Throwable.printStackTrace(stream: PrintStream): Unit { +public fun Throwable.printStackTrace(stream: PrintStream): Unit { val jlt = this as java.lang.Throwable jlt.printStackTrace(stream) } diff --git a/libraries/stdlib/src/kotlin/Strings.kt b/libraries/stdlib/src/kotlin/Strings.kt index 726c4e54b90..ab3cb1e0444 100644 --- a/libraries/stdlib/src/kotlin/Strings.kt +++ b/libraries/stdlib/src/kotlin/Strings.kt @@ -6,13 +6,13 @@ import java.util.HashSet import java.util.LinkedList /** Returns the string with leading and trailing text matching the given string removed */ -public inline fun String.trim(text: String) : String = trimLeading(text).trimTrailing(text) +public fun String.trim(text: String) : String = trimLeading(text).trimTrailing(text) /** Returns the string with the prefix and postfix text trimmed */ -public inline fun String.trim(prefix: String, postfix: String) : String = trimLeading(prefix).trimTrailing(postfix) +public fun String.trim(prefix: String, postfix: String) : String = trimLeading(prefix).trimTrailing(postfix) /** Returns the string with the leading prefix of this string removed */ -public inline fun String.trimLeading(prefix: String): String { +public fun String.trimLeading(prefix: String): String { var answer = this if (answer.startsWith(prefix)) { answer = answer.substring(prefix.length()) @@ -21,7 +21,7 @@ public inline fun String.trimLeading(prefix: String): String { } /** Returns the string with the trailing postfix of this string removed */ -public inline fun String.trimTrailing(postfix: String): String { +public fun String.trimTrailing(postfix: String): String { var answer = this if (answer.endsWith(postfix)) { answer = answer.substring(0, length() - postfix.length()) @@ -30,7 +30,7 @@ public inline fun String.trimTrailing(postfix: String): String { } /** Returns true if the string is not null and not empty */ -public inline fun String?.isNotEmpty() : Boolean = this != null && this.length() > 0 +public fun String?.isNotEmpty() : Boolean = this != null && this.length() > 0 /** Iterator for characters of given CharSequence @@ -44,7 +44,7 @@ public fun CharSequence.iterator() : CharIterator = object: jet.CharIterator() { } /** Returns the string if it is not null or the empty string if its null */ -public inline fun String?.orEmpty(): String = this ?: "" +public fun String?.orEmpty(): String = this ?: "" // "Extension functions" for CharSequence diff --git a/libraries/stdlib/src/kotlin/StringsJVM.kt b/libraries/stdlib/src/kotlin/StringsJVM.kt index 1af3682d5f7..f8611d3f32a 100644 --- a/libraries/stdlib/src/kotlin/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/StringsJVM.kt @@ -35,7 +35,7 @@ public inline fun String.getBytes() : ByteArray = (this as java.lang.String).get public inline fun String.toCharArray() : CharArray = (this as java.lang.String).toCharArray() -public inline fun String.toCharList(): List = toCharArray().toList() +public fun String.toCharList(): List = toCharArray().toList() public inline fun String.format(vararg args : Any?) : String = java.lang.String.format(this, *args) @@ -136,11 +136,11 @@ public inline fun String.toUpperCase(locale : java.util.Locale) : String = (this public inline fun CharSequence.charAt(index : Int) : Char = (this as java.lang.CharSequence).charAt(index) -public inline fun CharSequence.get(index : Int) : Char = charAt(index) +public fun CharSequence.get(index : Int) : Char = charAt(index) public inline fun CharSequence.subSequence(start : Int, end : Int) : CharSequence? = (this as java.lang.CharSequence).subSequence(start, end) -public inline fun CharSequence.get(start : Int, end : Int) : CharSequence? = subSequence(start, end) +public fun CharSequence.get(start : Int, end : Int) : CharSequence? = subSequence(start, end) public inline fun CharSequence.toString() : String? = (this as java.lang.CharSequence).toString() @@ -178,7 +178,7 @@ get() = length() * * @includeFunctionBody ../../test/StringTest.kt capitalize */ -public inline fun String.capitalize(): String { +public fun String.capitalize(): String { return if (isNotEmpty() && charAt(0).isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this } @@ -187,7 +187,7 @@ public inline fun String.capitalize(): String { * * @includeFunctionBody ../../test/StringTest.kt decapitalize */ -public inline fun String.decapitalize(): String { +public fun String.decapitalize(): String { return if (isNotEmpty() && charAt(0).isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this } @@ -196,7 +196,7 @@ public inline fun String.decapitalize(): String { * When n < 0, IllegalArgumentException is thrown. * @includeFunctionBody ../../test/StringTest.kt repeat */ -public inline fun String.repeat(n: Int): String { +public fun String.repeat(n: Int): String { require(n >= 0, { "Cannot repeat string $n times" }) var sb = StringBuilder() @@ -246,7 +246,7 @@ public inline fun String.filterNotTo(result: T, predicate: (Char * * @includeFunctionBody ../../test/StringTest.kt reverse */ -public inline fun String.reverse(): String = StringBuilder(this).reverse().toString() +public fun String.reverse(): String = StringBuilder(this).reverse().toString() /** * Performs the given *operation* on each character @@ -477,7 +477,7 @@ public inline fun String.dropWhile(predicate: (Char) -> Boolean): String = dropW * * @includeFunctionBody ../../test/StringTest.kt drop */ -public inline fun String.drop(n: Int): String = dropWhile(countTo(n)) +public fun String.drop(n: Int): String = dropWhile(countTo(n)) /** * Returns an Appendable containing the first characters that satisfy the given *predicate* @@ -501,28 +501,28 @@ public inline fun String.takeWhile(predicate: (Char) -> Boolean): String = takeW * * @includeFunctionBody ../../test/StringTest.kt take */ -public inline fun String.take(n: Int): String = takeWhile(countTo(n)) +public fun String.take(n: Int): String = takeWhile(countTo(n)) /** Copies all characters into the given collection */ -public inline fun > String.toCollection(result: C): C { +public fun > String.toCollection(result: C): C { for (c in this) result.add(c) return result } /** Copies all characters into a [[LinkedList]] */ -public inline fun String.toLinkedList(): LinkedList = toCollection(LinkedList()) +public fun String.toLinkedList(): LinkedList = toCollection(LinkedList()) /** Copies all characters into a [[List]] */ -public inline fun String.toList(): List = toCollection(ArrayList(this.length())) +public fun String.toList(): List = toCollection(ArrayList(this.length())) /** Copies all characters into a [[Collection] */ -public inline fun String.toCollection(): Collection = toCollection(ArrayList(this.length())) +public fun String.toCollection(): Collection = toCollection(ArrayList(this.length())) /** Copies all characters into a [[Set]] */ -public inline fun String.toSet(): Set = toCollection(HashSet()) +public fun String.toSet(): Set = toCollection(HashSet()) /** Returns a new String containing the everything but the leading whitespace characters */ -public inline fun String.trimLeading(): String { +public fun String.trimLeading(): String { var count = 0 while ((count < this.length) && (this[count] <= ' ')) { @@ -532,7 +532,7 @@ public inline fun String.trimLeading(): String { } /** Returns a new String containing the everything but the trailing whitespace characters */ -public inline fun String.trimTrailing(): String { +public fun String.trimTrailing(): String { var count = this.length while (count > 0 && this[count - 1] <= ' ') { diff --git a/libraries/stdlib/src/kotlin/dom/Dom.kt b/libraries/stdlib/src/kotlin/dom/Dom.kt index bbe7034f66e..5f9c202d1e1 100644 --- a/libraries/stdlib/src/kotlin/dom/Dom.kt +++ b/libraries/stdlib/src/kotlin/dom/Dom.kt @@ -77,17 +77,17 @@ fun Element.hasClass(cssClass: String): Boolean { /** Returns the children of the element as a list */ -inline fun Element?.children(): List { +fun Element?.children(): List { return this?.childNodes.toList() } /** Returns the child elements of this element */ -inline fun Element?.childElements(): List { +fun Element?.childElements(): List { return children().filter{ it.nodeType == Node.ELEMENT_NODE }.map { it as Element } } /** Returns the child elements of this element with the given name */ -inline fun Element?.childElements(name: String): List { +fun Element?.childElements(name: String): List { return children().filter{ it.nodeType == Node.ELEMENT_NODE && it.nodeName == name }.map { it as Element } } @@ -101,26 +101,26 @@ get() = this?.getElementsByTagName("*").toElementList() /** Returns all the descendant elements given the local element name */ -inline fun Element?.elements(localName: String): List { +fun Element?.elements(localName: String): List { return this?.getElementsByTagName(localName).toElementList() } /** Returns all the descendant elements given the local element name */ -inline fun Document?.elements(localName: String): List { +fun Document?.elements(localName: String): List { return this?.getElementsByTagName(localName).toElementList() } /** Returns all the descendant elements given the namespace URI and local element name */ -inline fun Element?.elements(namespaceUri: String, localName: String): List { +fun Element?.elements(namespaceUri: String, localName: String): List { return this?.getElementsByTagNameNS(namespaceUri, localName).toElementList() } /** Returns all the descendant elements given the namespace URI and local element name */ -inline fun Document?.elements(namespaceUri: String, localName: String): List { +fun Document?.elements(namespaceUri: String, localName: String): List { return this?.getElementsByTagNameNS(namespaceUri, localName).toElementList() } -inline fun NodeList?.toList(): List { +fun NodeList?.toList(): List { return if (this == null) { // TODO the following is easier to convert to JS emptyNodeList() @@ -130,7 +130,7 @@ inline fun NodeList?.toList(): List { } } -inline fun NodeList?.toElementList(): List { +fun NodeList?.toElementList(): List { return if (this == null) { // TODO the following is easier to convert to JS //emptyElementList() @@ -297,7 +297,7 @@ fun Node.isText(): Boolean { } /** Returns the attribute value or empty string if its not present */ -inline fun Element.attribute(name: String): String { +fun Element.attribute(name: String): String { return this.getAttribute(name) ?: "" } @@ -342,16 +342,16 @@ public fun nodesToXmlString(nodes: Iterable, xmlDeclaration: Boolean = fal // Syntax sugar -inline fun Node.plus(child: Node?): Node { +fun Node.plus(child: Node?): Node { if (child != null) { this.appendChild(child) } return this } -inline fun Element.plus(text: String?): Element = this.addText(text) +fun Element.plus(text: String?): Element = this.addText(text) -inline fun Element.plusAssign(text: String?): Element = this.addText(text) +fun Element.plusAssign(text: String?): Element = this.addText(text) // Builder diff --git a/libraries/stdlib/src/kotlin/io/Files.kt b/libraries/stdlib/src/kotlin/io/Files.kt index 1cc10c95aa4..90fd22ac331 100644 --- a/libraries/stdlib/src/kotlin/io/Files.kt +++ b/libraries/stdlib/src/kotlin/io/Files.kt @@ -84,7 +84,7 @@ public fun File.relativePath(descendant: File): String { /** * Creates a new [[FileReader]] for this file */ -public inline fun File.reader(): FileReader = FileReader(this) +public fun File.reader(): FileReader = FileReader(this) /** * Reads the entire content of the file as bytes diff --git a/libraries/stdlib/src/kotlin/io/JIO.kt b/libraries/stdlib/src/kotlin/io/JIO.kt index 6167d2cd3fe..93f9f38c6b6 100644 --- a/libraries/stdlib/src/kotlin/io/JIO.kt +++ b/libraries/stdlib/src/kotlin/io/JIO.kt @@ -17,88 +17,88 @@ public val defaultCharset: Charset = Charset.forName("UTF-8")!! /** Prints the given message to [[System.out]] */ -public inline fun print(message : Any?) { +public fun print(message : Any?) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Int) { +public fun print(message : Int) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Long) { +public fun print(message : Long) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Byte) { +public fun print(message : Byte) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Short) { +public fun print(message : Short) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Char) { +public fun print(message : Char) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Boolean) { +public fun print(message : Boolean) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Float) { +public fun print(message : Float) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : Double) { +public fun print(message : Double) { System.out.print(message) } /** Prints the given message to [[System.out]] */ -public inline fun print(message : CharArray) { +public fun print(message : CharArray) { System.out.print(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Any?) { +public fun println(message : Any?) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Int) { +public fun println(message : Int) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Long) { +public fun println(message : Long) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Byte) { +public fun println(message : Byte) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Short) { +public fun println(message : Short) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Char) { +public fun println(message : Char) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Boolean) { +public fun println(message : Boolean) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Float) { +public fun println(message : Float) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : Double) { +public fun println(message : Double) { System.out.println(message) } /** Prints the given message and newline to [[System.out]] */ -public inline fun println(message : CharArray) { +public fun println(message : CharArray) { System.out.println(message) } /** Prints a newline t[[System.out]] */ -public inline fun println() { +public fun println() { System.out.println() } @@ -186,9 +186,9 @@ else public fun InputStream.reader(encoding: Charset = defaultCharset) : InputStreamReader = InputStreamReader(this, encoding) -public inline fun InputStream.reader(encoding: String) : InputStreamReader = InputStreamReader(this, encoding) +public fun InputStream.reader(encoding: String) : InputStreamReader = InputStreamReader(this, encoding) -public inline fun InputStream.reader(encoding: CharsetDecoder) : InputStreamReader = InputStreamReader(this, encoding) +public fun InputStream.reader(encoding: CharsetDecoder) : InputStreamReader = InputStreamReader(this, encoding) public fun OutputStream.buffered(bufferSize: Int = defaultBufferSize) : BufferedOutputStream