From 513be4754489757aeb009fe0a7ba4f7c3eb381e8 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Wed, 25 Dec 2013 21:07:55 +0400 Subject: [PATCH] KT-4349 Make jet.Boolean implement Comparable #KT-4349 --- .../frontend/builtins/jet/.kotlin_class_names | Bin 772 -> 772 bytes .../frontend/builtins/jet/.kotlin_name_table | Bin 6180 -> 6180 bytes .../frontend/builtins/jet/.kotlin_package | Bin 291 -> 291 bytes .../builtins/jet/Boolean.kotlin_class | Bin 135 -> 167 bytes .../builtins/jet/BooleanArray.kotlin_class | Bin 135 -> 135 bytes .../builtins/jet/BooleanIterator.kotlin_class | 8 ++++---- .../frontend/builtins/jet/Byte.kotlin_class | Bin 1385 -> 1385 bytes .../builtins/jet/ByteArray.kotlin_class | Bin 135 -> 135 bytes .../builtins/jet/ByteIterator.kotlin_class | 8 ++++---- .../builtins/jet/ByteProgression.kotlin_class | Bin 120 -> 120 bytes .../builtins/jet/ByteRange.kotlin_class | Bin 148 -> 148 bytes .../frontend/builtins/jet/Char.kotlin_class | Bin 1145 -> 1145 bytes .../builtins/jet/CharIterator.kotlin_class | 2 +- .../builtins/jet/Comparable.kotlin_class | Bin 52 -> 52 bytes .../frontend/builtins/jet/Double.kotlin_class | Bin 1361 -> 1361 bytes .../builtins/jet/DoubleIterator.kotlin_class | 2 +- .../frontend/builtins/jet/Float.kotlin_class | Bin 1385 -> 1385 bytes .../builtins/jet/FloatIterator.kotlin_class | 2 +- .../builtins/jet/Hashable.kotlin_class | Bin 48 -> 48 bytes .../frontend/builtins/jet/Int.kotlin_class | Bin 1548 -> 1548 bytes .../builtins/jet/IntIterator.kotlin_class | 2 +- .../builtins/jet/Iterator.kotlin_class | Bin 53 -> 53 bytes .../builtins/jet/ListIterator.kotlin_class | Bin 118 -> 118 bytes .../frontend/builtins/jet/Long.kotlin_class | Bin 1548 -> 1548 bytes .../builtins/jet/LongIterator.kotlin_class | 2 +- .../jet/MutableListIterator.kotlin_class | Bin 148 -> 148 bytes .../frontend/builtins/jet/Number.kotlin_class | 6 +++--- .../builtins/jet/Progression.kotlin_class | Bin 76 -> 76 bytes .../frontend/builtins/jet/Range.kotlin_class | Bin 90 -> 90 bytes .../frontend/builtins/jet/Short.kotlin_class | Bin 1385 -> 1385 bytes .../builtins/jet/ShortIterator.kotlin_class | 2 +- .../frontend/builtins/jet/String.kotlin_class | Bin 165 -> 165 bytes compiler/testData/builtin-classes.txt | 3 ++- .../operatorConventions/compareTo/boolean.kt | 11 +++++++++++ .../tests/library/BooleanIsNotComparable.kt | 8 -------- .../checkers/JetDiagnosticsTestGenerated.java | 5 ----- .../BlackBoxCodegenTestGenerated.java | 5 +++++ idea/builtinsSrc/jet/Library.kt | 4 +++- 38 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt delete mode 100644 compiler/testData/diagnostics/tests/library/BooleanIsNotComparable.kt diff --git a/compiler/frontend/builtins/jet/.kotlin_class_names b/compiler/frontend/builtins/jet/.kotlin_class_names index cc20324b6dbc743147a8f12dfda95686d4052820..82757a402dc3def01095cbc90f3e16c2891fcb70 100644 GIT binary patch delta 31 lcmZo+Yhjxp&MCvdz#t363KJFd8AUb*#4|A}PTs&20svWG1~32s delta 31 lcmZo+Yhjxp&MC#fz#t98auXHw85K4L#4|C30svWI1~dQw diff --git a/compiler/frontend/builtins/jet/.kotlin_name_table b/compiler/frontend/builtins/jet/.kotlin_name_table index 20ce8ec5116d51e749fd8ac04850f4a76854bfc4..150001fb61d1051627c5b25684ecd574e6eb7ed0 100644 GIT binary patch delta 88 zcmZ2tu*6`(R3$Fw{M>@XqQs<}R4(Skyc90h{F02+A}-Ekuy|@n{=^00oB0@h1QbOi Z7`WIt7zAXXv@DcXfYOSas|8oG0RU;D6kz}W delta 88 zcmZ2tu*6`(RBq(%6%SZF n8_)zM2}Y<6E})DgTsND66ozhyZPJ+HS-f1_9ETVUm?7E$Hz*CH literal 135 zcmd;Jli)OB;bIbCiW1{sGZ3-j;$RREl>&)yI)TY3381)`6%SaP4Wv?n5h}w4lo5xr aLAoWd=mv>PVv1++a&dDUVl-feXa@k-_6tM+ diff --git a/compiler/frontend/builtins/jet/BooleanArray.kotlin_class b/compiler/frontend/builtins/jet/BooleanArray.kotlin_class index 68ba918bf24b3304912c706517f4eacfe9b2a01e..83abca5284a5c93f89dafd8bd19d6a5b2af1e61c 100644 GIT binary patch delta 19 acmZo?Y-eQQV3XjU$YRFGGtt_cksAOaKm$Pl delta 19 acmZo?Y-eQQV3XjQ$YRFGJ<-~mkqZDKE(1OQ diff --git a/compiler/frontend/builtins/jet/BooleanIterator.kotlin_class b/compiler/frontend/builtins/jet/BooleanIterator.kotlin_class index e431fb41a6e..25e99a6c3fa 100644 --- a/compiler/frontend/builtins/jet/BooleanIterator.kotlin_class +++ b/compiler/frontend/builtins/jet/BooleanIterator.kotlin_class @@ -1,9 +1,9 @@ -& 2 +& 2   Z -0B +0B  Z -&0B +&0B  j Æ0B - \ No newline at end of file + \ No newline at end of file diff --git a/compiler/frontend/builtins/jet/Byte.kotlin_class b/compiler/frontend/builtins/jet/Byte.kotlin_class index 0c44f575e1791003f42baf997e18e6cdb7ecd47b..e626bb17a8f4f550be29038c48f2eee40eef8615 100644 GIT binary patch literal 1385 zcmZ{k?@og-97WwE4c6gGr(N|0{4;0B65T{U`4~KckLi=y{z}a;O}~)Kfsk`=fL8hL z(CDSPI;_G`TV>-}H@Vgg+flb?#@z||ipM5!^^dPB+*Ej9;Z23x3g66J2cLV%(OC@- z6=!lflP70WJSRE#1*bEglbmgFe|Gj^TR*O3TNPGa`h_&Om~^=Eh-Oc7v)FPs^Vo7% zX-UqO{Z_mW4+jpPr>R`RFh&3C6S+n>d7E~niu6^nMu literal 1385 zcmZ{kOHRWu6h&!?tYBQ~xYPt@jQF%gQ6+wX5zELDSSBmOevZ*WmM788Nfe!Xm84a@ zIW~G}S4R_$7f!i&W+vbI;da#RiQV1^`HIITaP^O`E8JFiSK&>Cy9(dTTnC>!$~F=eFR<(-%B>UKKofs)8razTnC8TKIF}nf@Z=+>@Mpl5Hz>EE(6~H delta 16 WcmZo?Y-gOH$jCEM$qYzD>Hz>EAp_k2 diff --git a/compiler/frontend/builtins/jet/ByteIterator.kotlin_class b/compiler/frontend/builtins/jet/ByteIterator.kotlin_class index 0c5f9e97d81..07b35b70681 100644 --- a/compiler/frontend/builtins/jet/ByteIterator.kotlin_class +++ b/compiler/frontend/builtins/jet/ByteIterator.kotlin_class @@ -1,9 +1,9 @@ &2  - Z -0B - Z + Z +0B + Z &0?B - j + j Æ0B  \ No newline at end of file diff --git a/compiler/frontend/builtins/jet/ByteProgression.kotlin_class b/compiler/frontend/builtins/jet/ByteProgression.kotlin_class index 62b452e210687d0368b1f3683fe4c2287659a227..b50a483494efe8a4ffc69d0948d486c2e35bc635 100644 GIT binary patch literal 120 zcmd;JlaMju;bIby6=D-&0n)rt+#J_944j>iI4)ogOB5G}m;oP{Ee%oS1W}b`$feJ5 cjM0GEii?9mz)1?M70h-iI4)ogOB5G}m;oP{Ee%oS1W}b`$feJ5 cjM0GEii?9mz)1?M70h-60RS*l#h9LE?9n8BtwK}-X)osmoy0RU>k5DfqT literal 148 zcmd;JlMqp2Fyi525|9&O6Ji060RS*l#h9LE?9n8BtwK}-X)osmoy0RU*-5C#AM diff --git a/compiler/frontend/builtins/jet/Char.kotlin_class b/compiler/frontend/builtins/jet/Char.kotlin_class index 83234cc77b87dd8890a54ecc01ec5e35bde1c369..b0a45762637a713aad49e2924de5341c1ccedc4b 100644 GIT binary patch literal 1145 zcmZ{jOHRWu6h&zpS*d9h#}y&!h#8+!6jg%Kz=&mJ2`sZK!|yqUQx#9F>k|*oeRfLI z)%(KE-Q9i_R_l$IT|Ks?>2C*HUb%K7r23Mz2)sSx^)Ej^?=rl}@FK%~hOZ}XgXg{G z==|`nv+2pBo70Zu(XF}QbmRHx<}c1Cw=T@88&*0)6Q(!sW@@?|ZTRwt22WE1X|tWU z+`u-|hMYG*&X(kCNzRt!Y)PJ4isy62lbk-}^dYAYIeo~JkIZm~8SXM}k|*oeRfLI z)w{yZ-QBJV>y0;FcJa(a@}lboL9^dwK7GQ&5WVKqvA$NT)y?390MZZr>? X3(b4YUh_fo^6T1OmEW^|q1*ZgQNLnS diff --git a/compiler/frontend/builtins/jet/CharIterator.kotlin_class b/compiler/frontend/builtins/jet/CharIterator.kotlin_class index 189e544112b..e0a08ddfd7b 100644 --- a/compiler/frontend/builtins/jet/CharIterator.kotlin_class +++ b/compiler/frontend/builtins/jet/CharIterator.kotlin_class @@ -1,7 +1,7 @@ &"2  Z -0B +0B Z &0MB j diff --git a/compiler/frontend/builtins/jet/Comparable.kotlin_class b/compiler/frontend/builtins/jet/Comparable.kotlin_class index cd90405868a7e5aea7bbbb9544bbb15c16423ff2..4a9a354d136cb1e64794c4d8e0089bb6a9bd15b6 100644 GIT binary patch literal 52 zcmd-`li0UkNFdBPD(lVG84)+ z9g4V2cZb#ZjCEPdTN;{BcK3Y@SE+drQvJxYaD08{&BgE2nP2|TCc}#iuQPl*@i=-u zYBuL5=j^#Tdv4C2o3rQU?72C6Zq8|FL({eWO1CY?RhR8T8{7h2}5KwdQZl+uthQhQCF3t*_}HBph|w literal 1361 zcmZ{j+e*Vg6h&Bo3rQU?72C6ZqA;Yv*+dTBJ$99Lbo3vF;Ugz?K0nmtd=q~#7R zcbS&tY)Q_R?|9;I?trHklZ{yH&4&a({uCm+&n!uPvb}DX*YnJdy;cca_&jaJ;}Kz`Mjsx tuQxpd^&t6O^IG%AbT)*4YThXCH5Zz{G&h>RHE(}c;kx=;beH-X{{iRNb>{#8 diff --git a/compiler/frontend/builtins/jet/DoubleIterator.kotlin_class b/compiler/frontend/builtins/jet/DoubleIterator.kotlin_class index 5846b220330..2e7ff71083f 100644 --- a/compiler/frontend/builtins/jet/DoubleIterator.kotlin_class +++ b/compiler/frontend/builtins/jet/DoubleIterator.kotlin_class @@ -1,7 +1,7 @@ &*2  Z -0B +0B Z &0]B j diff --git a/compiler/frontend/builtins/jet/Float.kotlin_class b/compiler/frontend/builtins/jet/Float.kotlin_class index 2e34a417402682d0b00d56e4235413827683ef75..d4722832ac00c8612bbc0174231d63517720150d 100644 GIT binary patch literal 1385 zcmZ{jTTa6;5JhQ;BG)w3NhLR813XGmRH;w`Uo0a_V419pcqXY%HS$k1J(*hPUOBF8 z>to@U;r_TDpS~%Z^s64CE4y9q-A#xOiBv!7Ss1>_@NnVr>YVz*ug@ZIbl9A`Av)xx`%hlO(b*_ij#jfqw(rr1mx@;GcU^V#h%`=j{OvzHp zJyPy7Dao0VoGHnflAI~YnUZ`?nQqW)#*>_$~f^XL34|&(5jaH{-dJn@g^qmaAtp`|4@;)zfnIwCAX&?w^dOei`KKlbn5$vrlsN zNzOjW=RVVS_bzv!8q)kB^G4>g%t7YQ>7JyWUgkphm&}dK-!gB1D}U$y7TvA>O@(Wf1@I_ERwZ76FP4!duuOh=Z3%nalv5f1RMV4@b?!`@ zO4)K->PdULo%&zhsV@902U96`*6Zr1H7g;ne|!nvWcVz@+YF!Yxp6$d+;erny9{6K zxc2@R=()@|lhc_zI=3)e?* zh3WEjUQU|ny7s?^t!cx*e6WRaM}1lBHOFT{UjO(xc%9(01aA_2zU9{O{CvyJ4sR2D zvEilnzd+Ar!kL`Tug`k%#Gi|q{}41!BF}qS4eif zsVkrILz{BnWZV*wmx;*aj7-kR-x>bcat)Zw06_bhcQ^^4RCnb%KpDyMz)F@KwuRq>v=eLeUWO(2KI diff --git a/compiler/frontend/builtins/jet/IntIterator.kotlin_class b/compiler/frontend/builtins/jet/IntIterator.kotlin_class index 2b574834e62..4e30b956bc8 100644 --- a/compiler/frontend/builtins/jet/IntIterator.kotlin_class +++ b/compiler/frontend/builtins/jet/IntIterator.kotlin_class @@ -1,7 +1,7 @@ &f2  Z -0B +0B Z &0ÒB j Æ0B diff --git a/compiler/frontend/builtins/jet/Iterator.kotlin_class b/compiler/frontend/builtins/jet/Iterator.kotlin_class index c8d7cc08428d70f5ba6f5388b338af2e9cd55eb9..383ac8e81dc825f3f9361205ef72cc123e7cb889 100644 GIT binary patch delta 14 VcmXptouI=h=fuXv!oeuO000tx0lfeK delta 14 VcmXptouI=h;bFL>& z;Tpfq%TaZ_oy6bLJD>jft}a|SY0KiEs#ijufA|u7Dm<5d^4S2d2Kan{=X+iU?(g^9 z{o;!qFQfmN)SBhoI9smHmaB6m8M%)-&ka{+yN^0suFk$|iaIpyM9$pBDU6y-5*&49 zT)9B9%U!Z@O!=lwJ~p|qM&$KCWO7C(XJm3lCTC=FMkengr`POiz>}Pw$w^HX)KT4hMd>x*oUdVZU4W7zrYd+>L({fzA JX5mmb`vyZUiVy$* literal 1548 zcmZ{k%Tj|t5Je?Y6aq11qKNKX`G~QmQsoO>`5AnIpXt`uFFDg4;?b5(s&l4mICq*M z&sw)mi%C6QSK)WxWiI}6eUoSYpeyp7`tU@^^AA4-uY{-4Pd*#r^$4Gj@N~-?&;8w& zXTSJj!;9d5CbeccH_n!;v*qesOGfUa&U3@n+3usxmaDVt+r05jSIL=YVG5Hrkpz2v z5mqjc>~fQ=3@P8V$%UrOFA;e;5}BNl$r+iPk;xgEoRP_g$niD18u28jCpkUI=}Asc za(a@}vxVo-AJ2S+Ghd-cuZE7BoLR`3g`8Q)nT33Ci)TyDEZ4@fmDiYDJuO$y#`LS_ zk>ToT_fb#F)w2!PA@lD^SBCrWk;q4ANE}x_|6PfhZ%j6w0Xb(t&KZz%2IPa$-{*1$ z>>p+jFZ8XvH&q|&JE><<-%DLf{UG&R>Q3rZ>PM;Lop1b;)C)PUuhCOE?###hWm=T^ JYvOlxvu^dckkb<5U=UzcV9?^@ViMq*DC7YEDvtv( delta 24 fcma!w65>dckkb<5U=UzcV9?^@ViMq+DC7YEDxU*2 diff --git a/compiler/frontend/builtins/jet/Short.kotlin_class b/compiler/frontend/builtins/jet/Short.kotlin_class index cc5560966ad2cd72c537c9ea1db03dff818f0b73..29fb9a941b4a23966d4ec4617d4ca95732181a7d 100644 GIT binary patch literal 1385 zcmZ{kZBBzg6h&<%6C8^jhJ>OU@T1m{CTffRav3baWx6t%_rM(UGJnYBbdsKXp)Fn4 z91Fh=H^%8+&M(eg+4kMAk!{_y>bhG=gR9X`pFE=3)7&hz+|N8c znSG`uIa`vmB{^G?vn4rOk}oZj=X1uBoSx+LB&R1iJ;~`wzIdi>57_pQaVDoTIi1Pr zOipKVI+HKXY1P>m_SOWsO8Ne+_Fl55F>+)ySU+V2IjY)R$ literal 1385 zcmZ{kOHRWu6h&!?EMrodIKl*GjQEsRQ6+wX5zELDSSBkYelJD`S)N2UrfC0W&OEQqK0BYBdmDx@*0QacS6%ljX>c~V`I84Udt92umb-<= zC$lTGBxg%~W>PjY&a)03Q@~f^ zXL34|)0sRu$88Up=e4|X { public final fun set(/*0*/ index: jet.Int, /*1*/ value: T): jet.Unit } -public final class Boolean { +public final class Boolean : jet.Comparable { /*primary*/ private constructor Boolean() public final fun and(/*0*/ other: jet.Boolean): jet.Boolean + public open override /*1*/ fun compareTo(/*0*/ other: jet.Boolean): jet.Int public final fun equals(/*0*/ other: jet.Any?): jet.Boolean public final fun not(): jet.Boolean public final fun or(/*0*/ other: jet.Boolean): jet.Boolean diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt new file mode 100644 index 00000000000..67a344bf1ec --- /dev/null +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt @@ -0,0 +1,11 @@ +fun checkLess(x: Boolean, y: Boolean) = when { + x >= y -> "Fail $x >= $y" + !(x < y) -> "Fail !($x < $y)" + !(x <= y) -> "Fail !($x <= $y)" + x > y -> "Fail $x > $y" + x.compareTo(y) >= 0 -> "Fail $x.compareTo($y) >= 0" + x compareTo y >= 0 -> "Fail $x compareTo $y >= 0" + else -> "OK" +} + +fun box() = checkLess(false, true) diff --git a/compiler/testData/diagnostics/tests/library/BooleanIsNotComparable.kt b/compiler/testData/diagnostics/tests/library/BooleanIsNotComparable.kt deleted file mode 100644 index 02a6b985fea..00000000000 --- a/compiler/testData/diagnostics/tests/library/BooleanIsNotComparable.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun foo(x: Boolean) { - x < x - x <= x - x > x - x >= x - x == x - x.compareTo(x) -} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 59956d12b0d..d90aaef30c2 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -4614,11 +4614,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/library"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("BooleanIsNotComparable.kt") - public void testBooleanIsNotComparable() throws Exception { - doTest("compiler/testData/diagnostics/tests/library/BooleanIsNotComparable.kt"); - } - @TestMetadata("Collections.kt") public void testCollections() throws Exception { doTest("compiler/testData/diagnostics/tests/library/Collections.kt"); diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java index d7704d1c0a1..a4975a83296 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -4051,6 +4051,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/box/operatorConventions/compareTo"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("boolean.kt") + public void testBoolean() throws Exception { + doTest("compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt"); + } + @TestMetadata("comparable.kt") public void testComparable() throws Exception { doTest("compiler/testData/codegen/box/operatorConventions/compareTo/comparable.kt"); diff --git a/idea/builtinsSrc/jet/Library.kt b/idea/builtinsSrc/jet/Library.kt index 391fb2b24a8..ee9f69f4504 100644 --- a/idea/builtinsSrc/jet/Library.kt +++ b/idea/builtinsSrc/jet/Library.kt @@ -37,7 +37,7 @@ public trait Hashable { public fun equals(other : Any?) : Boolean } -public class Boolean private () { +public class Boolean private () : Comparable { public fun not() : Boolean public fun and(other : Boolean) : Boolean @@ -46,6 +46,8 @@ public class Boolean private () { public fun xor(other : Boolean) : Boolean + public override fun compareTo(other : Boolean) : Int + public fun equals(other : Any?) : Boolean }