Migrate type parameter list syntax.
This commit is contained in:
@@ -24,19 +24,19 @@ internal object EmptySet : Set<Nothing>, Serializable {
|
|||||||
|
|
||||||
|
|
||||||
/** Returns an empty read-only set. The returned set is serializable (JVM). */
|
/** Returns an empty read-only set. The returned set is serializable (JVM). */
|
||||||
public fun emptySet<T>(): Set<T> = EmptySet
|
public fun <T> emptySet(): Set<T> = EmptySet
|
||||||
/** Returns a new read-only ordered set with the given elements. The returned set is serializable (JVM). */
|
/** Returns a new read-only ordered set with the given elements. The returned set is serializable (JVM). */
|
||||||
public fun setOf<T>(vararg values: T): Set<T> = if (values.size > 0) values.toSet() else emptySet()
|
public fun <T> setOf(vararg values: T): Set<T> = if (values.size > 0) values.toSet() else emptySet()
|
||||||
|
|
||||||
/** Returns an empty read-only set. The returned set is serializable (JVM). */
|
/** Returns an empty read-only set. The returned set is serializable (JVM). */
|
||||||
public fun setOf<T>(): Set<T> = emptySet()
|
public fun <T> setOf(): Set<T> = emptySet()
|
||||||
|
|
||||||
|
|
||||||
/** Returns a new [HashSet] with the given elements. */
|
/** Returns a new [HashSet] with the given elements. */
|
||||||
public fun hashSetOf<T>(vararg values: T): HashSet<T> = values.toCollection(HashSet(mapCapacity(values.size)))
|
public fun <T> hashSetOf(vararg values: T): HashSet<T> = values.toCollection(HashSet(mapCapacity(values.size)))
|
||||||
|
|
||||||
/** Returns a new [LinkedHashSet] with the given elements. */
|
/** Returns a new [LinkedHashSet] with the given elements. */
|
||||||
public fun linkedSetOf<T>(vararg values: T): LinkedHashSet<T> = values.toCollection(LinkedHashSet(mapCapacity(values.size)))
|
public fun <T> linkedSetOf(vararg values: T): LinkedHashSet<T> = values.toCollection(LinkedHashSet(mapCapacity(values.size)))
|
||||||
|
|
||||||
/** Returns this Set if it's not `null` and the empty set otherwise. */
|
/** Returns this Set if it's not `null` and the empty set otherwise. */
|
||||||
public fun <T> Set<T>?.orEmpty(): Set<T> = this ?: emptySet()
|
public fun <T> Set<T>?.orEmpty(): Set<T> = this ?: emptySet()
|
||||||
@@ -46,17 +46,17 @@ public fun <T> Set<T>?.orEmpty(): Set<T> = this ?: emptySet()
|
|||||||
* The returned set is serializable.
|
* The returned set is serializable.
|
||||||
*/
|
*/
|
||||||
@JvmVersion
|
@JvmVersion
|
||||||
public fun setOf<T>(value: T): Set<T> = Collections.singleton(value)
|
public fun <T> setOf(value: T): Set<T> = Collections.singleton(value)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new [SortedSet] with the given elements.
|
* Returns a new [SortedSet] with the given elements.
|
||||||
*/
|
*/
|
||||||
@JvmVersion
|
@JvmVersion
|
||||||
public fun sortedSetOf<T>(vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>())
|
public fun <T> sortedSetOf(vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new [SortedSet] with the given [comparator] and elements.
|
* Returns a new [SortedSet] with the given [comparator] and elements.
|
||||||
*/
|
*/
|
||||||
@JvmVersion
|
@JvmVersion
|
||||||
public fun sortedSetOf<T>(comparator: Comparator<in T>, vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>(comparator))
|
public fun <T> sortedSetOf(comparator: Comparator<in T>, vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>(comparator))
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public abstract class Lazy<out T> internal constructor() {
|
|||||||
/**
|
/**
|
||||||
* Creates a new instance of the [Lazy] that is already initialized with the specified [value].
|
* Creates a new instance of the [Lazy] that is already initialized with the specified [value].
|
||||||
*/
|
*/
|
||||||
public fun lazyOf<T>(value: T): Lazy<T> = InitializedLazyImpl(value)
|
public fun <T> lazyOf(value: T): Lazy<T> = InitializedLazyImpl(value)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]
|
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]
|
||||||
@@ -34,7 +34,7 @@ public fun lazyOf<T>(value: T): Lazy<T> = InitializedLazyImpl(value)
|
|||||||
* the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future.
|
* the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future.
|
||||||
*/
|
*/
|
||||||
@kotlin.jvm.JvmVersion
|
@kotlin.jvm.JvmVersion
|
||||||
public fun lazy<T>(initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer)
|
public fun <T> lazy(initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]
|
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]
|
||||||
@@ -47,7 +47,7 @@ public fun lazy<T>(initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initial
|
|||||||
* Also this behavior can be changed in the future.
|
* Also this behavior can be changed in the future.
|
||||||
*/
|
*/
|
||||||
@kotlin.jvm.JvmVersion
|
@kotlin.jvm.JvmVersion
|
||||||
public fun lazy<T>(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
|
public fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
|
||||||
when (mode) {
|
when (mode) {
|
||||||
LazyThreadSafetyMode.SYNCHRONIZED -> SynchronizedLazyImpl(initializer)
|
LazyThreadSafetyMode.SYNCHRONIZED -> SynchronizedLazyImpl(initializer)
|
||||||
LazyThreadSafetyMode.PUBLICATION -> SafePublicationLazyImpl(initializer)
|
LazyThreadSafetyMode.PUBLICATION -> SafePublicationLazyImpl(initializer)
|
||||||
@@ -66,7 +66,7 @@ public fun lazy<T>(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
|
|||||||
* Also this behavior can be changed in the future.
|
* Also this behavior can be changed in the future.
|
||||||
*/
|
*/
|
||||||
@kotlin.jvm.JvmVersion
|
@kotlin.jvm.JvmVersion
|
||||||
public fun lazy<T>(lock: Any?, initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer, lock)
|
public fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer, lock)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extension to delegate a read-only property of type [T] to an instance of [Lazy].
|
* An extension to delegate a read-only property of type [T] to an instance of [Lazy].
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ class CollectionJVMTest {
|
|||||||
assertTrue(value === result)
|
assertTrue(value === result)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun serializeAndDeserialize<T>(value: T): T {
|
private fun <T> serializeAndDeserialize(value: T): T {
|
||||||
val outputStream = ByteArrayOutputStream()
|
val outputStream = ByteArrayOutputStream()
|
||||||
val objectOutputStream = ObjectOutputStream(outputStream)
|
val objectOutputStream = ObjectOutputStream(outputStream)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package test.collections
|
|||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
public fun compare<T>(expected: T, actual: T, block:CompareContext<T>.() -> Unit) {
|
public fun <T> compare(expected: T, actual: T, block:CompareContext<T>.() -> Unit) {
|
||||||
CompareContext(expected, actual).block()
|
CompareContext(expected, actual).block()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,11 +11,11 @@ public class CompareContext<out T>(public val expected: T, public val actual: T)
|
|||||||
public fun equals(message: String = "") {
|
public fun equals(message: String = "") {
|
||||||
assertEquals(expected, actual, message)
|
assertEquals(expected, actual, message)
|
||||||
}
|
}
|
||||||
public fun propertyEquals<P>(message: String = "", getter: T.() -> P) {
|
public fun <P> propertyEquals(message: String = "", getter: T.() -> P) {
|
||||||
assertEquals(expected.getter(), actual.getter(), message)
|
assertEquals(expected.getter(), actual.getter(), message)
|
||||||
}
|
}
|
||||||
public fun propertyFails(getter: T.() -> Unit) { assertFailEquals({expected.getter()}, {actual.getter()}) }
|
public fun propertyFails(getter: T.() -> Unit) { assertFailEquals({expected.getter()}, {actual.getter()}) }
|
||||||
public fun compareProperty<P>(getter: T.() -> P, block: CompareContext<P>.() -> Unit) {
|
public fun <P> compareProperty(getter: T.() -> P, block: CompareContext<P>.() -> Unit) {
|
||||||
compare(expected.getter(), actual.getter(), block)
|
compare(expected.getter(), actual.getter(), block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.junit.Test as test
|
|||||||
|
|
||||||
class ComplexMapJsTest : MapJsTest() {
|
class ComplexMapJsTest : MapJsTest() {
|
||||||
// Helper function with generic parameter to force to use ComlpexHashMap
|
// Helper function with generic parameter to force to use ComlpexHashMap
|
||||||
fun doTest<K : kotlin.Comparable<K>>() {
|
fun <K : kotlin.Comparable<K>> doTest() {
|
||||||
HashMap<K, Int>()
|
HashMap<K, Int>()
|
||||||
HashMap<K, Int>(3)
|
HashMap<K, Int>(3)
|
||||||
HashMap<K, Int>(3, 0.5f)
|
HashMap<K, Int>(3, 0.5f)
|
||||||
@@ -488,5 +488,5 @@ abstract class MapJsTest {
|
|||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
fun genericHashMapOf<K, V>(vararg values: Pair<K, V>) = hashMapOf(*values)
|
fun <K, V> genericHashMapOf(vararg values: Pair<K, V>) = hashMapOf(*values)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.LinkedHashSet
|
|||||||
|
|
||||||
class ComplexSetJsTest : SetJsTest() {
|
class ComplexSetJsTest : SetJsTest() {
|
||||||
// Helper function with generic parameter to force to use ComlpexHashMap
|
// Helper function with generic parameter to force to use ComlpexHashMap
|
||||||
fun doTest<T>() {
|
fun <T> doTest() {
|
||||||
HashSet<T>()
|
HashSet<T>()
|
||||||
HashSet<T>(3)
|
HashSet<T>(3)
|
||||||
HashSet<T>(3, 0.5f)
|
HashSet<T>(3, 0.5f)
|
||||||
@@ -257,5 +257,5 @@ abstract class SetJsTest {
|
|||||||
return set
|
return set
|
||||||
}
|
}
|
||||||
|
|
||||||
fun genericHashSetOf<T>(vararg values: T) = hashSetOf(*values)
|
fun <T> genericHashSetOf(vararg values: T) = hashSetOf(*values)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class LazyJVMTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun serializeAndDeserialize<T>(value: T): T {
|
private fun <T> serializeAndDeserialize(value: T): T {
|
||||||
val outputStream = ByteArrayOutputStream()
|
val outputStream = ByteArrayOutputStream()
|
||||||
val objectOutputStream = ObjectOutputStream(outputStream)
|
val objectOutputStream = ObjectOutputStream(outputStream)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user