Migrate type parameter list syntax.

This commit is contained in:
Ilya Gorbunov
2015-11-17 22:54:22 +03:00
parent 16c5289e6c
commit c3190bbae3
7 changed files with 21 additions and 21 deletions
@@ -24,19 +24,19 @@ internal object EmptySet : Set<Nothing>, Serializable {
/** 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). */
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). */
public fun setOf<T>(): Set<T> = emptySet()
public fun <T> setOf(): Set<T> = emptySet()
/** 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. */
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. */
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.
*/
@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.
*/
@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.
*/
@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))
+4 -4
View File
@@ -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].
*/
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]
@@ -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.
*/
@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]
@@ -47,7 +47,7 @@ public fun lazy<T>(initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initial
* Also this behavior can be changed in the future.
*/
@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) {
LazyThreadSafetyMode.SYNCHRONIZED -> SynchronizedLazyImpl(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.
*/
@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].
@@ -183,7 +183,7 @@ class CollectionJVMTest {
assertTrue(value === result)
}
private fun serializeAndDeserialize<T>(value: T): T {
private fun <T> serializeAndDeserialize(value: T): T {
val outputStream = ByteArrayOutputStream()
val objectOutputStream = ObjectOutputStream(outputStream)
@@ -2,7 +2,7 @@ package test.collections
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()
}
@@ -11,11 +11,11 @@ public class CompareContext<out T>(public val expected: T, public val actual: T)
public fun equals(message: String = "") {
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)
}
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)
}
+2 -2
View File
@@ -8,7 +8,7 @@ import org.junit.Test as test
class ComplexMapJsTest : MapJsTest() {
// 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>(3)
HashMap<K, Int>(3, 0.5f)
@@ -488,5 +488,5 @@ abstract class MapJsTest {
return map
}
fun genericHashMapOf<K, V>(vararg values: Pair<K, V>) = hashMapOf(*values)
fun <K, V> genericHashMapOf(vararg values: Pair<K, V>) = hashMapOf(*values)
}
+2 -2
View File
@@ -8,7 +8,7 @@ import java.util.LinkedHashSet
class ComplexSetJsTest : SetJsTest() {
// Helper function with generic parameter to force to use ComlpexHashMap
fun doTest<T>() {
fun <T> doTest() {
HashSet<T>()
HashSet<T>(3)
HashSet<T>(3, 0.5f)
@@ -257,5 +257,5 @@ abstract class SetJsTest {
return set
}
fun genericHashSetOf<T>(vararg values: T) = hashSetOf(*values)
fun <T> genericHashSetOf(vararg values: T) = hashSetOf(*values)
}
+1 -1
View File
@@ -86,7 +86,7 @@ class LazyJVMTest {
}
private fun serializeAndDeserialize<T>(value: T): T {
private fun <T> serializeAndDeserialize(value: T): T {
val outputStream = ByteArrayOutputStream()
val objectOutputStream = ObjectOutputStream(outputStream)