JS: Provide MIN_VALUE and MAX_VALUE member constants for Int, Long, Short and Byte companion objects.
JVM: Make MIN_VALUE and MAX_VALUE not an extension but member constant properties of Int, Long, Short and Byte companion objects.
This commit is contained in:
@@ -23,7 +23,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 () : Number, Comparable<Byte> {
|
||||
companion object {}
|
||||
companion object : IntegerConstants<Byte> {}
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
@@ -326,7 +326,7 @@ public class Char private () : Comparable<Char> {
|
||||
* On the JVM, non-nullable values of this type are represented as values of the primitive type `short`.
|
||||
*/
|
||||
public class Short private () : Number, Comparable<Short> {
|
||||
companion object {}
|
||||
companion object : IntegerConstants<Short> {}
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
@@ -484,7 +484,7 @@ public class Short private () : 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 () : Number, Comparable<Int> {
|
||||
companion object {}
|
||||
companion object : IntegerConstants<Int> {}
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
@@ -657,7 +657,7 @@ public class Int private () : 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 () : Number, Comparable<Long> {
|
||||
companion object {}
|
||||
companion object : IntegerConstants<Long> {}
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
* Holder for special values of floating point types.
|
||||
* An interface implemented by companion objects of floating-point types.
|
||||
*/
|
||||
public interface FloatingPointConstants<T> {
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
* An interface implemented by companion objects of integral types.
|
||||
*/
|
||||
public interface IntegerConstants<T> {
|
||||
/**
|
||||
* A constant holding the minimum value an instance of [T] can have.
|
||||
*/
|
||||
public val MIN_VALUE: T
|
||||
|
||||
/**
|
||||
* A constant holding the maximum value an instance of [T] can have.
|
||||
*/
|
||||
public val MAX_VALUE: T
|
||||
}
|
||||
Reference in New Issue
Block a user