[stdlib] Explicit visibility and return types: common

This commit is contained in:
Ilya Gorbunov
2023-09-19 14:25:49 +02:00
committed by Space Team
parent 7a267afeae
commit 02e933b3ff
13 changed files with 267 additions and 129 deletions
@@ -50,7 +50,7 @@ public expect annotation class CName(val externName: String = "", val shortName:
)
@Retention(AnnotationRetention.BINARY)
@OptionalExpectation
expect annotation class FreezingIsDeprecated
public expect annotation class FreezingIsDeprecated
/**
* Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function.
@@ -26,9 +26,9 @@ package kotlin.collections
@SinceKotlin("1.1")
public interface Grouping<T, out K> {
/** Returns an [Iterator] over the elements of the source of this grouping. */
fun sourceIterator(): Iterator<T>
public fun sourceIterator(): Iterator<T>
/** Extracts the key of an [element]. */
fun keyOf(element: T): K
public fun keyOf(element: T): K
}
/**
@@ -89,7 +89,7 @@ public abstract class SequenceScope<in T> internal constructor() {
*
* @sample samples.collections.Sequences.Building.buildSequenceYieldAll
*/
public suspend fun yieldAll(sequence: Sequence<T>) = yieldAll(sequence.iterator())
public suspend fun yieldAll(sequence: Sequence<T>): Unit = yieldAll(sequence.iterator())
}
private typealias State = Int
@@ -21,7 +21,7 @@ public interface ContinuationInterceptor : CoroutineContext.Element {
/**
* The key that defines *the* context interceptor.
*/
companion object Key : CoroutineContext.Key<ContinuationInterceptor>
public companion object Key : CoroutineContext.Key<ContinuationInterceptor>
/**
* Returns continuation that wraps the original [continuation], thus intercepting all resumptions.
+1 -1
View File
@@ -267,7 +267,7 @@ public abstract class Random {
*
* @sample samples.random.Randoms.defaultRandom
*/
companion object Default : Random(), Serializable {
public companion object Default : Random(), Serializable {
private val defaultRandom: Random = defaultPlatformRandom()
private object Serialized : Serializable {
@@ -21,7 +21,7 @@ import kotlin.internal.LowPriorityInOverloadResolution
*/
@SinceKotlin("1.4")
@LowPriorityInOverloadResolution
fun <T : Any> KClass<T>.cast(value: Any?): T {
public fun <T : Any> KClass<T>.cast(value: Any?): T {
if (!isInstance(value)) throw ClassCastException("Value cannot be cast to $qualifiedOrSimpleName")
return value as T
}
@@ -40,6 +40,6 @@ internal expect val KClass<*>.qualifiedOrSimpleName: String?
*/
@SinceKotlin("1.4")
@LowPriorityInOverloadResolution
fun <T : Any> KClass<T>.safeCast(value: Any?): T? {
public fun <T : Any> KClass<T>.safeCast(value: Any?): T? {
return if (isInstance(value)) value as T else null
}
@@ -16,7 +16,7 @@ package kotlin.reflect
* @see [KTypeProjection]
*/
@SinceKotlin("1.1")
enum class KVariance {
public enum class KVariance {
/**
* The affected type parameter or type is *invariant*, which means it has no variance applied to it.
*/
@@ -11,20 +11,20 @@ package kotlin.text
/**
* An object to which char sequences and values can be appended.
*/
expect interface Appendable {
public expect interface Appendable {
/**
* Appends the specified character [value] to this Appendable and returns this instance.
*
* @param value the character to append.
*/
fun append(value: Char): Appendable
public fun append(value: Char): Appendable
/**
* Appends the specified character sequence [value] to this Appendable and returns this instance.
*
* @param value the character sequence to append. If [value] is `null`, then the four characters `"null"` are appended to this Appendable.
*/
fun append(value: CharSequence?): Appendable
public fun append(value: CharSequence?): Appendable
/**
* Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance.
@@ -36,7 +36,7 @@ expect interface Appendable {
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
*/
fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable
public fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable
}
/**
@@ -14,7 +14,7 @@ package kotlin
* @constructor Creates a version from all three components.
*/
@SinceKotlin("1.1")
public class KotlinVersion(val major: Int, val minor: Int, val patch: Int) : Comparable<KotlinVersion> {
public class KotlinVersion(public val major: Int, public val minor: Int, public val patch: Int) : Comparable<KotlinVersion> {
/**
* Creates a version from [major] and [minor] components, leaving [patch] component zero.
*/
@@ -61,12 +61,12 @@ public class KotlinVersion(val major: Int, val minor: Int, val patch: Int) : Com
(this.minor > minor || this.minor == minor &&
this.patch >= patch))
companion object {
public companion object {
/**
* Maximum value a version component can have, a constant value 255.
*/
// NOTE: Must be placed before CURRENT because its initialization requires this field being initialized in JS
public const val MAX_COMPONENT_VALUE = 255
public const val MAX_COMPONENT_VALUE: Int = 255
/**
* Returns the current version of the Kotlin standard library.
+1 -1
View File
@@ -19,5 +19,5 @@ import kotlin.reflect.KProperty0
*/
@SinceKotlin("1.2")
@InlineOnly
inline val @receiver:AccessibleLateinitPropertyLiteral KProperty0<*>.isInitialized: Boolean
public inline val @receiver:AccessibleLateinitPropertyLiteral KProperty0<*>.isInitialized: Boolean
get() = throw NotImplementedError("Implementation is intrinsic")