Primitive Companion objects do not longer implement IntegerConstants and FloatingPointConstants. All declarations moved inside companions.

IntegerConstants and FloatingPointConstants are dropped.
#KT-8897 Fixed
This commit is contained in:
Ilya Gorbunov
2015-12-24 06:17:03 +03:00
parent fc4250b02b
commit de11ed4fc6
14 changed files with 355 additions and 228 deletions
+96 -6
View File
@@ -23,7 +23,17 @@ 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 : IntegerConstants<Byte> {}
companion object {
/**
* A constant holding the minimum value an instance of Byte can have.
*/
public const val MIN_VALUE: Byte = -128
/**
* A constant holding the maximum value an instance of Byte can have.
*/
public const val MAX_VALUE: Byte = 127
}
/**
* Compares this value with the specified value for order.
@@ -159,7 +169,17 @@ public class Byte private () : 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 () : Number, Comparable<Short> {
companion object : IntegerConstants<Short> {}
companion object {
/**
* A constant holding the minimum value an instance of Short can have.
*/
public const val MIN_VALUE: Short = -32768
/**
* A constant holding the maximum value an instance of Short can have.
*/
public const val MAX_VALUE: Short = 32767
}
/**
* Compares this value with the specified value for order.
@@ -295,7 +315,17 @@ 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 : IntegerConstants<Int> {}
companion object {
/**
* A constant holding the minimum value an instance of Int can have.
*/
public const val MIN_VALUE: Int = -2147483648
/**
* A constant holding the maximum value an instance of Int can have.
*/
public const val MAX_VALUE: Int = 2147483647
}
/**
* Compares this value with the specified value for order.
@@ -446,7 +476,17 @@ 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 : IntegerConstants<Long> {}
companion object {
/**
* A constant holding the minimum value an instance of Long can have.
*/
public const val MIN_VALUE: Long = -9223372036854775807L - 1L
/**
* A constant holding the maximum value an instance of Long can have.
*/
public const val MAX_VALUE: Long = 9223372036854775807L
}
/**
* Compares this value with the specified value for order.
@@ -597,7 +637,32 @@ public class Long private () : 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 () : Number, Comparable<Float> {
companion object : FloatingPointConstants<Float> {}
companion object {
/**
* A constant holding the smallest *positive* nonzero value of Float.
*/
public val MIN_VALUE: Float
/**
* A constant holding the largest positive finite value of Float.
*/
public val MAX_VALUE: Float
/**
* A constant holding the positive infinity value of Float.
*/
public val POSITIVE_INFINITY: Float
/**
* A constant holding the negative infinity value of Float.
*/
public val NEGATIVE_INFINITY: Float
/**
* A constant holding the "not a number" value of Float.
*/
public val NaN: Float
}
/**
* Compares this value with the specified value for order.
@@ -725,7 +790,32 @@ public class Float private () : 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 () : Number, Comparable<Double> {
companion object : FloatingPointConstants<Double> {}
companion object {
/**
* A constant holding the smallest *positive* nonzero value of Double.
*/
public val MIN_VALUE: Double
/**
* A constant holding the largest positive finite value of Double.
*/
public val MAX_VALUE: Double
/**
* A constant holding the positive infinity value of Double.
*/
public val POSITIVE_INFINITY: Double
/**
* A constant holding the negative infinity value of Double.
*/
public val NEGATIVE_INFINITY: Double
/**
* A constant holding the "not a number" value of Double.
*/
public val NaN: Double
}
/**
* Compares this value with the specified value for order.
@@ -1,47 +0,0 @@
/*
* 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 floating-point types.
*/
public interface FloatingPointConstants<T> {
/**
* A constant holding the smallest *positive* nonzero value.
*/
public val MIN_VALUE: T
/**
* A constant holding the largest positive finite value.
*/
public val MAX_VALUE: T
/**
* A constant holding the positive infinity value.
*/
public val POSITIVE_INFINITY: T
/**
* A constant holding the negative infinity value.
*/
public val NEGATIVE_INFINITY: T
/**
* A constant holding the "not a number" value.
*/
public val NaN: T
}
@@ -1,32 +0,0 @@
/*
* 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
}