[builtins-gen] Explicit visibility for companion objects and secondary constructors

This commit is contained in:
Ilya Gorbunov
2023-09-19 14:48:16 +02:00
committed by Space Team
parent ab7c2f2196
commit d8ee74222f
13 changed files with 27 additions and 37 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ package kotlin
*/
public class Boolean private constructor() : Comparable<Boolean> {
@SinceKotlin("1.3")
companion object {}
public companion object {}
/** Returns the inverse of this boolean. */
@kotlin.internal.IntrinsicConstEvaluation
+1 -1
View File
@@ -108,7 +108,7 @@ public class Char private constructor() : Comparable<Char> {
public override fun hashCode(): Int
companion object {
public companion object {
/**
* The minimum value of a character code unit.
*/
+6 -6
View File
@@ -13,7 +13,7 @@ package kotlin
* On the JVM, non-nullable values of this type are represented as values of the primitive type `byte`.
*/
public class Byte private constructor() : Number(), Comparable<Byte> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Byte can have.
*/
@@ -383,7 +383,7 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `short`.
*/
public class Short private constructor() : Number(), Comparable<Short> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Short can have.
*/
@@ -751,7 +751,7 @@ public class Short private constructor() : Number(), Comparable<Short> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `int`.
*/
public class Int private constructor() : Number(), Comparable<Int> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Int can have.
*/
@@ -1165,7 +1165,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `long`.
*/
public class Long private constructor() : Number(), Comparable<Long> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Long can have.
*/
@@ -1582,7 +1582,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `float`.
*/
public class Float private constructor() : Number(), Comparable<Float> {
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Float.
*/
@@ -1915,7 +1915,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
* On the JVM, non-nullable values of this type are represented as values of the primitive type `double`.
*/
public class Double private constructor() : Number(), Comparable<Double> {
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Double.
*/
@@ -199,10 +199,6 @@ class WasmBooleanGenerator(writer: PrintWriter) : BooleanGenerator(writer) {
}
}
override fun CompanionObjectBuilder.modifyGeneratedCompanionObject() {
isPublic = true
}
override fun MethodBuilder.modifyGeneratedNot() {
implementAsIntrinsic(PrimitiveType.BOOLEAN, methodName)
}
@@ -446,7 +446,6 @@ class WasmCharGenerator(writer: PrintWriter) : CharGenerator(writer) {
}
override fun CompanionObjectBuilder.modifyGeneratedCompanionObject() {
isPublic = true
property {
appendDoc("The minimum value of a supplementary code point, `\\u0x10000`.")
visibility = MethodVisibility.INTERNAL
@@ -29,10 +29,6 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri
}
}
override fun CompanionObjectBuilder.modifyGeneratedCompanionObject(thisKind: PrimitiveType) {
isPublic = true
}
override fun primitiveConstants(type: PrimitiveType): List<Any> {
return when (type) {
PrimitiveType.FLOAT -> listOf(
+3 -4
View File
@@ -188,7 +188,6 @@ internal class ClassBuilder : AnnotatedAndDocumented(), PrimitiveBuilder {
}
internal class CompanionObjectBuilder : AnnotatedAndDocumented(), PrimitiveBuilder {
var isPublic: Boolean = false
private val properties: MutableList<PropertyBuilder> = mutableListOf()
fun property(init: PropertyBuilder.() -> Unit): PropertyBuilder {
@@ -200,7 +199,7 @@ internal class CompanionObjectBuilder : AnnotatedAndDocumented(), PrimitiveBuild
override fun build(): String {
return buildString {
printDocumentationAndAnnotations()
if (isPublic) append("public ")
append("public ")
if (properties.isEmpty()) {
append("companion object {}")
} else {
@@ -235,7 +234,7 @@ internal class PrimaryConstructorBuilder : AnnotatedAndDocumented(), PrimitiveBu
}
internal class SecondaryConstructorBuilder : AnnotatedAndDocumented(), PrimitiveBuilder {
var visibility: MethodVisibility? = MethodVisibility.PRIVATE
var visibility: MethodVisibility = MethodVisibility.PRIVATE
private var parameters: MutableList<MethodParameterBuilder> = mutableListOf()
private var argumentsToPrimaryContructor: MutableList<String> = mutableListOf()
@@ -253,7 +252,7 @@ internal class SecondaryConstructorBuilder : AnnotatedAndDocumented(), Primitive
return buildString {
printDocumentationAndAnnotations()
visibility?.let { append("${it.name.lowercase()} ") }
append("${visibility.name.lowercase()} ")
append("constructor")
append(parameters.joinToString(prefix = "(", postfix = ") : ") { it.build() })
append(argumentsToPrimaryContructor.joinToString(prefix = "this(", postfix = ")"))
@@ -14,7 +14,7 @@ import kotlin.native.internal.IntrinsicType
/** Represents a value which is either `true` or `false`. */
public class Boolean private constructor() : Comparable<Boolean> {
@SinceKotlin("1.3")
companion object {}
public companion object {}
/** Returns the inverse of this boolean. */
@kotlin.internal.IntrinsicConstEvaluation
@@ -137,7 +137,7 @@ public class Char private constructor() : Comparable<Char> {
this == other
@kotlin.native.internal.CanBePrecreated
companion object {
public companion object {
/**
* The minimum value of a character code unit.
*/
@@ -15,7 +15,7 @@ import kotlin.native.internal.*
/** Represents a 8-bit signed integer. */
public class Byte private constructor() : Number(), Comparable<Byte> {
@CanBePrecreated
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Byte can have.
*/
@@ -448,7 +448,7 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
/** Represents a 16-bit signed integer. */
public class Short private constructor() : Number(), Comparable<Short> {
@CanBePrecreated
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Short can have.
*/
@@ -879,7 +879,7 @@ public class Short private constructor() : Number(), Comparable<Short> {
/** Represents a 32-bit signed integer. */
public class Int private constructor() : Number(), Comparable<Int> {
@CanBePrecreated
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Int can have.
*/
@@ -1363,7 +1363,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
/** Represents a 64-bit signed integer. */
public class Long private constructor() : Number(), Comparable<Long> {
@CanBePrecreated
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Long can have.
*/
@@ -1849,7 +1849,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
/** Represents a single-precision 32-bit IEEE 754 floating point number. */
public class Float private constructor() : Number(), Comparable<Float> {
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Float.
*/
@@ -2260,7 +2260,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
/** Represents a double-precision 64-bit IEEE 754 floating point number. */
public class Double private constructor() : Number(), Comparable<Double> {
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Double.
*/
+1 -1
View File
@@ -13,7 +13,7 @@ package kotlin
/** Represents a value which is either `true` or `false`. */
public class Boolean private constructor() : Comparable<Boolean> {
@SinceKotlin("1.3")
companion object {}
public companion object {}
/** Returns the inverse of this boolean. */
@kotlin.internal.IntrinsicConstEvaluation
+1 -1
View File
@@ -139,7 +139,7 @@ internal constructor(private val value: Int) : Comparable<Char> {
public override fun hashCode(): Int =
value
companion object {
public companion object {
/**
* The minimum value of a character code unit.
*/
+6 -6
View File
@@ -12,7 +12,7 @@ package kotlin
/** Represents a 8-bit signed integer. */
public class Byte private constructor() : Number(), Comparable<Byte> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Byte can have.
*/
@@ -385,7 +385,7 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
/** Represents a 16-bit signed integer. */
public class Short private constructor() : Number(), Comparable<Short> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Short can have.
*/
@@ -756,7 +756,7 @@ public class Short private constructor() : Number(), Comparable<Short> {
/** Represents a 32-bit signed integer. */
public class Int private constructor() : Number(), Comparable<Int> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Int can have.
*/
@@ -1174,7 +1174,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
/** Represents a 64-bit signed integer. */
@Suppress("NOTHING_TO_INLINE")
public class Long internal constructor(internal val low: Int, internal val high: Int) : Number(), Comparable<Long> {
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Long can have.
*/
@@ -1665,7 +1665,7 @@ public class Long internal constructor(internal val low: Int, internal val high:
/** Represents a single-precision 32-bit IEEE 754 floating point number. */
public class Float private constructor() : Number(), Comparable<Float> {
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Float.
*/
@@ -2000,7 +2000,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
/** Represents a double-precision 64-bit IEEE 754 floating point number. */
public class Double private constructor() : Number(), Comparable<Double> {
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Double.
*/