From 3f5d3e5dbc7f974b773c30c3c4f330602076ad4e Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 20 Oct 2016 14:42:48 +0300 Subject: [PATCH] Fix errors and indent in built-ins sources --- .../builtin-classes/default/kotlin.txt | 14 +- .../testData/builtin-classes/java6/kotlin.txt | 14 +- .../testData/builtin-classes/java8/kotlin.txt | 14 +- .../builtin-classes/newMethods/kotlin.txt | 14 +- core/builtins/native/kotlin/Boolean.kt | 2 +- core/builtins/native/kotlin/Char.kt | 17 +- core/builtins/native/kotlin/Nothing.kt | 2 +- core/builtins/native/kotlin/Primitives.kt | 402 ++++++++++-------- .../kotlin/generators/builtins/primitives.kt | 19 +- 9 files changed, 263 insertions(+), 235 deletions(-) diff --git a/compiler/testData/builtin-classes/default/kotlin.txt b/compiler/testData/builtin-classes/default/kotlin.txt index a7000715188..8164c551dea 100644 --- a/compiler/testData/builtin-classes/default/kotlin.txt +++ b/compiler/testData/builtin-classes/default/kotlin.txt @@ -134,13 +134,13 @@ public final class Char : kotlin.Comparable { public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange - public open fun toByte(): kotlin.Byte - public open fun toChar(): kotlin.Char - public open fun toDouble(): kotlin.Double - public open fun toFloat(): kotlin.Float - public open fun toInt(): kotlin.Int - public open fun toLong(): kotlin.Long - public open fun toShort(): kotlin.Short + public final fun toByte(): kotlin.Byte + public final fun toChar(): kotlin.Char + public final fun toDouble(): kotlin.Double + public final fun toFloat(): kotlin.Float + public final fun toInt(): kotlin.Int + public final fun toLong(): kotlin.Long + public final fun toShort(): kotlin.Short public companion object Companion { /*primary*/ private constructor Companion() diff --git a/compiler/testData/builtin-classes/java6/kotlin.txt b/compiler/testData/builtin-classes/java6/kotlin.txt index 210307557fb..8f3f6916938 100644 --- a/compiler/testData/builtin-classes/java6/kotlin.txt +++ b/compiler/testData/builtin-classes/java6/kotlin.txt @@ -134,13 +134,13 @@ public final class Char : kotlin.Comparable, java.io.Serializable { public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange - public open fun toByte(): kotlin.Byte - public open fun toChar(): kotlin.Char - public open fun toDouble(): kotlin.Double - public open fun toFloat(): kotlin.Float - public open fun toInt(): kotlin.Int - public open fun toLong(): kotlin.Long - public open fun toShort(): kotlin.Short + public final fun toByte(): kotlin.Byte + public final fun toChar(): kotlin.Char + public final fun toDouble(): kotlin.Double + public final fun toFloat(): kotlin.Float + public final fun toInt(): kotlin.Int + public final fun toLong(): kotlin.Long + public final fun toShort(): kotlin.Short public companion object Companion { /*primary*/ private constructor Companion() diff --git a/compiler/testData/builtin-classes/java8/kotlin.txt b/compiler/testData/builtin-classes/java8/kotlin.txt index be04f6d651d..35c39569c54 100644 --- a/compiler/testData/builtin-classes/java8/kotlin.txt +++ b/compiler/testData/builtin-classes/java8/kotlin.txt @@ -134,13 +134,13 @@ public final class Char : kotlin.Comparable, java.io.Serializable { public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange - public open fun toByte(): kotlin.Byte - public open fun toChar(): kotlin.Char - public open fun toDouble(): kotlin.Double - public open fun toFloat(): kotlin.Float - public open fun toInt(): kotlin.Int - public open fun toLong(): kotlin.Long - public open fun toShort(): kotlin.Short + public final fun toByte(): kotlin.Byte + public final fun toChar(): kotlin.Char + public final fun toDouble(): kotlin.Double + public final fun toFloat(): kotlin.Float + public final fun toInt(): kotlin.Int + public final fun toLong(): kotlin.Long + public final fun toShort(): kotlin.Short public companion object Companion { /*primary*/ private constructor Companion() diff --git a/compiler/testData/builtin-classes/newMethods/kotlin.txt b/compiler/testData/builtin-classes/newMethods/kotlin.txt index 3a093e8a8dd..607d78f9a87 100644 --- a/compiler/testData/builtin-classes/newMethods/kotlin.txt +++ b/compiler/testData/builtin-classes/newMethods/kotlin.txt @@ -134,13 +134,13 @@ public final class Char : kotlin.Comparable, java.io.Serializable { public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange - public open fun toByte(): kotlin.Byte - public open fun toChar(): kotlin.Char - public open fun toDouble(): kotlin.Double - public open fun toFloat(): kotlin.Float - public open fun toInt(): kotlin.Int - public open fun toLong(): kotlin.Long - public open fun toShort(): kotlin.Short + public final fun toByte(): kotlin.Byte + public final fun toChar(): kotlin.Char + public final fun toDouble(): kotlin.Double + public final fun toFloat(): kotlin.Float + public final fun toInt(): kotlin.Int + public final fun toLong(): kotlin.Long + public final fun toShort(): kotlin.Short public companion object Companion { /*primary*/ private constructor Companion() diff --git a/core/builtins/native/kotlin/Boolean.kt b/core/builtins/native/kotlin/Boolean.kt index 0e6b2dd52ab..eea0ce4a3cd 100644 --- a/core/builtins/native/kotlin/Boolean.kt +++ b/core/builtins/native/kotlin/Boolean.kt @@ -20,7 +20,7 @@ package kotlin * Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are * represented as values of the primitive type `boolean`. */ -public class Boolean private () : Comparable { +public class Boolean private constructor() : Comparable { /** * Returns the inverse of this boolean. */ diff --git a/core/builtins/native/kotlin/Char.kt b/core/builtins/native/kotlin/Char.kt index b927a12ee68..ba601a6fb1b 100644 --- a/core/builtins/native/kotlin/Char.kt +++ b/core/builtins/native/kotlin/Char.kt @@ -20,8 +20,7 @@ package kotlin * Represents a 16-bit Unicode character. * On the JVM, non-nullable values of this type are represented as values of the primitive type `char`. */ -public class Char private () : Comparable { - +public class Char private constructor() : Comparable { /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, @@ -46,19 +45,19 @@ public class Char private () : Comparable { public operator fun rangeTo(other: Char): CharRange /** Returns the value of this character as a `Byte`. */ - public override fun toByte(): Byte + public fun toByte(): Byte /** Returns the value of this character as a `Char`. */ - public override fun toChar(): Char + public fun toChar(): Char /** Returns the value of this character as a `Short`. */ - public override fun toShort(): Short + public fun toShort(): Short /** Returns the value of this character as a `Int`. */ - public override fun toInt(): Int + public fun toInt(): Int /** Returns the value of this character as a `Long`. */ - public override fun toLong(): Long + public fun toLong(): Long /** Returns the value of this character as a `Float`. */ - public override fun toFloat(): Float + public fun toFloat(): Float /** Returns the value of this character as a `Double`. */ - public override fun toDouble(): Double + public fun toDouble(): Double companion object { /** diff --git a/core/builtins/native/kotlin/Nothing.kt b/core/builtins/native/kotlin/Nothing.kt index 0306fe46fba..b2efbb75194 100644 --- a/core/builtins/native/kotlin/Nothing.kt +++ b/core/builtins/native/kotlin/Nothing.kt @@ -20,4 +20,4 @@ package kotlin * Nothing has no instances. You can use Nothing to represent "a value that never exists": for example, * if a function has the return type of Nothing, it means that it never returns (always throws an exception). */ -public class Nothing private () {} +public class Nothing private constructor() diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index 7ca5aa5a540..1eea4ea60ec 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -22,7 +22,7 @@ package kotlin * Represents a 8-bit signed integer. * On the JVM, non-nullable values of this type are represented as values of the primitive type `byte`. */ -public class Byte private () : Number, Comparable { +public class Byte private constructor() : Number(), Comparable { companion object { /** * A constant holding the minimum value an instance of Byte can have. @@ -35,41 +35,46 @@ public class Byte private () : Number, Comparable { public const val MAX_VALUE: Byte = 127 } -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public override operator fun compareTo(other: Byte): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Short): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Int): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Long): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Float): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ @@ -168,7 +173,7 @@ public class Byte private () : Number, Comparable { * Represents a 16-bit signed integer. * On the JVM, non-nullable values of this type are represented as values of the primitive type `short`. */ -public class Short private () : Number, Comparable { +public class Short private constructor() : Number(), Comparable { companion object { /** * A constant holding the minimum value an instance of Short can have. @@ -181,41 +186,46 @@ public class Short private () : Number, Comparable { public const val MAX_VALUE: Short = 32767 } -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Byte): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public override operator fun compareTo(other: Short): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Int): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Long): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Float): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ @@ -314,7 +324,7 @@ public class Short private () : Number, Comparable { * Represents a 32-bit signed integer. * On the JVM, non-nullable values of this type are represented as values of the primitive type `int`. */ -public class Int private () : Number, Comparable { +public class Int private constructor() : Number(), Comparable { companion object { /** * A constant holding the minimum value an instance of Int can have. @@ -327,41 +337,46 @@ public class Int private () : Number, Comparable { public const val MAX_VALUE: Int = 2147483647 } -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Byte): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Short): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public override operator fun compareTo(other: Int): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Long): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Float): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ @@ -475,7 +490,7 @@ public class Int private () : Number, Comparable { * Represents a 64-bit signed integer. * On the JVM, non-nullable values of this type are represented as values of the primitive type `long`. */ -public class Long private () : Number, Comparable { +public class Long private constructor() : Number(), Comparable { companion object { /** * A constant holding the minimum value an instance of Long can have. @@ -488,41 +503,46 @@ public class Long private () : Number, Comparable { public const val MAX_VALUE: Long = 9223372036854775807L } -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Byte): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Short): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Int): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public override operator fun compareTo(other: Long): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Float): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ @@ -636,7 +656,7 @@ public class Long private () : Number, Comparable { * Represents a single-precision 32-bit IEEE 754 floating point number. * On the JVM, non-nullable values of this type are represented as values of the primitive type `float`. */ -public class Float private () : Number, Comparable { +public class Float private constructor() : Number(), Comparable { companion object { /** * A constant holding the smallest *positive* nonzero value of Float. @@ -664,41 +684,46 @@ public class Float private () : Number, Comparable { public val NaN: Float } -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Byte): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Short): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Int): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Long): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public override operator fun compareTo(other: Float): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ @@ -789,7 +814,7 @@ public class Float private () : Number, Comparable { * Represents a double-precision 64-bit IEEE 754 floating point number. * On the JVM, non-nullable values of this type are represented as values of the primitive type `double`. */ -public class Double private () : Number, Comparable { +public class Double private constructor() : Number(), Comparable { companion object { /** * A constant holding the smallest *positive* nonzero value of Double. @@ -817,41 +842,46 @@ public class Double private () : Number, Comparable { public val NaN: Double } -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Byte): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Short): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Int): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Long): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public operator fun compareTo(other: Float): Int -/** - * Compares this value with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ + + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */ public override operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt index 3f0a0184b2b..2b348e98fd9 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt @@ -65,7 +65,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { for (kind in PrimitiveType.onlyNumeric) { val className = kind.capitalized generateDoc(kind) - out.println("public class $className private () : Number, Comparable<$className> {") + out.println("public class $className private constructor() : Number(), Comparable<$className> {") out.print(" companion object ") if (kind == PrimitiveType.FLOAT || kind == PrimitiveType.DOUBLE) { @@ -95,8 +95,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { * A constant holding the "not a number" value of $className. */ public val NaN: $className - } -""") + }""") } if (kind == PrimitiveType.INT || kind == PrimitiveType.LONG || kind == PrimitiveType.SHORT || kind == PrimitiveType.BYTE) { val (minValue, maxValue) = primitiveConstants(kind) @@ -110,8 +109,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { * A constant holding the maximum value an instance of $className can have. */ public const val MAX_VALUE: $className = $maxValue - } -""") + }""") } generateCompareTo(kind) @@ -139,11 +137,12 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { private fun generateCompareTo(thisKind: PrimitiveType) { for (otherKind in PrimitiveType.onlyNumeric) { - out.println("/**") - out.println(" * Compares this value with the specified value for order.") - out.println(" * Returns zero if this value is equal to the specified other value, a negative number if its less than other, ") - out.println(" * or a positive number if its greater than other.") - out.println(" */") + out.println(""" + /** + * Compares this value with the specified value for order. + * Returns zero if this value is equal to the specified other value, a negative number if its less than other, + * or a positive number if its greater than other. + */""") out.print(" public ") if (otherKind == thisKind) out.print("override ") out.println("operator fun compareTo(other: ${otherKind.capitalized}): Int")