[Native] Mark necessary methods that must be evaluated at compile-time
It includes methods and properties from Boolean, Char, String, Enum and KCallable.
This commit is contained in:
@@ -21,6 +21,7 @@ public class Boolean private constructor() : Comparable<Boolean> {
|
||||
* Returns the inverse of this boolean.
|
||||
*/
|
||||
@TypedIntrinsic(IntrinsicType.NOT)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public operator fun not(): Boolean
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,7 @@ public class Boolean private constructor() : Comparable<Boolean> {
|
||||
* this function does not perform short-circuit evaluation. Both `this` and [other] will always be evaluated.
|
||||
*/
|
||||
@TypedIntrinsic(IntrinsicType.AND)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public infix fun and(other: Boolean): Boolean
|
||||
|
||||
/**
|
||||
@@ -35,22 +37,28 @@ public class Boolean private constructor() : Comparable<Boolean> {
|
||||
* this function does not perform short-circuit evaluation. Both `this` and [other] will always be evaluated.
|
||||
*/
|
||||
@TypedIntrinsic(IntrinsicType.OR)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public infix fun or(other: Boolean): Boolean
|
||||
|
||||
/**
|
||||
* Performs a logical `xor` operation between this Boolean and the [other] one.
|
||||
*/
|
||||
@TypedIntrinsic(IntrinsicType.XOR)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public infix fun xor(other: Boolean): Boolean
|
||||
|
||||
@TypedIntrinsic(IntrinsicType.UNSIGNED_COMPARE_TO)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public override fun compareTo(other: Boolean): Int
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public fun equals(other: Boolean): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun equals(other: Any?): Boolean =
|
||||
other is Boolean && kotlin.native.internal.areEqualByValue(this, other)
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun toString() = if (this) "true" else "false"
|
||||
|
||||
public override fun hashCode() = if (this) 1 else 0
|
||||
|
||||
@@ -22,15 +22,19 @@ public class Char private constructor() : Comparable<Char> {
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
@TypedIntrinsic(IntrinsicType.UNSIGNED_COMPARE_TO)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public override fun compareTo(other: Char): Int
|
||||
|
||||
/** Adds the other Int value to this value resulting a Char. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline operator fun plus(other: Int): Char =
|
||||
(this.code + other).toChar()
|
||||
/** Subtracts the other Char value from this value resulting an Int. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline operator fun minus(other: Char): Int =
|
||||
this.code - other.code
|
||||
/** Subtracts the other Int value from this value resulting a Char. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline operator fun minus(other: Int): Char =
|
||||
(this.code - other).toChar()
|
||||
|
||||
@@ -67,33 +71,40 @@ public class Char private constructor() : Comparable<Char> {
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toByte()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@TypedIntrinsic(IntrinsicType.INT_TRUNCATE)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public fun toByte(): Byte
|
||||
/** Returns the value of this character as a `Char`. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline fun toChar(): Char = this
|
||||
/** Returns the value of this character as a `Short`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toShort()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@TypedIntrinsic(IntrinsicType.ZERO_EXTEND)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public fun toShort(): Short
|
||||
/** Returns the value of this character as a `Int`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@TypedIntrinsic(IntrinsicType.ZERO_EXTEND)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public fun toInt(): Int
|
||||
/** Returns the value of this character as a `Long`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toLong()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@TypedIntrinsic(IntrinsicType.ZERO_EXTEND)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public fun toLong(): Long
|
||||
/** Returns the value of this character as a `Float`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toFloat()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@TypedIntrinsic(IntrinsicType.UNSIGNED_TO_FLOAT)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public fun toFloat(): Float
|
||||
/** Returns the value of this character as a `Double`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toDouble()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@TypedIntrinsic(IntrinsicType.UNSIGNED_TO_FLOAT)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public fun toDouble(): Double
|
||||
|
||||
@kotlin.native.internal.CanBePrecreated
|
||||
@@ -193,12 +204,15 @@ public class Char private constructor() : Comparable<Char> {
|
||||
public const val MAX_RADIX: Int = 36
|
||||
}
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public fun equals(other: Char): Boolean = this == other
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun equals(other: Any?): Boolean =
|
||||
other is Char && this.equals(other)
|
||||
|
||||
@GCUnsafeCall("Kotlin_Char_toString")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external public override fun toString(): String
|
||||
|
||||
public override fun hashCode(): Int {
|
||||
|
||||
@@ -13,7 +13,7 @@ import kotlin.native.internal.enumValuesIntrinsic
|
||||
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/enum-classes.html) for more
|
||||
* information on enum classes.
|
||||
*/
|
||||
public abstract class Enum<E: Enum<E>>(public val name: String, public val ordinal: Int): Comparable<E> {
|
||||
public abstract class Enum<E: Enum<E>>(@kotlin.internal.IntrinsicConstEvaluation public val name: String, public val ordinal: Int): Comparable<E> {
|
||||
|
||||
public companion object {
|
||||
}
|
||||
|
||||
@@ -21,15 +21,18 @@ public final class String : Comparable<String>, CharSequence {
|
||||
@GCUnsafeCall("Kotlin_String_hashCode")
|
||||
external public override fun hashCode(): Int
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public operator fun plus(other: Any?): String {
|
||||
return plusImpl(other.toString())
|
||||
}
|
||||
|
||||
@TypedIntrinsic(IntrinsicType.IDENTITY)
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
override public fun toString(): String {
|
||||
return this
|
||||
}
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override val length: Int
|
||||
get() = getStringLength()
|
||||
|
||||
@@ -39,12 +42,14 @@ public final class String : Comparable<String>, CharSequence {
|
||||
* If the [index] is out of bounds of this string, throws an [IndexOutOfBoundsException].
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_String_get")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public external override fun get(index: Int): Char
|
||||
|
||||
@GCUnsafeCall("Kotlin_String_subSequence")
|
||||
public external override fun subSequence(startIndex: Int, endIndex: Int): CharSequence
|
||||
|
||||
@GCUnsafeCall("Kotlin_String_compareTo")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public external override fun compareTo(other: String): Int
|
||||
|
||||
@GCUnsafeCall("Kotlin_String_getStringLength")
|
||||
@@ -55,6 +60,7 @@ public final class String : Comparable<String>, CharSequence {
|
||||
internal external fun plusImpl(other: String): String
|
||||
|
||||
@GCUnsafeCall("Kotlin_String_equals")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
external override fun equals(other: Any?): Boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public actual interface KCallable<out R> : KAnnotatedElement {
|
||||
* - property accessors: the getter for a property named "foo" will have the name "<get-foo>",
|
||||
* the setter, similarly, will have the name "<set-foo>".
|
||||
*/
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public actual val name: String
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user