From df190b12652d8606e0b88beb808b97b330d392b2 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 19 Sep 2023 13:47:45 +0200 Subject: [PATCH] [stdlib] Explicit visibility and return types: JVM internal --- .../lazyResolveStdlibSources/wrappedInt.txt | 12 ++++++------ .../runtime/kotlin/jvm/functions/FunctionN.kt | 4 ++-- .../kotlin/jvm/internal/ClassReference.kt | 8 ++++---- .../kotlin/jvm/internal/FunctionBase.kt | 4 ++-- .../runtime/kotlin/jvm/internal/KTypeBase.kt | 2 +- .../jvm/runtime/kotlin/jvm/internal/Lambda.kt | 2 +- .../kotlin/jvm/internal/PackageReference.kt | 6 +++--- .../kotlin/jvm/internal/SerializedIr.kt | 2 +- .../jvm/internal/SourceDebugExtension.kt | 2 +- .../jvm/internal/TypeParameterReference.kt | 8 ++++---- .../kotlin/jvm/internal/TypeReference.kt | 2 +- .../jvm/internal/localVariableReferences.kt | 4 ++-- .../kotlin/jvm/internal/markers/KMarkers.kt | 18 +++++++++--------- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/analysis/low-level-api-fir/testData/lazyResolveStdlibSources/wrappedInt.txt b/analysis/low-level-api-fir/testData/lazyResolveStdlibSources/wrappedInt.txt index 7e634002231..31644856ca8 100644 --- a/analysis/low-level-api-fir/testData/lazyResolveStdlibSources/wrappedInt.txt +++ b/analysis/low-level-api-fir/testData/lazyResolveStdlibSources/wrappedInt.txt @@ -17,7 +17,7 @@ FILE: [ResolvedTo(RAW_FIR)] TypeReference.kt @SinceKotlin[Unresolved](LAZY_EXPRESSION) internal final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val flags: Int = R|/flags| internal [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] get(): Int - public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { + public [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { LAZY_this } @@ -77,7 +77,7 @@ FILE: [ResolvedTo(IMPORTS)] TypeReference.kt @SinceKotlin[Unresolved](LAZY_EXPRESSION) internal final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val flags: Int = R|/flags| internal [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] get(): Int - public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { + public [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { LAZY_this } @@ -137,7 +137,7 @@ FILE: [ResolvedTo(IMPORTS)] TypeReference.kt @SinceKotlin[Unresolved](LAZY_EXPRESSION) internal final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val flags: Int = R|/flags| internal [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] get(): Int - public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { + public [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { LAZY_this } @@ -197,7 +197,7 @@ FILE: [ResolvedTo(IMPORTS)] TypeReference.kt @SinceKotlin[Unresolved](LAZY_EXPRESSION) internal final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val flags: Int = R|/flags| internal [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] get(): Int - public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { + public [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { LAZY_this } @@ -257,7 +257,7 @@ FILE: [ResolvedTo(IMPORTS)] TypeReference.kt @SinceKotlin[Unresolved](LAZY_EXPRESSION) internal final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val flags: Int = R|/flags| internal [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] get(): Int - public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { + public [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { LAZY_this } @@ -317,7 +317,7 @@ FILE: [ResolvedTo(IMPORTS)] TypeReference.kt @SinceKotlin[Unresolved](LAZY_EXPRESSION) internal final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val flags: Int = R|/flags| internal [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] get(): Int - public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { + public [ResolvedTo(RAW_FIR)] [ContainingClassKey=TypeReference] constructor([ResolvedTo(RAW_FIR)] classifier: KClassifier, [ResolvedTo(RAW_FIR)] arguments: List, [ResolvedTo(RAW_FIR)] isMarkedNullable: Boolean): R|kotlin/jvm/internal/TypeReference| { LAZY_this } diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/functions/FunctionN.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/functions/FunctionN.kt index 013e28c985e..e115144432a 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/functions/FunctionN.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/functions/FunctionN.kt @@ -13,7 +13,7 @@ import kotlin.jvm.internal.FunctionBase * This interface must only be used in Java sources to reference a Kotlin function type with more than 22 arguments. */ @SinceKotlin("1.3") -interface FunctionN : Function, FunctionBase { +public interface FunctionN : Function, FunctionBase { /** * Invokes the function with the specified arguments. * @@ -21,7 +21,7 @@ interface FunctionN : Function, FunctionBase { * * @param args arguments to the function */ - operator fun invoke(vararg args: Any?): R + public operator fun invoke(vararg args: Any?): R /** * Returns the number of arguments that must be passed to this function. diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/ClassReference.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/ClassReference.kt index 530aefa3e36..0f1332a17a1 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/ClassReference.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/ClassReference.kt @@ -87,16 +87,16 @@ public class ClassReference(override val jClass: Class<*>) : KClass, ClassB private fun error(): Nothing = throw KotlinReflectionNotSupportedError() - override fun equals(other: Any?) = + override fun equals(other: Any?): Boolean = other is ClassReference && javaObjectType == other.javaObjectType - override fun hashCode() = + override fun hashCode(): Int = javaObjectType.hashCode() - override fun toString() = + override fun toString(): String = jClass.toString() + Reflection.REFLECTION_NOT_AVAILABLE - companion object { + public companion object { private val FUNCTION_CLASSES = listOf( Function0::class.java, Function1::class.java, Function2::class.java, Function3::class.java, Function4::class.java, diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/FunctionBase.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/FunctionBase.kt index 9fc2751f293..f70d8de7807 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/FunctionBase.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/FunctionBase.kt @@ -5,6 +5,6 @@ package kotlin.jvm.internal -interface FunctionBase : Function { - val arity: Int +public interface FunctionBase : Function { + public val arity: Int } diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/KTypeBase.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/KTypeBase.kt index d611af88d08..41fd4283aee 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/KTypeBase.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/KTypeBase.kt @@ -10,5 +10,5 @@ import kotlin.reflect.KType @SinceKotlin("1.4") public interface KTypeBase : KType { - val javaType: Type? + public val javaType: Type? } diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/Lambda.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/Lambda.kt index b2697d53f78..9fa7a31b3c7 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/Lambda.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/Lambda.kt @@ -7,6 +7,6 @@ package kotlin.jvm.internal import java.io.Serializable -abstract class Lambda(override val arity: Int) : FunctionBase, Serializable { +public abstract class Lambda(override val arity: Int) : FunctionBase, Serializable { override fun toString(): String = Reflection.renderLambdaToString(this) } diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/PackageReference.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/PackageReference.kt index 41194cec9fc..0ee8ccc47ef 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/PackageReference.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/PackageReference.kt @@ -15,12 +15,12 @@ public class PackageReference( override val members: Collection> get() = throw KotlinReflectionNotSupportedError() - override fun equals(other: Any?) = + override fun equals(other: Any?): Boolean = other is PackageReference && jClass == other.jClass - override fun hashCode() = + override fun hashCode(): Int = jClass.hashCode() - override fun toString() = + override fun toString(): String = jClass.toString() + Reflection.REFLECTION_NOT_AVAILABLE } diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SerializedIr.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SerializedIr.kt index d2424887887..75d16b2b4d8 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SerializedIr.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SerializedIr.kt @@ -11,7 +11,7 @@ package kotlin.jvm.internal @Retention(AnnotationRetention.BINARY) @Target(AnnotationTarget.CLASS) @SinceKotlin("1.6") -annotation class SerializedIr( +public annotation class SerializedIr( @get:JvmName("b") val bytes: Array = [] ) diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SourceDebugExtension.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SourceDebugExtension.kt index 233055af7eb..61929475b78 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SourceDebugExtension.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/SourceDebugExtension.kt @@ -15,4 +15,4 @@ package kotlin.jvm.internal @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) @SinceKotlin("1.8") -annotation class SourceDebugExtension(val value: Array) +public annotation class SourceDebugExtension(val value: Array) diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeParameterReference.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeParameterReference.kt index 7f469e1d0fc..96ef5d38718 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeParameterReference.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeParameterReference.kt @@ -11,7 +11,7 @@ import kotlin.reflect.KVariance import kotlin.reflect.typeOf @SinceKotlin("1.4") -class TypeParameterReference( +public class TypeParameterReference( private val container: Any?, // Either ClassReference or CallableReference override val name: String, override val variance: KVariance, @@ -24,7 +24,7 @@ class TypeParameterReference( override val upperBounds: List get() = bounds ?: listOf(typeOf()).also { bounds = it } - fun setUpperBounds(upperBounds: List) { + public fun setUpperBounds(upperBounds: List) { // This assertion is only checking that the typeOf compiler implementation didn't generate some nonsense in bytecode. // Since this class is not used anywhere else, we don't use any locks to prevent double initialization here intentionally. if (bounds != null) { @@ -41,8 +41,8 @@ class TypeParameterReference( override fun toString(): String = toString(this) - companion object { - fun toString(typeParameter: KTypeParameter): String = + public companion object { + public fun toString(typeParameter: KTypeParameter): String = buildString { when (typeParameter.variance) { KVariance.INVARIANT -> { diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt index fd862ff6c6d..1140573a2e7 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt @@ -14,7 +14,7 @@ public class TypeReference @SinceKotlin("1.6") constructor( @SinceKotlin("1.6") internal val platformTypeUpperBound: KType?, @SinceKotlin("1.6") internal val flags: Int, ) : KType { - constructor( + public constructor( classifier: KClassifier, arguments: List, isMarkedNullable: Boolean, diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/localVariableReferences.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/localVariableReferences.kt index 4e2229b2f5d..5016cc64d6a 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/localVariableReferences.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/localVariableReferences.kt @@ -14,7 +14,7 @@ private fun notSupportedError(): Nothing { } @SinceKotlin("1.1") -open class LocalVariableReference : PropertyReference0() { +public open class LocalVariableReference : PropertyReference0() { override fun getOwner(): KDeclarationContainer = notSupportedError() override fun get(): Any? = notSupportedError() @@ -22,7 +22,7 @@ open class LocalVariableReference : PropertyReference0() { } @SinceKotlin("1.1") -open class MutableLocalVariableReference : MutablePropertyReference0() { +public open class MutableLocalVariableReference : MutablePropertyReference0() { override fun getOwner(): KDeclarationContainer = notSupportedError() override fun get(): Any? = notSupportedError() diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/markers/KMarkers.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/markers/KMarkers.kt index 2269a6c050a..7232b1e2f3e 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/markers/KMarkers.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/markers/KMarkers.kt @@ -5,20 +5,20 @@ package kotlin.jvm.internal.markers -interface KMappedMarker +public interface KMappedMarker -interface KMutableIterable : KMappedMarker +public interface KMutableIterable : KMappedMarker -interface KMutableCollection : KMutableIterable +public interface KMutableCollection : KMutableIterable -interface KMutableList : KMutableCollection +public interface KMutableList : KMutableCollection -interface KMutableIterator : KMappedMarker +public interface KMutableIterator : KMappedMarker -interface KMutableListIterator : KMutableIterator +public interface KMutableListIterator : KMutableIterator -interface KMutableMap : KMappedMarker { - interface Entry : KMappedMarker +public interface KMutableMap : KMappedMarker { + public interface Entry : KMappedMarker } -interface KMutableSet : KMutableCollection \ No newline at end of file +public interface KMutableSet : KMutableCollection \ No newline at end of file