From c0fce6becd598f65a1ab774df34883faee5a38d1 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Sat, 16 Nov 2013 19:48:39 +0400 Subject: [PATCH] KT-4209 Make constructors of primitives private #KT-4209 Fixed --- .../builtins/jet/Boolean.kotlin_class | Bin 133 -> 133 bytes .../frontend/builtins/jet/Byte.kotlin_class | Bin 1383 -> 1383 bytes .../frontend/builtins/jet/Char.kotlin_class | Bin 1143 -> 1143 bytes .../frontend/builtins/jet/Double.kotlin_class | Bin 1359 -> 1359 bytes .../frontend/builtins/jet/Float.kotlin_class | Bin 1383 -> 1383 bytes .../frontend/builtins/jet/Int.kotlin_class | Bin 1546 -> 1546 bytes .../frontend/builtins/jet/Long.kotlin_class | Bin 1546 -> 1546 bytes .../frontend/builtins/jet/Short.kotlin_class | Bin 1383 -> 1383 bytes compiler/testData/builtin-classes.txt | 14 +++++++------- .../tests/ConstructorsOfPrimitives.kt | 10 ++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 5 +++++ idea/builtinsSrc/jet/Library.kt | 2 +- idea/builtinsSrc/jet/Numbers.kt | 14 +++++++------- 13 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.kt diff --git a/compiler/frontend/builtins/jet/Boolean.kotlin_class b/compiler/frontend/builtins/jet/Boolean.kotlin_class index 8b472b4bbd583e8cbc51ac216a28380a7a411ee1..48876f24ce9187aa66d800779c6b84330bfb25b9 100644 GIT binary patch delta 22 dcmZo=Y-Qx*V3Xi9V&P&EU<%^qI5d&38~`P(1KR)q delta 22 dcmZo=Y-Qx*V3Xi9V&P&EU<%^qI5v^58~`P}1K$7u diff --git a/compiler/frontend/builtins/jet/Byte.kotlin_class b/compiler/frontend/builtins/jet/Byte.kotlin_class index b9b56a89c2bbb60f4a951108de1e501118ec0065..96e16f171d7c3f0ceebf463b879185c53e1ece2c 100644 GIT binary patch delta 12 TcmaFP^_**hG~=O-GTy8JA#Mb2 delta 12 TcmaFP^_**hG~=<2GTy8JA%X;Q diff --git a/compiler/frontend/builtins/jet/Char.kotlin_class b/compiler/frontend/builtins/jet/Char.kotlin_class index d77e9cc4aa7935bad77fcae0c134d8d722187004..a3ff15dabad539eb995599650f10e48c6e4a7fd7 100644 GIT binary patch delta 12 Tcmey)@ttFWG~=O-GSMsmBEEf9n&3I^|%sW;98r}q3 delta 12 TcmeC;>Ef9n&3J61%sW;98uA2R diff --git a/compiler/frontend/builtins/jet/Long.kotlin_class b/compiler/frontend/builtins/jet/Long.kotlin_class index 9c512a4f466dad9eb630e9fdcb0a90cea3af5ea2..03202abda2ec2d00fd84100fc34449b26fa2d61c 100644 GIT binary patch delta 12 TcmeC;>Ef9n&3I^|%sW;98r}q3 delta 12 TcmeC;>Ef9n&3J61%sW;98uA2R diff --git a/compiler/frontend/builtins/jet/Short.kotlin_class b/compiler/frontend/builtins/jet/Short.kotlin_class index c89f298c2db37d6d475c0b489bf60d0e1ca8847a..d6f9b5f14a219ee0f68a2799180f50019ae3b5b0 100644 GIT binary patch delta 12 TcmaFP^_**hG~=O-GTy8JA#Mb2 delta 12 TcmaFP^_**hG~=<2GTy8JA%X;Q diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 35ab534a698..174badbe091 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -54,7 +54,7 @@ public abstract class BooleanIterator : jet.Iterator { } public final class Byte : jet.Number, jet.Comparable { - /*primary*/ public constructor Byte() + /*primary*/ private constructor Byte() public open override /*1*/ fun compareTo(/*0*/ other: jet.Byte): jet.Int public final fun compareTo(/*0*/ other: jet.Char): jet.Int public final fun compareTo(/*0*/ other: jet.Double): jet.Int @@ -167,7 +167,7 @@ public final class ByteRange : jet.Range, jet.Progression { } public final class Char : jet.Number, jet.Comparable { - /*primary*/ public constructor Char() + /*primary*/ private constructor Char() public final fun compareTo(/*0*/ other: jet.Byte): jet.Int public open override /*1*/ fun compareTo(/*0*/ other: jet.Char): jet.Int public final fun compareTo(/*0*/ other: jet.Double): jet.Int @@ -291,7 +291,7 @@ public trait Comparable { } public final class Double : jet.Number, jet.Comparable { - /*primary*/ public constructor Double() + /*primary*/ private constructor Double() public final fun compareTo(/*0*/ other: jet.Byte): jet.Int public final fun compareTo(/*0*/ other: jet.Char): jet.Int public open override /*1*/ fun compareTo(/*0*/ other: jet.Double): jet.Int @@ -501,7 +501,7 @@ public trait ExtensionFunction9 { - /*primary*/ public constructor Float() + /*primary*/ private constructor Float() public final fun compareTo(/*0*/ other: jet.Byte): jet.Int public final fun compareTo(/*0*/ other: jet.Char): jet.Int public final fun compareTo(/*0*/ other: jet.Double): jet.Int @@ -711,7 +711,7 @@ public trait Hashable { } public final class Int : jet.Number, jet.Comparable { - /*primary*/ public constructor Int() + /*primary*/ private constructor Int() public final fun and(/*0*/ other: jet.Int): jet.Int public final fun compareTo(/*0*/ other: jet.Byte): jet.Int public final fun compareTo(/*0*/ other: jet.Char): jet.Int @@ -1141,7 +1141,7 @@ public trait ListIterator : jet.Iterator { } public final class Long : jet.Number, jet.Comparable { - /*primary*/ public constructor Long() + /*primary*/ private constructor Long() public final fun and(/*0*/ other: jet.Long): jet.Long public final fun compareTo(/*0*/ other: jet.Byte): jet.Int public final fun compareTo(/*0*/ other: jet.Char): jet.Int @@ -1438,7 +1438,7 @@ public trait Set : jet.Collection { } public final class Short : jet.Number, jet.Comparable { - /*primary*/ public constructor Short() + /*primary*/ private constructor Short() public final fun compareTo(/*0*/ other: jet.Byte): jet.Int public final fun compareTo(/*0*/ other: jet.Char): jet.Int public final fun compareTo(/*0*/ other: jet.Double): jet.Int diff --git a/compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.kt b/compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.kt new file mode 100644 index 00000000000..adfb57f794b --- /dev/null +++ b/compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.kt @@ -0,0 +1,10 @@ +fun test() { + Double() + Float() + Long() + Int() + Short() + Byte() + Char() + Boolean() +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index cc4183dce25..b222706d282 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -134,6 +134,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/Constructors.kt"); } + @TestMetadata("ConstructorsOfPrimitives.kt") + public void testConstructorsOfPrimitives() throws Exception { + doTest("compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.kt"); + } + @TestMetadata("CovariantOverrideType.kt") public void testCovariantOverrideType() throws Exception { doTest("compiler/testData/diagnostics/tests/CovariantOverrideType.kt"); diff --git a/idea/builtinsSrc/jet/Library.kt b/idea/builtinsSrc/jet/Library.kt index fe19c3f8db0..2050b98dba6 100644 --- a/idea/builtinsSrc/jet/Library.kt +++ b/idea/builtinsSrc/jet/Library.kt @@ -29,7 +29,7 @@ public trait Hashable { public fun equals(other : Any?) : Boolean } -public class Boolean { +public class Boolean private () { public fun not() : Boolean public fun and(other : Boolean) : Boolean diff --git a/idea/builtinsSrc/jet/Numbers.kt b/idea/builtinsSrc/jet/Numbers.kt index 728d49f64d9..52ddf64bc8d 100644 --- a/idea/builtinsSrc/jet/Numbers.kt +++ b/idea/builtinsSrc/jet/Numbers.kt @@ -17,7 +17,7 @@ public abstract class Number : Hashable { // fun equals(other : Char) : Boolean } -public class Double : Number, Comparable { +public class Double private () : Number, Comparable { public override fun compareTo(other : Double) : Int public fun compareTo(other : Float) : Int public fun compareTo(other : Long) : Int @@ -90,7 +90,7 @@ public class Double : Number, Comparable { public override fun equals(other : Any?) : Boolean } -public class Float : Number, Comparable { +public class Float private () : Number, Comparable { public fun compareTo(other : Double) : Int public override fun compareTo(other : Float) : Int public fun compareTo(other : Long) : Int @@ -164,7 +164,7 @@ public class Float : Number, Comparable { public override fun equals(other : Any?) : Boolean } -public class Long : Number, Comparable { +public class Long private () : Number, Comparable { public fun compareTo(other : Double) : Int public fun compareTo(other : Float) : Int public override fun compareTo(other : Long) : Int @@ -246,7 +246,7 @@ public class Long : Number, Comparable { public override fun equals(other : Any?) : Boolean } -public class Int : Number, Comparable { +public class Int private () : Number, Comparable { public fun compareTo(other : Double) : Int public fun compareTo(other : Float) : Int public fun compareTo(other : Long) : Int @@ -328,7 +328,7 @@ public class Int : Number, Comparable { public override fun equals(other : Any?) : Boolean } -public class Char : Number, Comparable { +public class Char private () : Number, Comparable { public fun compareTo(other : Double) : Int public fun compareTo(other : Float) : Int public fun compareTo(other : Long) : Int @@ -396,7 +396,7 @@ public class Char : Number, Comparable { public override fun equals(other : Any?) : Boolean } -public class Short : Number, Comparable { +public class Short private () : Number, Comparable { public fun compareTo(other : Double) : Int public fun compareTo(other : Float) : Int public fun compareTo(other : Long) : Int @@ -470,7 +470,7 @@ public class Short : Number, Comparable { public override fun equals(other : Any?) : Boolean } -public class Byte : Number, Comparable { +public class Byte private () : Number, Comparable { public fun compareTo(other : Double) : Int public fun compareTo(other : Float) : Int public fun compareTo(other : Long) : Int