From 1c3383c811bbaff2c9810d9252833023281ac75b Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 3 Dec 2013 21:44:13 +0400 Subject: [PATCH] Unextend Char from Number This is impossible to achieve on JVM, where java/lang/Character does not extend java/lang/Number --- .../frontend/builtins/jet/.kotlin_class_names | Bin 768 -> 768 bytes .../frontend/builtins/jet/.kotlin_name_table | Bin 6156 -> 6156 bytes .../frontend/builtins/jet/.kotlin_package | Bin 291 -> 291 bytes .../frontend/builtins/jet/Char.kotlin_class | Bin 1145 -> 1145 bytes .../builtins/jet/CharArray.kotlin_class | Bin 135 -> 135 bytes .../builtins/jet/CharIterator.kotlin_class | 6 +++--- .../builtins/jet/CharProgression.kotlin_class | Bin 120 -> 120 bytes .../builtins/jet/CharRange.kotlin_class | Bin 148 -> 148 bytes .../jet/CharRange.object.kotlin_class | Bin 26 -> 26 bytes .../builtins/jet/CharSequence.kotlin_class | Bin 59 -> 59 bytes .../builtins/jet/Collection.kotlin_class | Bin 148 -> 148 bytes .../frontend/builtins/jet/Enum.kotlin_class | Bin 127 -> 127 bytes .../builtins/jet/Hashable.kotlin_class | Bin 48 -> 48 bytes .../jet/InlineStrategy.object.kotlin_class | Bin 55 -> 55 bytes .../builtins/jet/Iterable.kotlin_class | Bin 48 -> 48 bytes .../frontend/builtins/jet/List.kotlin_class | Bin 333 -> 333 bytes .../builtins/jet/Map.Entry.kotlin_class | Bin 75 -> 75 bytes .../frontend/builtins/jet/Map.kotlin_class | Bin 246 -> 246 bytes .../jet/MutableCollection.kotlin_class | Bin 248 -> 248 bytes .../builtins/jet/MutableIterable.kotlin_class | Bin 60 -> 60 bytes .../builtins/jet/MutableList.kotlin_class | Bin 491 -> 491 bytes .../jet/MutableMap.MutableEntry.kotlin_class | Bin 97 -> 97 bytes .../builtins/jet/MutableSet.kotlin_class | Bin 249 -> 249 bytes .../frontend/builtins/jet/Number.kotlin_class | 2 +- .../builtins/jet/Progression.kotlin_class | Bin 76 -> 76 bytes .../jet/PropertyMetadata.kotlin_class | 2 +- .../jet/PropertyMetadataImpl.kotlin_class | Bin 53 -> 53 bytes .../frontend/builtins/jet/Set.kotlin_class | Bin 143 -> 143 bytes .../frontend/builtins/jet/String.kotlin_class | Bin 165 -> 165 bytes .../builtins/jet/Throwable.kotlin_class | 4 ++-- .../builtins/jet/deprecated.kotlin_class | Bin 40 -> 40 bytes .../builtins/jet/suppress.kotlin_class | Bin 55 -> 55 bytes compiler/testData/builtin-classes.txt | 16 ++++++++-------- .../tests/numbers/characterIsNotANumber.kt | 11 +++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 5 +++++ idea/builtinsSrc/jet/Numbers.kt | 16 ++++++++-------- 36 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/numbers/characterIsNotANumber.kt diff --git a/compiler/frontend/builtins/jet/.kotlin_class_names b/compiler/frontend/builtins/jet/.kotlin_class_names index 9730774eea0dfd4e95ecbd8135ef68575d1e53ec..14c2f9fcff6baa247ce15d8ec8e84773aadddf6c 100644 GIT binary patch delta 72 zcmZo*YhasTF6zy|z~BSKen4yh!~sAYGSTO?tQU}R7>L<{_yQ1L1mep;%nQU}n?o4e M85x5o-(gY#0I`q^>i_@% delta 72 zcmZo*YhasTF6za=z~BwUzCdgM#Qs1WJkjU1Y#5Mn7>L<{_yQ1L1mep;%nQV!n?o4e M85x5n-(gY#0J2I9@Bjb+ diff --git a/compiler/frontend/builtins/jet/.kotlin_name_table b/compiler/frontend/builtins/jet/.kotlin_name_table index 459e676336021bc2ce3fa9f619b1b6b2307739c0..66fd80f211487e535d801a8426759d26f89e3fe4 100644 GIT binary patch delta 73 zcmeA%=rP#Pz{JVnkyxCOn3R(`xt?jtW?ANUe40KI3|wp+3<7>&T2#Ov$`63j!B9G6 Jvx(3RRsfNT4u1du delta 69 zcmeA%=rP#Pz%;pwX)-H^M`CftW(nrce44%z3|wp+q5^(knnA!HN(VvdU??5B*+l3D FD*!544D|p2 diff --git a/compiler/frontend/builtins/jet/.kotlin_package b/compiler/frontend/builtins/jet/.kotlin_package index 104f218ca5491198aaab2d6e8ee9156a1ed700ed..60c8fca1d6791c8803c04d8ee1ab39af5892d216 100644 GIT binary patch delta 28 kcmZ3?w3unaR#r6$Mg!f6j>3#;6VLgv2RX5DF$t&v0CCa=%K!iX delta 28 kcmZ3?w3unaR#sIBMg!f6j>3$p6VLgv2RgBEF$t&w0CA}X#{d8T diff --git a/compiler/frontend/builtins/jet/Char.kotlin_class b/compiler/frontend/builtins/jet/Char.kotlin_class index ab6607d04d3c2face19445fde51de523cbe824e2..83234cc77b87dd8890a54ecc01ec5e35bde1c369 100644 GIT binary patch delta 116 zcmey#@sop#gH3|ph=q$uKw%>nKT86efteGC#}fsVF)#X7hvD7GSmjm~9DW3xe5J eU^WYwZ4G7%f!Q`-ws00N7dOWtMgwLrmmdJOwhrC^ diff --git a/compiler/frontend/builtins/jet/CharArray.kotlin_class b/compiler/frontend/builtins/jet/CharArray.kotlin_class index af0fe5cc8f088817fe5f35bb2cf52c2372cc7ccd..b17641f096354740467e93d8a640326f9b177484 100644 GIT binary patch delta 19 acmZo?Y-eQQV3Sas$YRE*G|}3dQ4s(m%mae} delta 19 acmZo?Y-eQQV3Sao$YRE*IMLdhQ2_uWx&wd! diff --git a/compiler/frontend/builtins/jet/CharIterator.kotlin_class b/compiler/frontend/builtins/jet/CharIterator.kotlin_class index 1d27898c159..189e544112b 100644 --- a/compiler/frontend/builtins/jet/CharIterator.kotlin_class +++ b/compiler/frontend/builtins/jet/CharIterator.kotlin_class @@ -1,9 +1,9 @@ -&!2 +&"2  Z 0B Z -&0LB +&0MB j Æ0B -! \ No newline at end of file +" \ No newline at end of file diff --git a/compiler/frontend/builtins/jet/CharProgression.kotlin_class b/compiler/frontend/builtins/jet/CharProgression.kotlin_class index c129da341af875469548a6941b57a22910f7340f..8a99bf17b74217c49b8a121c35bb3ab26651b9bc 100644 GIT binary patch delta 17 Ycmb=ZVBuhsP@c$Q%&0Wc!k$qX03Y-NRR910 delta 17 Ycmb=ZVBuhsP@2eM%&0ig!k$qH03YH5QUCw| diff --git a/compiler/frontend/builtins/jet/CharRange.kotlin_class b/compiler/frontend/builtins/jet/CharRange.kotlin_class index 9d1acb5f95297e9c2f94f42b2682889fc27d49ca..74846b51fe384513790f7d6c2df79185d2930b99 100644 GIT binary patch delta 11 ScmbQjIE8USJfqUY1QP%i3j<;R delta 11 ScmbQjIE8USJfq^o1QP%i2LoXM diff --git a/compiler/frontend/builtins/jet/CharRange.object.kotlin_class b/compiler/frontend/builtins/jet/CharRange.object.kotlin_class index f604a57fb175181f4c2b240139a2a183e2d2ff1e..3af4f2066c172af8a06bbd768b77594a9fec31e0 100644 GIT binary patch literal 26 fcmd;RW0p`cV&P&EV2a}AIL2Y%=>+14W-$N&G9m-F literal 26 fcmd;RW0p`hV&P&EV2a}AIL2Y%=>+14W-$N&G7JN@ diff --git a/compiler/frontend/builtins/jet/CharSequence.kotlin_class b/compiler/frontend/builtins/jet/CharSequence.kotlin_class index d8444cecb74b1d90d497fedb97c0847441fdf74c..0d60ce7de3130f0a26839c3369cc4c0634fa9b66 100644 GIT binary patch delta 30 icmcDvX5mPaP@Tx4A{^+%!o?)O62--#W)K8ss{sH>)dWQV delta 30 icmcDvX5mPaP?^Z0A{^kv!o?)O62--#W)KKws{#N?q69$z diff --git a/compiler/frontend/builtins/jet/Collection.kotlin_class b/compiler/frontend/builtins/jet/Collection.kotlin_class index 335a85012cd83f98e05b50a32020faf97e42756e..f30a6efb2d99afca52a410a29b631ea663f68d07 100644 GIT binary patch delta 55 zcmbQjIE7J*BTYhGi;sgrAXI@-i;as(fJuVUh!03>2yqCpaj|eP3NRS40Qm|NwX_-4 ICx+Pp0K3=*u>b%7 delta 55 zcmbQjIE7J*BTYh0i;sgrAVh&ti;as(fJuVUh!04s3vmdsaj|eP3NRS40QnjdwX_-4 ICWhGo0K2OOwEzGB diff --git a/compiler/frontend/builtins/jet/Enum.kotlin_class b/compiler/frontend/builtins/jet/Enum.kotlin_class index bbc9231d9e560aeda1cc46257cb689c7d84aa810..e9318ca1e5dc070c6bcd140960f446d26a2e0732 100644 GIT binary patch delta 81 zcmb=g=i*S4(A5&*U=RqM$fd}rHc>~yI#i2~i%CFNh(m~ti-m(xfWd&-iVLVBQHlj9 Ot_Ef&f!QohXet4-)Ch+F delta 81 zcmb=g=i*S4(A5&*U=RqI$fd}rI#EZ$Iz)?)i%CFNh(m~ti-m(xfWd&-iVLVBQHlj9 Ot_o%+f!QohXet4+_XvXk diff --git a/compiler/frontend/builtins/jet/Hashable.kotlin_class b/compiler/frontend/builtins/jet/Hashable.kotlin_class index 566c778ab17c324242a7151bb74a5e43d6849a3a..0c6f281d938c4b30e22818956c5b3a71f9a17818 100644 GIT binary patch delta 10 RcmXpoVBtuUP?*S~0{{s%0n7jZ delta 10 RcmXpoVBtuU(3r@g0{{tC0n`8h diff --git a/compiler/frontend/builtins/jet/InlineStrategy.object.kotlin_class b/compiler/frontend/builtins/jet/InlineStrategy.object.kotlin_class index d7c9186738d581ab0f8763ac54496af46da2ce43..097db3005a5ba902fea583d689eaffb1a6b367c0 100644 GIT binary patch delta 9 QcmXpvpCG}gHc?Uz01D6o1^@s6 delta 9 QcmXpvpCG}gI#E&%01C_k1poj5 diff --git a/compiler/frontend/builtins/jet/Iterable.kotlin_class b/compiler/frontend/builtins/jet/Iterable.kotlin_class index 909005b4d096fbfadd7c06b14fefb040a104407c..61de568c57e1af6c1aee6649b1671002034b9f8f 100644 GIT binary patch delta 10 RcmXpoVBtuU(3r@g0{{tC0n`8h delta 10 RcmXpoVBtuUP@l-60{{t80n-2g diff --git a/compiler/frontend/builtins/jet/List.kotlin_class b/compiler/frontend/builtins/jet/List.kotlin_class index 936836506967240bbb1c5632d3bed29135005f08..49147d94ee7028edd0a8ec89533062760100c2ac 100644 GIT binary patch delta 40 ucmX@hbe2h)BTZr*qZS_rgFvVPqZS(%lK_(hqY)pFR-Y(s%BVgu@DBi&PzQzp delta 40 ucmX@hbe2h)BTZr*qZS_rgFuJ^qZS(%lK_(hqY)pFR+}ho%BVIm@DBi&DhGoA diff --git a/compiler/frontend/builtins/jet/Map.Entry.kotlin_class b/compiler/frontend/builtins/jet/Map.Entry.kotlin_class index 3ba5303352dd630f03d7449baecdc03ed82ed88f..60bc72a6dffaebacdc8e9afd704197620a9df72e 100644 GIT binary patch delta 9 QcmebFo}k01Fi}?y01T`GPyhe` delta 9 QcmebFo}k01F;Q0z01V6mSO5S3 diff --git a/compiler/frontend/builtins/jet/Map.kotlin_class b/compiler/frontend/builtins/jet/Map.kotlin_class index f25b08f12c0723e4cd9bc973c6726d87d5ce801e..af22c5a85c1f20367e46c68723b1168371489058 100644 GIT binary patch delta 18 Zcmeyy_>FPGYi@NR4k0!!77j)MMgTb|1NHy_ delta 18 Zcmeyy_>FPGYi>0m4k0!!77j)MMgTb-1N8s^ diff --git a/compiler/frontend/builtins/jet/MutableCollection.kotlin_class b/compiler/frontend/builtins/jet/MutableCollection.kotlin_class index 78a81b6605ccbd43e93714482d1b2c80156ac7f5..19eb72bf4717958113ce2f9756e13746a5ddb52e 100644 GIT binary patch delta 61 zcmeyt_=8cBBTZsEqZSVbgFvVj8yAxRlLVs?ACOj`DCx+;FBTZs2qZSVbgFxs+?g&Qpi7AOd;+T@4x)6sD8yAxRlLVs^3y|gn01|5n A1^@s6 delta 47 zcmey#_>+;FBTZs2qZSVbgFwhc?g&P;i7AOd;+T@4nh=K&8yAxRlLVs^3y|gn01^oa A0ssI2 diff --git a/compiler/frontend/builtins/jet/Number.kotlin_class b/compiler/frontend/builtins/jet/Number.kotlin_class index fa727325b22..c9533d9b1f4 100644 --- a/compiler/frontend/builtins/jet/Number.kotlin_class +++ b/compiler/frontend/builtins/jet/Number.kotlin_class @@ -1,5 +1,5 @@ & 2 -(Z + Z &06B  Z &07B diff --git a/compiler/frontend/builtins/jet/Progression.kotlin_class b/compiler/frontend/builtins/jet/Progression.kotlin_class index 54362ffcb0f3bf698c1840a2f72d4a71549c5b70..25f08d9a9903665d728ed8e3e3d605b1308a1edf 100644 GIT binary patch delta 9 QcmebAnIOifF;UzU01QL|MF0Q* delta 9 QcmebAnIOifK2h8h01Q9^L;wH) diff --git a/compiler/frontend/builtins/jet/PropertyMetadata.kotlin_class b/compiler/frontend/builtins/jet/PropertyMetadata.kotlin_class index a2b7e7cde6e..925803982bf 100644 --- a/compiler/frontend/builtins/jet/PropertyMetadata.kotlin_class +++ b/compiler/frontend/builtins/jet/PropertyMetadata.kotlin_class @@ -1,3 +1,3 @@ fÀ2 Z æ0aB -% \ No newline at end of file +& \ No newline at end of file diff --git a/compiler/frontend/builtins/jet/PropertyMetadataImpl.kotlin_class b/compiler/frontend/builtins/jet/PropertyMetadataImpl.kotlin_class index 629e734e597a7848629f357b3dabb51cddfc6be2..27c13e5d412f737ddc395f0132fff95385972c7f 100644 GIT binary patch delta 34 pcmXptogg8rmL}QnbNR!ygsKv*@AP}m+sKv&`B)}xWXv7Dk)h9}uGOAAuv;zQyLIzO) delta 40 ucmeBY>}QnbNR!ygsKv*@AP}O!sKv&`B)}xWXv7Dk)h0@tGOA4sv;zQy90pDR diff --git a/compiler/frontend/builtins/jet/String.kotlin_class b/compiler/frontend/builtins/jet/String.kotlin_class index 985871b7bbb486785acf78e561d456c1c9b11301..cba6174396b671d6932e4b03526f93fad23f1453 100644 GIT binary patch delta 85 zcmZ3=xRgcq;$EO3eu01(6iT>t<8 diff --git a/compiler/frontend/builtins/jet/suppress.kotlin_class b/compiler/frontend/builtins/jet/suppress.kotlin_class index 884452e88f52b3e2f84d7474383a4c030d689aa4..c88d805418af083ed6774f06b3d221660b5c5826 100644 GIT binary patch delta 19 acmXpvpPH&@B%tcV%Ec^jmJt9S7XtJE diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 9e5e8e9ef1a..3379b00b049 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -166,7 +166,7 @@ public final class ByteRange : jet.Range, jet.Progression { } } -public final class Char : jet.Number, jet.Comparable { +public final class Char : jet.Hashable, jet.Comparable { /*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 @@ -213,13 +213,13 @@ public final class Char : jet.Number, jet.Comparable { public final fun times(/*0*/ other: jet.Int): jet.Int public final fun times(/*0*/ other: jet.Long): jet.Long public final fun times(/*0*/ other: jet.Short): jet.Int - public open override /*1*/ fun toByte(): jet.Byte - public open override /*1*/ fun toChar(): jet.Char - public open override /*1*/ fun toDouble(): jet.Double - public open override /*1*/ fun toFloat(): jet.Float - public open override /*1*/ fun toInt(): jet.Int - public open override /*1*/ fun toLong(): jet.Long - public open override /*1*/ fun toShort(): jet.Short + public open fun toByte(): jet.Byte + public open fun toChar(): jet.Char + public open fun toDouble(): jet.Double + public open fun toFloat(): jet.Float + public open fun toInt(): jet.Int + public open fun toLong(): jet.Long + public open fun toShort(): jet.Short } public final class CharArray { diff --git a/compiler/testData/diagnostics/tests/numbers/characterIsNotANumber.kt b/compiler/testData/diagnostics/tests/numbers/characterIsNotANumber.kt new file mode 100644 index 00000000000..ec7e0155f29 --- /dev/null +++ b/compiler/testData/diagnostics/tests/numbers/characterIsNotANumber.kt @@ -0,0 +1,11 @@ +fun foo(n: Number) = n + +fun test() { + foo('a') + + val c = 'c' + foo(c) + + val d: Char? = 'd' + foo(d!!) +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index ada48004162..e6374cb3d94 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -4620,6 +4620,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/numbers"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("characterIsNotANumber.kt") + public void testCharacterIsNotANumber() throws Exception { + doTest("compiler/testData/diagnostics/tests/numbers/characterIsNotANumber.kt"); + } + @TestMetadata("doublesInSimpleConstraints.kt") public void testDoublesInSimpleConstraints() throws Exception { doTest("compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt"); diff --git a/idea/builtinsSrc/jet/Numbers.kt b/idea/builtinsSrc/jet/Numbers.kt index 52ddf64bc8d..64fb68c7bc2 100644 --- a/idea/builtinsSrc/jet/Numbers.kt +++ b/idea/builtinsSrc/jet/Numbers.kt @@ -328,7 +328,7 @@ public class Int private () : Number, Comparable { public override fun equals(other : Any?) : Boolean } -public class Char private () : Number, Comparable { +public class Char private () : Hashable, Comparable { public fun compareTo(other : Double) : Int public fun compareTo(other : Float) : Int public fun compareTo(other : Long) : Int @@ -384,13 +384,13 @@ public class Char private () : Number, Comparable { public fun plus() : Int public fun minus() : Int - public override fun toDouble() : Double - public override fun toFloat() : Float - public override fun toLong() : Long - public override fun toInt() : Int - public override fun toChar() : Char - public override fun toShort() : Short - public override fun toByte() : Byte + public fun toDouble() : Double + public fun toFloat() : Float + public fun toLong() : Long + public fun toInt() : Int + public fun toChar() : Char + public fun toShort() : Short + public fun toByte() : Byte public override fun hashCode() : Int public override fun equals(other : Any?) : Boolean