KT-1306123.lng or 123.sht is not good name

This commit is contained in:
Andrey Breslav
2012-02-20 21:42:13 +04:00
parent 5eb483b7a7
commit bff62484b1
68 changed files with 233 additions and 220 deletions
+2
View File
@@ -26,6 +26,8 @@
<RunnerSettings RunnerId="Profile "> <RunnerSettings RunnerId="Profile ">
<option name="myExternalizedOptions" value="&#10;additional-options2=onexit\=snapshot&#10;" /> <option name="myExternalizedOptions" value="&#10;additional-options2=onexit\=snapshot&#10;" />
</RunnerSettings> </RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method /> <method />
</configuration> </configuration>
</component> </component>
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.types.JetStandardClasses;
import org.jetbrains.jet.lang.types.JetStandardLibrary; import org.jetbrains.jet.lang.types.JetStandardLibrary;
import org.jetbrains.jet.lang.types.PrimitiveType; import org.jetbrains.jet.lang.types.PrimitiveType;
import org.jetbrains.jet.lang.types.TypeProjection; import org.jetbrains.jet.lang.types.TypeProjection;
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
import org.jetbrains.jet.plugin.JetFileType; import org.jetbrains.jet.plugin.JetFileType;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
@@ -70,7 +71,7 @@ public class IntrinsicMethods {
public IntrinsicMethods(Project project, JetStandardLibrary stdlib) { public IntrinsicMethods(Project project, JetStandardLibrary stdlib) {
myProject = project; myProject = project;
myStdLib = stdlib; myStdLib = stdlib;
List<String> primitiveCastMethods = ImmutableList.of("dbl", "flt", "lng", "int", "chr", "sht", "byt"); List<String> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
for (String method : primitiveCastMethods) { for (String method : primitiveCastMethods) {
declareIntrinsicProperty("Number", method, NUMBER_CAST); declareIntrinsicProperty("Number", method, NUMBER_CAST);
for (String type : PRIMITIVE_NUMBER_TYPES) { for (String type : PRIMITIVE_NUMBER_TYPES) {
+6 -6
View File
@@ -1,13 +1,13 @@
package jet package jet
abstract class Number : Hashable { abstract class Number : Hashable {
abstract val dbl : Double abstract val double : Double
abstract val flt : Float abstract val float : Float
abstract val lng : Long abstract val long : Long
abstract val int : Int abstract val int : Int
abstract val chr : Char abstract val char : Char
abstract val sht : Short abstract val short : Short
abstract val byt : Byte abstract val byte : Byte
// fun equals(other : Double) : Boolean // fun equals(other : Double) : Boolean
// fun equals(other : Float) : Boolean // fun equals(other : Float) : Boolean
// fun equals(other : Long) : Boolean // fun equals(other : Long) : Boolean
@@ -180,8 +180,8 @@ public class OverloadResolver {
continue; continue;
} }
OverloadUtil.OverloadCompatibilityInfo overloadble = OverloadUtil.isOverloadble(function, function2); OverloadUtil.OverloadCompatibilityInfo overloadable = OverloadUtil.isOverloadable(function, function2);
if (!overloadble.isSuccess()) { if (!overloadable.isSuccess()) {
JetDeclaration member = (JetDeclaration) context.getTrace().get(BindingContext.DESCRIPTOR_TO_DECLARATION, function); JetDeclaration member = (JetDeclaration) context.getTrace().get(BindingContext.DESCRIPTOR_TO_DECLARATION, function);
if (member == null) { if (member == null) {
assert context.getTrace().get(DELEGATED, function); assert context.getTrace().get(DELEGATED, function);
@@ -29,7 +29,7 @@ public class OverloadUtil {
/** /**
* Does not check names. * Does not check names.
*/ */
public static OverloadCompatibilityInfo isOverloadble(CallableDescriptor a, CallableDescriptor b) { public static OverloadCompatibilityInfo isOverloadable(CallableDescriptor a, CallableDescriptor b) {
int abc = braceCount(a); int abc = braceCount(a);
int bbc = braceCount(b); int bbc = braceCount(b);
@@ -59,6 +59,6 @@ public class ByteValue implements CompileTimeConstant<Byte> {
@Override @Override
public String toString() { public String toString() {
return value + ".byt"; return value + ".byte";
} }
} }
@@ -49,6 +49,6 @@ public class DoubleValue implements CompileTimeConstant<Double> {
@Override @Override
public String toString() { public String toString() {
return value + ".dbl"; return value + ".double";
} }
} }
@@ -49,6 +49,6 @@ public class FloatValue implements CompileTimeConstant<Float> {
@Override @Override
public String toString() { public String toString() {
return value + ".flt"; return value + ".float";
} }
} }
@@ -58,6 +58,6 @@ public class LongValue implements CompileTimeConstant<Long> {
@Override @Override
public String toString() { public String toString() {
return value + ".lng"; return value + ".long";
} }
} }
@@ -59,7 +59,7 @@ public class ShortValue implements CompileTimeConstant<Short> {
@Override @Override
public String toString() { public String toString() {
return value + ".sht"; return value + ".short";
} }
} }
@@ -52,6 +52,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.*;
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor.NO_RECEIVER; import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor.NO_RECEIVER;
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE; import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.*; import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.*;
import static org.jetbrains.jet.lang.types.expressions.OperatorConventions.*;
/** /**
* @author abreslav * @author abreslav
@@ -570,22 +571,22 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
Number value = (Number) receiverValue.getValue(); Number value = (Number) receiverValue.getValue();
String referencedName = selectorExpression.getReferencedName(); String referencedName = selectorExpression.getReferencedName();
if (OperatorConventions.NUMBER_CONVERSIONS.contains(referencedName)) { if (OperatorConventions.NUMBER_CONVERSIONS.contains(referencedName)) {
if ("dbl".equals(referencedName)) { if (DOUBLE.equals(referencedName)) {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new DoubleValue(value.doubleValue())); context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new DoubleValue(value.doubleValue()));
} }
else if ("flt".equals(referencedName)) { else if (FLOAT.equals(referencedName)) {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new FloatValue(value.floatValue())); context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new FloatValue(value.floatValue()));
} }
else if ("lng".equals(referencedName)) { else if (LONG.equals(referencedName)) {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new LongValue(value.longValue())); context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new LongValue(value.longValue()));
} }
else if ("sht".equals(referencedName)) { else if (SHORT.equals(referencedName)) {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new ShortValue(value.shortValue())); context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new ShortValue(value.shortValue()));
} }
else if ("byt".equals(referencedName)) { else if (BYTE.equals(referencedName)) {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new ByteValue(value.byteValue())); context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new ByteValue(value.byteValue()));
} }
else if ("int".equals(referencedName)) { else if (INT.equals(referencedName)) {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new IntValue(value.intValue())); context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new IntValue(value.intValue()));
} }
} }
@@ -35,13 +35,18 @@ public class OperatorConventions {
private OperatorConventions() {} private OperatorConventions() {}
// Names for primitive type conversion properties
public static final String DOUBLE = "double";
public static final String FLOAT = "float";
public static final String LONG = "long";
public static final String INT = "int";
public static final String CHAR = "char";
public static final String SHORT = "short";
public static final String BYTE = "byte";
public static final ImmutableSet<String> NUMBER_CONVERSIONS = ImmutableSet.of( public static final ImmutableSet<String> NUMBER_CONVERSIONS = ImmutableSet.of(
"dbl", DOUBLE, FLOAT, LONG, INT, SHORT, BYTE, CHAR
"flt",
"lng",
"sht",
"byt",
"int"
); );
public static final ImmutableBiMap<JetToken, String> UNARY_OPERATION_NAMES = ImmutableBiMap.<JetToken, String>builder() public static final ImmutableBiMap<JetToken, String> UNARY_OPERATION_NAMES = ImmutableBiMap.<JetToken, String>builder()
+5 -5
View File
@@ -15,7 +15,7 @@ sink:
fun f(a : Boolean) : Unit { fun f(a : Boolean) : Unit {
1 1
a a
2.lng 2.long
foo(a, 3) foo(a, 3)
genfun<Any>() genfun<Any>()
flfun {1} flfun {1}
@@ -36,10 +36,10 @@ l0:
w(a) NEXT:[r(1)] PREV:[v(a : Boolean)] w(a) NEXT:[r(1)] PREV:[v(a : Boolean)]
r(1) NEXT:[r(a)] PREV:[w(a)] r(1) NEXT:[r(a)] PREV:[w(a)]
r(a) NEXT:[r(2)] PREV:[r(1)] r(a) NEXT:[r(2)] PREV:[r(1)]
r(2) NEXT:[r(lng)] PREV:[r(a)] r(2) NEXT:[r(long)] PREV:[r(a)]
r(lng) NEXT:[r(2.lng)] PREV:[r(2)] r(long) NEXT:[r(2.long)] PREV:[r(2)]
r(2.lng) NEXT:[r(a)] PREV:[r(lng)] r(2.long) NEXT:[r(a)] PREV:[r(long)]
r(a) NEXT:[r(3)] PREV:[r(2.lng)] r(a) NEXT:[r(3)] PREV:[r(2.long)]
r(3) NEXT:[r(foo)] PREV:[r(a)] r(3) NEXT:[r(foo)] PREV:[r(a)]
r(foo) NEXT:[r(foo(a, 3))] PREV:[r(3)] r(foo) NEXT:[r(foo(a, 3))] PREV:[r(3)]
r(foo(a, 3)) NEXT:[r(genfun)] PREV:[r(foo)] r(foo(a, 3)) NEXT:[r(genfun)] PREV:[r(foo)]
+1 -1
View File
@@ -1,7 +1,7 @@
fun f(a : Boolean) : Unit { fun f(a : Boolean) : Unit {
1 1
a a
2.lng 2.long
foo(a, 3) foo(a, 3)
genfun<Any>() genfun<Any>()
flfun {1} flfun {1}
@@ -1,5 +1,5 @@
fun StringBuilder.takeFirst(): Char { fun StringBuilder.takeFirst(): Char {
if (this.length() == 0) return 0.chr if (this.length() == 0) return 0.char
val c = this.charAt(0) val c = this.charAt(0)
this.deleteCharAt(0) this.deleteCharAt(0)
return c return c
@@ -8,7 +8,7 @@ fun StringBuilder.takeFirst(): Char {
fun foo(expr: StringBuilder): Int { fun foo(expr: StringBuilder): Int {
val c = expr.takeFirst() val c = expr.takeFirst()
when(c) { when(c) {
0.chr -> throw Exception("zero") 0.char -> throw Exception("zero")
else -> throw Exception("nonzero" + c) else -> throw Exception("nonzero" + c)
} }
} }
+12 -12
View File
@@ -62,43 +62,43 @@ fun t3() : Boolean {
} }
fun t4() : Boolean { fun t4() : Boolean {
var x = 100.flt var x = 100.float
val y = x + 22 val y = x + 22
val foo = { val foo = {
x = x + 200.flt + y x = x + 200.float + y
x += 18 x += 18
#() #()
} }
foo() foo()
System.out?.println(x) System.out?.println(x)
return x == 440.flt return x == 440.float
} }
fun t5() : Boolean { fun t5() : Boolean {
var x = 100.dbl var x = 100.double
val y = x + 22 val y = x + 22
val foo = { val foo = {
x = x + 200.dbl + y x = x + 200.double + y
x -= 22 x -= 22
#() #()
} }
foo() foo()
System.out?.println(x) System.out?.println(x)
return x == 400.dbl return x == 400.double
} }
fun t6() : Boolean { fun t6() : Boolean {
var x = 20.byt var x = 20.byte
val y = x + 22 val y = x + 22
val foo = { val foo = {
x = (x + 20.byt + y).byt x = (x + 20.byte + y).byte
x += 2 x += 2
x-- x--
#() #()
} }
foo() foo()
System.out?.println(x) System.out?.println(x)
return x == 83.byt return x == 83.byte
} }
fun t7() : Boolean { fun t7() : Boolean {
@@ -113,17 +113,17 @@ fun t7() : Boolean {
} }
fun t8() : Boolean { fun t8() : Boolean {
var x = 20.sht var x = 20.short
val foo = { val foo = {
val bar = { val bar = {
x = 30.sht x = 30.short
#() #()
} }
bar() bar()
#() #()
} }
foo() foo()
return x == 30.sht return x == 30.short
} }
fun t9(var x: Int) : Boolean { fun t9(var x: Int) : Boolean {
+10 -10
View File
@@ -3,24 +3,24 @@ class A() {
var xin : Int? = 0 var xin : Int? = 0
var xinn : Int? = null var xinn : Int? = null
var xl = 0.lng var xl = 0.long
var xln : Long? = 0.lng var xln : Long? = 0.long
var xlnn : Long? = null var xlnn : Long? = null
var xb = 0.byt var xb = 0.byte
var xbn : Byte? = 0.byt var xbn : Byte? = 0.byte
var xbnn : Byte? = null var xbnn : Byte? = null
var xf = 0.flt var xf = 0.float
var xfn : Float? = 0.flt var xfn : Float? = 0.float
var xfnn : Float? = null var xfnn : Float? = null
var xd = 0.dbl var xd = 0.double
var xdn : Double? = 0.dbl var xdn : Double? = 0.double
var xdnn : Double? = null var xdnn : Double? = null
var xs = 0.sht var xs = 0.short
var xsn : Short? = 0.sht var xsn : Short? = 0.short
var xsnn : Short? = null var xsnn : Short? = null
} }
@@ -123,6 +123,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do { do {
var i = read(); var i = read();
if (i == -1) break if (i == -1) break
body(i.chr) body(i.char)
} while(true) } while(true)
} }
@@ -102,6 +102,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do { do {
var i = read(); var i = read();
if (i == -1) break if (i == -1) break
body(i.chr) body(i.char)
} while(true) } while(true)
} }
@@ -139,6 +139,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do { do {
var i = read(); var i = read();
if (i == -1) break if (i == -1) break
body(i.chr) body(i.char)
} while(true) } while(true)
} }
@@ -2,7 +2,7 @@ package name
class Test() { class Test() {
var i = 5 var i = 5
val ten = 10.lng val ten = 10.long
fun Long.t() = this.int + i++ + ++i fun Long.t() = this.int + i++ + ++i
@@ -5,5 +5,5 @@ fun Long?.inv() : Long = this.sure().inv()
fun box() : String { fun box() : String {
val x : Long? = 10 val x : Long? = 10
System.out?.println(x.inv()) System.out?.println(x.inv())
return if(x.inv() == -11.lng) "OK" else "fail" return if(x.inv() == -11.long) "OK" else "fail"
} }
@@ -1,11 +1,11 @@
fun box() : String { fun box() : String {
System.out?.println(System.out?.println(10.flt..11.flt)) System.out?.println(System.out?.println(10.float..11.float))
for(f in 10.flt..11.flt step 0.3.flt) { for(f in 10.float..11.float step 0.3.float) {
System.out?.println(f) System.out?.println(f)
} }
for(f in 10.dbl..11.dbl step 0.3.dbl) { for(f in 10.double..11.double step 0.3.double) {
System.out?.println(f) System.out?.println(f)
} }
@@ -9,22 +9,22 @@ fun box() : String {
if(r4.end != 5 || r4.isReversed || r4.size != 6) return "fail" if(r4.end != 5 || r4.isReversed || r4.size != 6) return "fail"
val r5 = ByteRange(1, 4) val r5 = ByteRange(1, 4)
if(r5.end != 4.byt || r5.isReversed || r5.size != 4) return "fail" if(r5.end != 4.byte || r5.isReversed || r5.size != 4) return "fail"
val r7 = -(0.byt..5.byt) val r7 = -(0.byte..5.byte)
if(r7.start != 5.byt || r7.end != 0.byt || !r7.isReversed) return "fail" if(r7.start != 5.byte || r7.end != 0.byte || !r7.isReversed) return "fail"
val r9 = -r7 val r9 = -r7
if(r9.end != 5.byt || r9.isReversed) return "fail" if(r9.end != 5.byte || r9.isReversed) return "fail"
val r10 = ShortRange(1, 4) val r10 = ShortRange(1, 4)
if(r10.end != 4.sht || r10.isReversed || r10.size != 4) return "fail" if(r10.end != 4.short || r10.isReversed || r10.size != 4) return "fail"
val r12 = -(0.sht..5.sht) val r12 = -(0.short..5.short)
if(r12.start != 5.sht || r12.end != 0.sht || !r12.isReversed) return "fail" if(r12.start != 5.short || r12.end != 0.short || !r12.isReversed) return "fail"
val r13 = -r12 val r13 = -r12
if(r13.end != 5.sht || r13.isReversed) return "fail" if(r13.end != 5.short || r13.isReversed) return "fail"
val r14 = CharRange('a', 4) val r14 = CharRange('a', 4)
if(r14.end != 'd' || r14.isReversed || r14.size != 4) return "fail" if(r14.end != 'd' || r14.isReversed || r14.size != 4) return "fail"
@@ -1,11 +1,11 @@
fun box() : String { fun box() : String {
val fps : Double = 1.dbl val fps : Double = 1.double
var mspf : Long var mspf : Long
{ {
if ((fps.int == 0)) if ((fps.int == 0))
mspf = 0 mspf = 0
else else
mspf = (((1000.0 / fps)).lng) mspf = (((1000.0 / fps)).long)
} }
return "OK" return "OK"
} }
@@ -1,5 +1,5 @@
val _0 : Double = 0.0 val _0 : Double = 0.0
val _0dbl : Double = 0.dbl val _0dbl : Double = 0.double
fun box() : String { fun box() : String {
if(_0 != _0dbl) return "fail" if(_0 != _0dbl) return "fail"
@@ -8,7 +8,7 @@ public open class PerfectNumberFinder() {
var factors : List<Int?>? = ArrayList<Int?>() var factors : List<Int?>? = ArrayList<Int?>()
factors?.add(1) factors?.add(1)
factors?.add(number) factors?.add(number)
for (i in 2..(Math.sqrt((number).dbl) - 1).int) for (i in 2..(Math.sqrt((number).double) - 1).int)
if (((number % i) == 0)) { if (((number % i) == 0)) {
factors?.add(i) factors?.add(i)
if (((number / i) != i)) if (((number / i) != i))
@@ -8,7 +8,7 @@ fun test1() : Boolean {
} }
fun test2() : Boolean { fun test2() : Boolean {
val r1 = 1.byt..10.byt val r1 = 1.byte..10.byte
var s1 = 0 var s1 = 0
for(e in r1 step 2) { for(e in r1 step 2) {
s1 += e s1 += e
@@ -17,21 +17,21 @@ fun test2() : Boolean {
} }
fun test3() : Boolean { fun test3() : Boolean {
val r1 = 1.byt..10.lng val r1 = 1.byte..10.long
var s1 = 0.lng var s1 = 0.long
for(e in r1 step 2) { for(e in r1 step 2) {
s1 += e s1 += e
} }
return s1 == 25.lng return s1 == 25.long
} }
fun test4() : Boolean { fun test4() : Boolean {
val r1 = 1.byt..10.sht val r1 = 1.byte..10.short
var s1 = 0.sht var s1 = 0.short
for(e in r1 step 2) { for(e in r1 step 2) {
s1 += e s1 += e
} }
return s1 == 25.sht return s1 == 25.short
} }
fun test5() : Boolean { fun test5() : Boolean {
+26 -26
View File
@@ -15,51 +15,51 @@ fun testInt () : String {
} }
fun testByte () : String { fun testByte () : String {
val r1 = 1.byt upto 4.byt val r1 = 1.byte upto 4.byte
if(r1.end != 4.byt || r1.isReversed || r1.size != 4) return "byte upto fail" if(r1.end != 4.byte || r1.isReversed || r1.size != 4) return "byte upto fail"
val r2 = 4.byt upto 1.byt val r2 = 4.byte upto 1.byte
if(r2.start != 0.byt || r2.size != 0) return "byte negative upto fail" if(r2.start != 0.byte || r2.size != 0) return "byte negative upto fail"
val r3 = 5.byt downto 0.byt val r3 = 5.byte downto 0.byte
if(r3.start != 5.byt || r3.end != 0.byt || !r3.isReversed || r3.size != 6) return "byte downto fail" if(r3.start != 5.byte || r3.end != 0.byte || !r3.isReversed || r3.size != 6) return "byte downto fail"
val r4 = 5.byt downto 6.byt val r4 = 5.byte downto 6.byte
if(r4.start != 0.byt || r4.end != 0.byt || !r3.isReversed || r4.size != 0) return "byte negative downto fail" if(r4.start != 0.byte || r4.end != 0.byte || !r3.isReversed || r4.size != 0) return "byte negative downto fail"
return "OK" return "OK"
} }
fun testShort () : String { fun testShort () : String {
val r1 = 1.sht upto 4.sht val r1 = 1.short upto 4.short
if(r1.end != 4.sht || r1.isReversed || r1.size != 4) return "short upto fail" if(r1.end != 4.short || r1.isReversed || r1.size != 4) return "short upto fail"
val r2 = 4.sht upto 1.sht val r2 = 4.short upto 1.short
if(r2.start != 0.sht || r2.size != 0) return "short negative upto fail" if(r2.start != 0.short || r2.size != 0) return "short negative upto fail"
val r3 = 5.sht downto 0.sht val r3 = 5.short downto 0.short
if(r3.start != 5.sht || r3.end != 0.sht || !r3.isReversed || r3.size != 6) return "short downto fail" if(r3.start != 5.short || r3.end != 0.short || !r3.isReversed || r3.size != 6) return "short downto fail"
val r4 = 5.sht downto 6.sht val r4 = 5.short downto 6.short
if(r4.start != 0.sht || r4.end != 0.sht || !r3.isReversed || r4.size != 0) return "short negative downto fail" if(r4.start != 0.short || r4.end != 0.short || !r3.isReversed || r4.size != 0) return "short negative downto fail"
return "OK" return "OK"
} }
fun testLong () : String { fun testLong () : String {
val r1 = 1.lng upto 4.lng val r1 = 1.long upto 4.long
if(r1.end != 4.lng || r1.isReversed || r1.size != 4.lng) return "long upto fail" if(r1.end != 4.long || r1.isReversed || r1.size != 4.long) return "long upto fail"
val r2 = 4.lng upto 1.lng val r2 = 4.long upto 1.long
if(r2.start != 0.lng || r2.size != 0.lng) return "short negative long fail" if(r2.start != 0.long || r2.size != 0.long) return "short negative long fail"
val r3 = 5.lng downto 0.lng val r3 = 5.long downto 0.long
if(r3.start != 5.lng || r3.end != 0.lng || !r3.isReversed || r3.size != 6.lng) return "long downto fail" if(r3.start != 5.long || r3.end != 0.long || !r3.isReversed || r3.size != 6.long) return "long downto fail"
val r4 = 5.lng downto 6.lng val r4 = 5.long downto 6.long
if(r4.start != 0.lng || r4.end != 0.lng || !r3.isReversed || r4.size != 0.lng) return "long negative downto fail" if(r4.start != 0.long || r4.end != 0.long || !r3.isReversed || r4.size != 0.long) return "long negative downto fail"
return "OK" return "OK"
} }
@@ -70,13 +70,13 @@ fun testChar () : String {
if(r1.end != 'd' || r1.isReversed || r1.size != 4) return "char upto fail" if(r1.end != 'd' || r1.isReversed || r1.size != 4) return "char upto fail"
val r2 = 'd' upto 'a' val r2 = 'd' upto 'a'
if(r2.start != 0.chr || r2.size != 0) return "char negative long fail" if(r2.start != 0.char || r2.size != 0) return "char negative long fail"
val r3 = 'd' downto 'a' val r3 = 'd' downto 'a'
if(r3.start != 'd' || r3.end != 'a' || !r3.isReversed || r3.size != 4) return "char downto fail" if(r3.start != 'd' || r3.end != 'a' || !r3.isReversed || r3.size != 4) return "char downto fail"
val r4 = 'a' downto 'd' val r4 = 'a' downto 'd'
if(r4.start != 0.chr || r4.end != 0.chr || !r3.isReversed || r4.size != 0) return "char negative downto fail" if(r4.start != 0.char || r4.end != 0.char || !r3.isReversed || r4.size != 0) return "char negative downto fail"
return "OK" return "OK"
} }
@@ -18,8 +18,8 @@ abstract class B() : A {
override fun foo2() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> { override fun foo2() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> {
} }
override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.dbl override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.double
override val <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>a1<!> = 1.dbl override val <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>a1<!> = 1.double
abstract override fun <X> g() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Int<!> abstract override fun <X> g() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Int<!>
abstract override fun <X> g1() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>java.util.List<X><!> abstract override fun <X> g1() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>java.util.List<X><!>
@@ -21,7 +21,7 @@ fun bbb() {
fun foo(<!UNUSED_PARAMETER!>expr<!>: StringBuilder): Int { fun foo(<!UNUSED_PARAMETER!>expr<!>: StringBuilder): Int {
val c = 'a' val c = 'a'
when(c) { when(c) {
0.chr -> throw Exception("zero") 0.char -> throw Exception("zero")
else -> throw Exception("nonzero" + c) else -> throw Exception("nonzero" + c)
} }
} }
@@ -2,7 +2,7 @@ var x : Int = 1 + x
get() : Int = 1 get() : Int = 1
set(value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) { set(value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) {
$x = value.int $x = value.int
$x = <!TYPE_MISMATCH!>1.lng<!> $x = <!TYPE_MISMATCH!>1.long<!>
} }
val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!> val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!>
@@ -23,5 +23,5 @@ fun test() {
fooi(1, 2, 3) fooi(1, 2, 3)
fool(1, 2, 3) fool(1, 2, 3)
food(1.0, 2.0, 3.0) food(1.0, 2.0, 3.0)
foof(1.0.flt, 2.0.flt, 3.0.flt) foof(1.0.float, 2.0.float, 3.0.float)
} }
@@ -5,7 +5,7 @@ package kt1066
import java.util.Set import java.util.Set
fun randomDigit() = 0.chr fun randomDigit() = 0.char
fun foo(excluded: Set<Char>) { fun foo(excluded: Set<Char>) {
var digit : Char var digit : Char
@@ -285,7 +285,7 @@ public class ArrayGenTest extends CodegenTestCase {
public void testLongDouble () throws Exception { public void testLongDouble () throws Exception {
loadText( loadText(
"fun box() : Int { var l = IntArray(1); l[0.lng] = 4; l[0.lng] += 6; return l[0.lng];}\n" + "fun box() : Int { var l = IntArray(1); l[0.long] = 4; l[0.long] += 6; return l[0.long];}\n" +
"fun IntArray.set(index: Long, elem: Int) { this[index.int] = elem }\n" + "fun IntArray.set(index: Long, elem: Int) { this[index.int] = elem }\n" +
"fun IntArray.get(index: Long) = this[index.int]"); "fun IntArray.get(index: Long) = this[index.int]");
// System.out.println(generateToText()); // System.out.println(generateToText());
@@ -378,7 +378,7 @@ public class NamespaceGenTest extends CodegenTestCase {
} }
public void testArrayAugAssignLong() throws Exception { public void testArrayAugAssignLong() throws Exception {
loadText("fun foo(c: LongArray) { c[0] *= 2.lng }"); loadText("fun foo(c: LongArray) { c[0] *= 2.long }");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction(); final Method main = generateFunction();
long[] data = new long[] { 5 }; long[] data = new long[] { 5 };
@@ -154,13 +154,13 @@ public class PrimitiveTypesTest extends CodegenTestCase {
} }
public void testCastConstant() throws Exception { public void testCastConstant() throws Exception {
loadText("fun foo(): Double = 1.dbl"); loadText("fun foo(): Double = 1.double");
final Method main = generateFunction(); final Method main = generateFunction();
assertEquals(1.0, main.invoke(null)); assertEquals(1.0, main.invoke(null));
} }
public void testCastOnStack() throws Exception { public void testCastOnStack() throws Exception {
loadText("fun foo(): Double = System.currentTimeMillis().dbl"); loadText("fun foo(): Double = System.currentTimeMillis().double");
final Method main = generateFunction(); final Method main = generateFunction();
double currentTimeMillis = (double) System.currentTimeMillis(); double currentTimeMillis = (double) System.currentTimeMillis();
double result = (Double) main.invoke(null); double result = (Double) main.invoke(null);
@@ -327,7 +327,7 @@ public class PrimitiveTypesTest extends CodegenTestCase {
} }
public void testKt737() throws Exception { public void testKt737() throws Exception {
loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.byt.compareTo(10.lng) >= 0) \"fail\" else \"OK\""); loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.byte.compareTo(10.long) >= 0) \"fail\" else \"OK\"");
assertEquals("OK", blackBox()); assertEquals("OK", blackBox());
} }
@@ -58,7 +58,7 @@ public class VarArgTest extends CodegenTestCase {
} }
public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException { public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException {
loadText("fun test() = testf(239.byt, 7.byt); fun testf(vararg ts: Byte?) = ts"); loadText("fun test() = testf(239.byte, 7.byte); fun testf(vararg ts: Byte?) = ts");
// System.out.println(generateToText()); // System.out.println(generateToText());
final Method main = generateFunction("test"); final Method main = generateFunction("test");
Object res = main.invoke(null); Object res = main.invoke(null);
@@ -160,11 +160,11 @@ public class JetOverloadTest extends JetLiteFixture {
FunctionDescriptor a = makeFunction(funA); FunctionDescriptor a = makeFunction(funA);
FunctionDescriptor b = makeFunction(funB); FunctionDescriptor b = makeFunction(funB);
{ {
OverloadUtil.OverloadCompatibilityInfo overloadableWith = OverloadUtil.isOverloadble(a, b); OverloadUtil.OverloadCompatibilityInfo overloadableWith = OverloadUtil.isOverloadable(a, b);
assertEquals(overloadableWith.getMessage(), expectedIsError, !overloadableWith.isSuccess()); assertEquals(overloadableWith.getMessage(), expectedIsError, !overloadableWith.isSuccess());
} }
{ {
OverloadUtil.OverloadCompatibilityInfo overloadableWith = OverloadUtil.isOverloadble(b, a); OverloadUtil.OverloadCompatibilityInfo overloadableWith = OverloadUtil.isOverloadable(b, a);
assertEquals(overloadableWith.getMessage(), expectedIsError, !overloadableWith.isSuccess()); assertEquals(overloadableWith.getMessage(), expectedIsError, !overloadableWith.isSuccess());
} }
} }
@@ -79,14 +79,14 @@ public class JetTypeCheckerTest extends JetLiteFixture {
assertType("0b1", library.getIntType()); assertType("0b1", library.getIntType());
assertType("0B1", library.getIntType()); assertType("0B1", library.getIntType());
assertType("1.lng", library.getLongType()); assertType("1.long", library.getLongType());
assertType("1.0", library.getDoubleType()); assertType("1.0", library.getDoubleType());
assertType("1.0.dbl", library.getDoubleType()); assertType("1.0.double", library.getDoubleType());
assertType("0x1.fffffffffffffp1023", library.getDoubleType()); assertType("0x1.fffffffffffffp1023", library.getDoubleType());
assertType("1.0.flt", library.getFloatType()); assertType("1.0.float", library.getFloatType());
assertType("0x1.fffffffffffffp1023.flt", library.getFloatType()); assertType("0x1.fffffffffffffp1023.float", library.getFloatType());
assertType("true", library.getBooleanType()); assertType("true", library.getBooleanType());
assertType("false", library.getBooleanType()); assertType("false", library.getBooleanType());
@@ -400,53 +400,53 @@ public class JetTypeCheckerTest extends JetLiteFixture {
assertType("f()", "Unit"); assertType("f()", "Unit");
assertType("f(1)", "Int"); assertType("f(1)", "Int");
assertType("f(1.flt, 1)", "Float"); assertType("f(1.float, 1)", "Float");
assertType("f<String>(1.flt)", "String"); assertType("f<String>(1.float)", "String");
} }
public void testPlus() throws Exception { public void testPlus() throws Exception {
assertType("1.0.plus(1.dbl)", "Double"); assertType("1.0.plus(1.double)", "Double");
assertType("1.0.plus(1.flt)", "Double"); assertType("1.0.plus(1.float)", "Double");
assertType("1.0.plus(1.lng)", "Double"); assertType("1.0.plus(1.long)", "Double");
assertType("1.0.plus(1)", "Double"); assertType("1.0.plus(1)", "Double");
assertType("1.flt.plus(1.dbl)", "Double"); assertType("1.float.plus(1.double)", "Double");
assertType("1.flt.plus(1.flt)", "Float"); assertType("1.float.plus(1.float)", "Float");
assertType("1.flt.plus(1.lng)", "Float"); assertType("1.float.plus(1.long)", "Float");
assertType("1.flt.plus(1)", "Float"); assertType("1.float.plus(1)", "Float");
assertType("1.lng.plus(1.dbl)", "Double"); assertType("1.long.plus(1.double)", "Double");
assertType("1.lng.plus(1.flt)", "Float"); assertType("1.long.plus(1.float)", "Float");
assertType("1.lng.plus(1.lng)", "Long"); assertType("1.long.plus(1.long)", "Long");
assertType("1.lng.plus(1)", "Long"); assertType("1.long.plus(1)", "Long");
assertType("1.plus(1.dbl)", "Double"); assertType("1.plus(1.double)", "Double");
assertType("1.plus(1.flt)", "Float"); assertType("1.plus(1.float)", "Float");
assertType("1.plus(1.lng)", "Long"); assertType("1.plus(1.long)", "Long");
assertType("1.plus(1)", "Int"); assertType("1.plus(1)", "Int");
assertType("'1'.plus(1.dbl)", "Double"); assertType("'1'.plus(1.double)", "Double");
assertType("'1'.plus(1.flt)", "Float"); assertType("'1'.plus(1.float)", "Float");
assertType("'1'.plus(1.lng)", "Long"); assertType("'1'.plus(1.long)", "Long");
assertType("'1'.plus(1)", "Int"); assertType("'1'.plus(1)", "Int");
assertType("'1'.minus('1')", "Int"); // Plus is not available for char assertType("'1'.minus('1')", "Int"); // Plus is not available for char
assertType("(1:Short).plus(1.dbl)", "Double"); assertType("(1:Short).plus(1.double)", "Double");
assertType("(1:Short).plus(1.flt)", "Float"); assertType("(1:Short).plus(1.float)", "Float");
assertType("(1:Short).plus(1.lng)", "Long"); assertType("(1:Short).plus(1.long)", "Long");
assertType("(1:Short).plus(1)", "Int"); assertType("(1:Short).plus(1)", "Int");
assertType("(1:Short).plus(1:Short)", "Int"); assertType("(1:Short).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1.dbl)", "Double"); assertType("(1:Byte).plus(1.double)", "Double");
assertType("(1:Byte).plus(1.flt)", "Float"); assertType("(1:Byte).plus(1.float)", "Float");
assertType("(1:Byte).plus(1.lng)", "Long"); assertType("(1:Byte).plus(1.long)", "Long");
assertType("(1:Byte).plus(1)", "Int"); assertType("(1:Byte).plus(1)", "Int");
assertType("(1:Byte).plus(1:Short)", "Int"); assertType("(1:Byte).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1:Byte)", "Int"); assertType("(1:Byte).plus(1:Byte)", "Int");
assertType("\"1\".plus(1.dbl)", "String"); assertType("\"1\".plus(1.double)", "String");
assertType("\"1\".plus(1.flt)", "String"); assertType("\"1\".plus(1.float)", "String");
assertType("\"1\".plus(1.lng)", "String"); assertType("\"1\".plus(1.long)", "String");
assertType("\"1\".plus(1)", "String"); assertType("\"1\".plus(1)", "String");
assertType("\"1\".plus('1')", "String"); assertType("\"1\".plus('1')", "String");
} }
@@ -8,8 +8,8 @@ fun main(args : Array<String>) {
// val MILLIS_PER_DAY_ : Long = 24 * 60 * 60 * 1000 // val MILLIS_PER_DAY_ : Long = 24 * 60 * 60 * 1000
// Solution: // Solution:
val MICROS_PER_DAY : Long = 24.lng * 60 * 60 * 1000 * 1000; val MICROS_PER_DAY : Long = 24.long * 60 * 60 * 1000 * 1000;
val MILLIS_PER_DAY : Long = 24.lng * 60 * 60 * 1000 val MILLIS_PER_DAY : Long = 24.long * 60 * 60 * 1000
println(MICROS_PER_DAY / MILLIS_PER_DAY) println(MICROS_PER_DAY / MILLIS_PER_DAY)
} }
@@ -3,8 +3,8 @@ namespace long.division.solution
import std.io.* import std.io.*
fun main(args : Array<String>) { fun main(args : Array<String>) {
val MICROS_PER_DAY : Long = 24.lng * 60 * 60 * 1000 * 1000; val MICROS_PER_DAY : Long = 24.long * 60 * 60 * 1000 * 1000;
val MILLIS_PER_DAY : Long = 24.lng * 60 * 60 * 1000 val MILLIS_PER_DAY : Long = 24.long * 60 * 60 * 1000
println(MICROS_PER_DAY / MILLIS_PER_DAY) println(MICROS_PER_DAY / MILLIS_PER_DAY)
} }
@@ -7,5 +7,5 @@ fun main(args : Array<String>) {
// println(12345 + 5432l) // println(12345 + 5432l)
// Correct syntax: // Correct syntax:
println(12345 + 5432.lng) println(12345 + 5432.long)
} }
@@ -3,6 +3,6 @@ namespace multicast
import std.io.* import std.io.*
fun main(args : Array<String>) { fun main(args : Array<String>) {
println(-1.byt.chr.int) println(-1.byte.char.int)
println((-1).byt.chr.int) println((-1).byte.char.int)
} }
@@ -5,6 +5,6 @@ import std.*
fun main(args : Array<String>) { fun main(args : Array<String>) {
// Note: \u000A is Unicode representation of linefeed (LF) // Note: \u000A is Unicode representation of linefeed (LF)
val c : Char = 0x000A .chr; val c : Char = 0x000A .char;
println(c); println(c);
} }
@@ -5,12 +5,12 @@ import std.io.*
fun main(args : Array<String>) { fun main(args : Array<String>) {
// for (b : Byte in Byte.MIN_VALUE..Byte.MAX_VALUE) { // for (b : Byte in Byte.MIN_VALUE..Byte.MAX_VALUE) {
// // Problematic code does not compile // // Problematic code does not compile
// if (b == 0x90 .byt) // if (b == 0x90 .byte)
// println("joy") // println("joy")
// } // }
for (b : Byte in Byte.MIN_VALUE to Byte.MAX_VALUE) { for (b : Byte in Byte.MIN_VALUE to Byte.MAX_VALUE) {
// Problematic code does not compile // Problematic code does not compile
if (b == 0x90 .byt) if (b == 0x90 .byte)
println("joy") println("joy")
} }
} }
@@ -3,8 +3,8 @@ namespace ghost.of.looper
import std.io.* import std.io.*
fun main(args : Array<String>) { fun main(args : Array<String>) {
var i : Short = -1.sht var i : Short = -1.short
while (i != 1.sht) while (i != 1.short)
// Lots of magic made explicit: // Lots of magic made explicit:
i = (i.int ushr 1).sht i = (i.int ushr 1).short
} }
+1 -1
View File
@@ -31,7 +31,7 @@ internal object RefreshQueue {
} }
} }
fixedRateTimer(daemon=true, name="refresher timer", period=5000.lng) { fixedRateTimer(daemon=true, name="refresher timer", period=5000.long) {
scheduleRefresh(FileSystem.watchedDirectories) scheduleRefresh(FileSystem.watchedDirectories)
} }
} }
+1 -1
View File
@@ -4,7 +4,7 @@ class Point(val x: Int, val y: Int) {
fun distanceTo(other: Point): Double { fun distanceTo(other: Point): Double {
val dx = x - other.x val dx = x - other.x
val dy = y - other.y val dy = y - other.y
return Math.sqrt((dx*dx + dy*dy).dbl) return Math.sqrt((dx*dx + dy*dy).double)
} }
} }
+1 -1
View File
@@ -167,7 +167,7 @@ abstract class Actor(protected val executor: Executor, val fair: Boolean = false
val messagesSent = AtomicLong() val messagesSent = AtomicLong()
val messagesProcessed = AtomicLong() val messagesProcessed = AtomicLong()
val timer = fixedRateTimer(daemon=true, period=5000.lng) { val timer = fixedRateTimer(daemon=true, period=5000.long) {
val sent = messagesSent.get() val sent = messagesSent.get()
val received = messagesProcessed.get() val received = messagesProcessed.get()
println("Actors stat: Sent: $sent Processed: $received Pending: ${sent-received}") println("Actors stat: Sent: $sent Processed: $received Pending: ${sent-received}")
+4 -4
View File
@@ -7,11 +7,11 @@ import java.util.LinkedList
class StatCalculator() : Actor(Executors.newSingleThreadExecutor().sure()) { class StatCalculator() : Actor(Executors.newSingleThreadExecutor().sure()) {
val list = LinkedList<Long> () val list = LinkedList<Long> ()
var average = 0.lng var average = 0.long
var sum = 0.lng var sum = 0.long
var cnt = 0.lng var cnt = 0.long
val timer = fixedRateTimer(period=2000.lng, daemon=true) { val timer = fixedRateTimer(period=2000.long, daemon=true) {
this@StatCalculator post "print" this@StatCalculator post "print"
} }
+1 -1
View File
@@ -14,7 +14,7 @@ class StockServer(val numberOfShards : Int) : Actor(Executors.newFixedThreadPool
private val shards = Array<StockServerShard> (numberOfShards, { (i: Int) -> StockServerShard(statCalculator, executor) }) private val shards = Array<StockServerShard> (numberOfShards, { (i: Int) -> StockServerShard(statCalculator, executor) })
private val timer = fixedRateTimer(period=1000.lng, daemon=true) { private val timer = fixedRateTimer(period=1000.long, daemon=true) {
for(s in shards) for(s in shards)
s post StockMessage.UpdateModel s post StockMessage.UpdateModel
} }
@@ -37,8 +37,8 @@ fun spectralnormGame(n: Int) : Double {
Approximate (u, v, tmp, r1, r2) Approximate (u, v, tmp, r1, r2)
}) })
var vBv = 0.dbl var vBv = 0.double
var vv = 0.dbl; var vv = 0.double;
for (i in 0..nthread-1) { for (i in 0..nthread-1) {
try { try {
ap[i].join (); ap[i].join ();
@@ -100,7 +100,7 @@ class Approximate(val u: DoubleArray, val v: DoubleArray, val _tmp: DoubleArray,
{ {
for (i in rbegin..rend) for (i in rbegin..rend)
{ {
var sum = 0.dbl var sum = 0.double
for (j in v.indices) for (j in v.indices)
sum += eval_A (j, i) * v[j]; sum += eval_A (j, i) * v[j];
+3 -3
View File
@@ -144,7 +144,7 @@ fun computeLast(allButLast : String) : Char {
} }
var remainder = sum % 10 var remainder = sum % 10
return if (remainder == 0) '0' else ('0' + (10 - remainder)).chr return if (remainder == 0) '0' else ('0' + (10 - remainder)).char
} }
fun computeLast(allButLast : CharSequence) : Char = computeLast(allButLast.toString().sure()) fun computeLast(allButLast : CharSequence) : Char = computeLast(allButLast.toString().sure())
@@ -155,12 +155,12 @@ fun setRandomDigits(builder : StringBuilder, start : Int, end : Int) {
} }
/** Generates a random digit. */ /** Generates a random digit. */
fun randomDigit() : Char = ('0' + random.nextInt(10)).chr fun randomDigit() : Char = ('0' + random.nextInt(10)).char
fun nonDigits() : String { fun nonDigits() : String {
val nonDigits = StringBuilder() val nonDigits = StringBuilder()
for (i in 0..999) for (i in 0..999)
nonDigits.append((random.nextInt(68) + ':').chr) nonDigits.append((random.nextInt(68) + ':').char)
return nonDigits.toString().sure() return nonDigits.toString().sure()
} }
@@ -16,7 +16,7 @@ fun bbb() {
fun foo(<warning>expr</warning>: StringBuilder): Int { fun foo(<warning>expr</warning>: StringBuilder): Int {
val c = 'a' val c = 'a'
when(c) { when(c) {
0.chr -> throw Exception("zero") 0.char -> throw Exception("zero")
else -> throw Exception("nonzero" + c) else -> throw Exception("nonzero" + c)
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@
get() : Int = 1 get() : Int = 1
set(value : <error>Long</error>) { set(value : <error>Long</error>) {
$x = value.int $x = value.int
$x = <error>1.lng</error> $x = <error>1.long</error>
} }
val xx : Int = <error>1 + x</error> val xx : Int = <error>1 + x</error>
+1
View File
@@ -8,6 +8,7 @@
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="intellij-core" level="project" /> <orderEntry type="library" scope="PROVIDED" name="intellij-core" level="project" />
<orderEntry type="module" module-name="frontend" />
</component> </component>
</module> </module>
+18 -16
View File
@@ -26,12 +26,14 @@ import org.jetbrains.jet.j2k.ast.Class;
import org.jetbrains.jet.j2k.ast.Enum; import org.jetbrains.jet.j2k.ast.Enum;
import org.jetbrains.jet.j2k.util.AstUtil; import org.jetbrains.jet.j2k.util.AstUtil;
import org.jetbrains.jet.j2k.visitors.*; import org.jetbrains.jet.j2k.visitors.*;
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
import java.util.*; import java.util.*;
import static org.jetbrains.jet.j2k.ConverterUtil.countWritingAccesses; import static org.jetbrains.jet.j2k.ConverterUtil.countWritingAccesses;
import static org.jetbrains.jet.j2k.ConverterUtil.createMainFunction; import static org.jetbrains.jet.j2k.ConverterUtil.createMainFunction;
import static org.jetbrains.jet.j2k.visitors.TypeVisitor.*; import static org.jetbrains.jet.j2k.visitors.TypeVisitor.*;
import static org.jetbrains.jet.lang.types.expressions.OperatorConventions.*;
/** /**
* @author ignatov * @author ignatov
@@ -328,8 +330,8 @@ public class Converter {
final String typeToKotlin = f.getType().toKotlin(); final String typeToKotlin = f.getType().toKotlin();
if (typeToKotlin.equals("Boolean")) return "false"; if (typeToKotlin.equals("Boolean")) return "false";
if (typeToKotlin.equals("Char")) return "' '"; if (typeToKotlin.equals("Char")) return "' '";
if (typeToKotlin.equals("Double")) return "0.dbl"; if (typeToKotlin.equals("Double")) return "0." + OperatorConventions.DOUBLE;
if (typeToKotlin.equals("Float")) return "0.flt"; if (typeToKotlin.equals("Float")) return "0." + OperatorConventions.FLOAT;
return "0"; return "0";
} }
} }
@@ -780,21 +782,21 @@ public class Converter {
@NotNull @NotNull
private static String getPrimitiveTypeConversion(@NotNull String type) { private static String getPrimitiveTypeConversion(@NotNull String type) {
Map<String, String> conversions = new HashMap<String, String>(); Map<String, String> conversions = new HashMap<String, String>();
conversions.put("byte", "byt"); conversions.put("byte", BYTE);
conversions.put("short", "sht"); conversions.put("short", SHORT);
conversions.put("int", "int"); conversions.put("int", INT);
conversions.put("long", "lng"); conversions.put("long", LONG);
conversions.put("float", "flt"); conversions.put("float", FLOAT);
conversions.put("double", "dbl"); conversions.put("double", DOUBLE);
conversions.put("char", "chr"); conversions.put("char", CHAR);
conversions.put(JAVA_LANG_BYTE, "byt"); conversions.put(JAVA_LANG_BYTE, BYTE);
conversions.put(JAVA_LANG_SHORT, "sht"); conversions.put(JAVA_LANG_SHORT, SHORT);
conversions.put(JAVA_LANG_INTEGER, "int"); conversions.put(JAVA_LANG_INTEGER, INT);
conversions.put(JAVA_LANG_LONG, "lng"); conversions.put(JAVA_LANG_LONG, LONG);
conversions.put(JAVA_LANG_FLOAT, "flt"); conversions.put(JAVA_LANG_FLOAT, FLOAT);
conversions.put(JAVA_LANG_DOUBLE, "dbl"); conversions.put(JAVA_LANG_DOUBLE, DOUBLE);
conversions.put(JAVA_LANG_CHARACTER, "chr"); conversions.put(JAVA_LANG_CHARACTER, CHAR);
if (conversions.containsKey(type)) { if (conversions.containsKey(type)) {
return "." + conversions.get(type); return "." + conversions.get(type);
@@ -18,6 +18,7 @@ package org.jetbrains.jet.j2k.ast;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.j2k.util.AstUtil; import org.jetbrains.jet.j2k.util.AstUtil;
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
import java.util.*; import java.util.*;
@@ -75,8 +76,8 @@ public class ArrayInitializerExpression extends Expression {
@NotNull @NotNull
private static String getConversion(@NotNull final String afterReplace) { private static String getConversion(@NotNull final String afterReplace) {
if (afterReplace.contains("double")) return DOT + "dbl"; if (afterReplace.contains("double")) return DOT + OperatorConventions.DOUBLE;
if (afterReplace.contains("float")) return DOT + "flt"; if (afterReplace.contains("float")) return DOT + OperatorConventions.FLOAT;
return ""; return "";
} }
@@ -208,7 +208,7 @@ public class ExpressionVisitor extends StatementVisitor {
text = text.replace("D", "").replace("d", ""); text = text.replace("D", "").replace("d", "");
} }
if (canonicalTypeStr.equals("float") || canonicalTypeStr.equals(JAVA_LANG_FLOAT)) { if (canonicalTypeStr.equals("float") || canonicalTypeStr.equals(JAVA_LANG_FLOAT)) {
text = text.replace("F", "").replace("f", "") + "." + "flt"; text = text.replace("F", "").replace("f", "") + "." + "float";
} }
if (canonicalTypeStr.equals("long") || canonicalTypeStr.equals(JAVA_LANG_LONG)) { if (canonicalTypeStr.equals("long") || canonicalTypeStr.equals(JAVA_LANG_LONG)) {
text = text.replace("L", "").replace("l", ""); text = text.replace("L", "").replace("l", "");
@@ -1,4 +1,4 @@
var a : Double = 0 var a : Double = 0
var b : Double = 0 var b : Double = 0
var c : Double = 0 var c : Double = 0
var ds : DoubleArray? = doubleArray((a).dbl, (b).dbl, (c).dbl) var ds : DoubleArray? = doubleArray((a).double, (b).double, (c).double)
@@ -1,8 +1,8 @@
public open class Test(_myName : String?, _a : Boolean, _b : Double, _c : Float, _d : Long, _e : Int, _f : Short, _g : Char) { public open class Test(_myName : String?, _a : Boolean, _b : Double, _c : Float, _d : Long, _e : Int, _f : Short, _g : Char) {
private val myName : String? private val myName : String?
private var a : Boolean = false private var a : Boolean = false
private var b : Double = 0.dbl private var b : Double = 0.double
private var c : Float = 0.flt private var c : Float = 0.float
private var d : Long = 0 private var d : Long = 0
private var e : Int = 0 private var e : Int = 0
private var f : Short = 0 private var f : Short = 0
@@ -19,11 +19,11 @@ g = _g
} }
class object { class object {
open public fun init() : Test { open public fun init() : Test {
val __ = Test(null, false, 0.dbl, 0.flt, 0, 0, 0, ' ') val __ = Test(null, false, 0.double, 0.float, 0, 0, 0, ' ')
return __ return __
} }
open public fun init(name : String?) : Test { open public fun init(name : String?) : Test {
val __ = Test(foo(name), false, 0.dbl, 0.flt, 0, 0, 0, ' ') val __ = Test(foo(name), false, 0.double, 0.flat, 0, 0, 0, ' ')
return __ return __
} }
open fun foo(n : String?) : String? { open fun foo(n : String?) : String? {
@@ -8,5 +8,5 @@ var myContainer : Container? = Container()
} }
} }
open class Test() { open class Test() {
var b : Byte = One.myContainer?.myInt.sure().byt var b : Byte = One.myContainer?.myInt.sure().byte
} }
+1 -1
View File
@@ -9,6 +9,6 @@ var myContainer : Container? = Container()
} }
open class Test() { open class Test() {
open fun test() : Unit { open fun test() : Unit {
var b : Byte = One.myContainer?.myInt.sure().byt var b : Byte = One.myContainer?.myInt.sure().byte
} }
} }
@@ -2,17 +2,17 @@ open class Test() {
open fun test() : Unit { open fun test() : Unit {
var l1 : Long = 10 var l1 : Long = 10
var d1 : Double = 10.0 var d1 : Double = 10.0
var f1 : Float = 10.0.flt var f1 : Float = 10.0.float
var l2 : Long = 10 var l2 : Long = 10
var d2 : Double = 10.0 var d2 : Double = 10.0
var f2 : Float = 10.0.flt var f2 : Float = 10.0.float
} }
open fun testBoxed() : Unit { open fun testBoxed() : Unit {
var l1 : Long? = 10 var l1 : Long? = 10
var d1 : Double? = 10.0 var d1 : Double? = 10.0
var f1 : Float? = 10.0.flt var f1 : Float? = 10.0.float
var l2 : Long? = 10 var l2 : Long? = 10
var d2 : Double? = 10.0 var d2 : Double? = 10.0
var f2 : Float? = 10.0.flt var f2 : Float? = 10.0.float
} }
} }
+2 -2
View File
@@ -49,7 +49,7 @@ private val stdin : BufferedReader = BufferedReader(InputStreamReader(object : I
} }
override fun skip(n: Long): Long { override fun skip(n: Long): Long {
return System.`in`?.skip(n) ?: -1.lng return System.`in`?.skip(n) ?: -1.long
} }
override fun available(): Int { override fun available(): Int {
@@ -98,7 +98,7 @@ fun InputStream.iterator() : ByteIterator =
override val hasNext : Boolean override val hasNext : Boolean
get() = available() > 0 get() = available() > 0
override fun nextByte() = read().byt override fun nextByte() = read().byte
} }
inline fun InputStream.buffered(bufferSize: Int) = BufferedInputStream(this, bufferSize) inline fun InputStream.buffered(bufferSize: Int) = BufferedInputStream(this, bufferSize)
+2 -2
View File
@@ -40,7 +40,7 @@ fun Timer.scheduleAtFixedRate(time: Date, period: Long, action: TimerTask.()->Un
return task return task
} }
fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.lng, period: Long, action: TimerTask.()->Unit) : Timer { fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.long, period: Long, action: TimerTask.()->Unit) : Timer {
val timer = if(name == null) Timer(daemon) else Timer(name, daemon) val timer = if(name == null) Timer(daemon) else Timer(name, daemon)
timer.schedule(initialDelay, period, action) timer.schedule(initialDelay, period, action)
return timer return timer
@@ -52,7 +52,7 @@ fun timer(name: String? = null, daemon: Boolean = false, startAt: Date, period:
return timer return timer
} }
fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.lng, period: Long, action: TimerTask.()->Unit) : Timer { fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.long, period: Long, action: TimerTask.()->Unit) : Timer {
val timer = if(name == null) Timer(daemon) else Timer(name, daemon) val timer = if(name == null) Timer(daemon) else Timer(name, daemon)
timer.scheduleAtFixedRate(initialDelay, period, action) timer.scheduleAtFixedRate(initialDelay, period, action)
return timer return timer
+1 -1
View File
@@ -24,7 +24,7 @@ class OldStdlibTest() : TestSupport() {
val x = ByteArray (10) val x = ByteArray (10)
for(index in 0..9) { for(index in 0..9) {
x [index] = index.byt x [index] = index.byte
} }
for(b in x.inputStream) { for(b in x.inputStream) {