dbl -> toDouble

This commit is contained in:
Alex Tkachman
2012-02-22 13:14:41 +02:00
parent 18990e2c1b
commit 53bba59a4f
79 changed files with 335 additions and 298 deletions
@@ -76,9 +76,9 @@ public class IntrinsicMethods {
List<String> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
for (String method : primitiveCastMethods) {
declareIntrinsicProperty("Number", method, NUMBER_CAST);
declareIntrinsicFunction("Number", method, 0, NUMBER_CAST, true);
for (String type : PRIMITIVE_NUMBER_TYPES) {
declareIntrinsicProperty(type, method, NUMBER_CAST);
declareIntrinsicFunction(type, method, 0, NUMBER_CAST, true);
}
}
+7 -7
View File
@@ -1,13 +1,13 @@
package jet
abstract class Number : Hashable {
abstract val double : Double
abstract val float : Float
abstract val long : Long
abstract val int : Int
abstract val char : Char
abstract val short : Short
abstract val byte : Byte
abstract fun toDouble() : Double
abstract fun toFloat() : Float
abstract fun toLong() : Long
abstract fun toInt() : Int
abstract fun toChar() : Char
abstract fun toShort() : Short
abstract fun toByte() : Byte
// fun equals(other : Double) : Boolean
// fun equals(other : Float) : Boolean
// fun equals(other : Long) : Boolean
@@ -59,6 +59,6 @@ public class ByteValue implements CompileTimeConstant<Byte> {
@Override
public String toString() {
return value + ".byte";
return value + ".toByte()";
}
}
@@ -49,6 +49,6 @@ public class DoubleValue implements CompileTimeConstant<Double> {
@Override
public String toString() {
return value + ".double";
return value + ".toDouble()";
}
}
@@ -49,6 +49,6 @@ public class FloatValue implements CompileTimeConstant<Float> {
@Override
public String toString() {
return value + ".float";
return value + ".toFloat()";
}
}
@@ -59,7 +59,7 @@ public class IntValue implements CompileTimeConstant<Integer> {
@Override
public String toString() {
return value + ".int";
return value + ".toInt()";
}
@Override
@@ -58,6 +58,6 @@ public class LongValue implements CompileTimeConstant<Long> {
@Override
public String toString() {
return value + ".long";
return value + ".toLong()";
}
}
@@ -59,7 +59,7 @@ public class ShortValue implements CompileTimeConstant<Short> {
@Override
public String toString() {
return value + ".short";
return value + ".toShort()";
}
}
@@ -36,13 +36,13 @@ public class 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 String DOUBLE = "toDouble";
public static final String FLOAT = "toFloat";
public static final String LONG = "toLong";
public static final String INT = "toInt";
public static final String CHAR = "toChar";
public static final String SHORT = "toShort";
public static final String BYTE = "toByte";
public static final ImmutableSet<String> NUMBER_CONVERSIONS = ImmutableSet.of(
+6 -5
View File
@@ -15,7 +15,7 @@ sink:
fun f(a : Boolean) : Unit {
1
a
2.long
2.toLong()
foo(a, 3)
genfun<Any>()
flfun {1}
@@ -36,10 +36,11 @@ l0:
w(a) NEXT:[r(1)] PREV:[v(a : Boolean)]
r(1) NEXT:[r(a)] PREV:[w(a)]
r(a) NEXT:[r(2)] PREV:[r(1)]
r(2) NEXT:[r(long)] PREV:[r(a)]
r(long) NEXT:[r(2.long)] PREV:[r(2)]
r(2.long) NEXT:[r(a)] PREV:[r(long)]
r(a) NEXT:[r(3)] PREV:[r(2.long)]
r(2) NEXT:[r(toLong)] PREV:[r(a)]
r(toLong) NEXT:[r(toLong())] PREV:[r(2)]
r(toLong()) NEXT:[r(2.toLong())] PREV:[r(toLong)]
r(2.toLong()) NEXT:[r(a)] PREV:[r(toLong())]
r(a) NEXT:[r(3)] PREV:[r(2.toLong())]
r(3) NEXT:[r(foo)] PREV:[r(a)]
r(foo) NEXT:[r(foo(a, 3))] PREV:[r(3)]
r(foo(a, 3)) NEXT:[r(genfun)] PREV:[r(foo)]
+1 -1
View File
@@ -1,7 +1,7 @@
fun f(a : Boolean) : Unit {
1
a
2.long
2.toLong()
foo(a, 3)
genfun<Any>()
flfun {1}
@@ -1,5 +1,5 @@
fun StringBuilder.takeFirst(): Char {
if (this.length() == 0) return 0.char
if (this.length() == 0) return 0.toChar()
val c = this.charAt(0)
this.deleteCharAt(0)
return c
@@ -8,7 +8,7 @@ fun StringBuilder.takeFirst(): Char {
fun foo(expr: StringBuilder): Int {
val c = expr.takeFirst()
when(c) {
0.char -> throw Exception("zero")
0.toChar() -> throw Exception("zero")
else -> throw Exception("nonzero" + c)
}
}
+12 -12
View File
@@ -62,43 +62,43 @@ fun t3() : Boolean {
}
fun t4() : Boolean {
var x = 100.float
var x = 100.toFloat()
val y = x + 22
val foo = {
x = x + 200.float + y
x = x + 200.toFloat() + y
x += 18
#()
}
foo()
System.out?.println(x)
return x == 440.float
return x == 440.toFloat()
}
fun t5() : Boolean {
var x = 100.double
var x = 100.toDouble()
val y = x + 22
val foo = {
x = x + 200.double + y
x = x + 200.toDouble() + y
x -= 22
#()
}
foo()
System.out?.println(x)
return x == 400.double
return x == 400.toDouble()
}
fun t6() : Boolean {
var x = 20.byte
var x = 20.toByte()
val y = x + 22
val foo = {
x = (x + 20.byte + y).byte
x = (x + 20.toByte() + y).toByte()
x += 2
x--
#()
}
foo()
System.out?.println(x)
return x == 83.byte
return x == 83.toByte()
}
fun t7() : Boolean {
@@ -113,17 +113,17 @@ fun t7() : Boolean {
}
fun t8() : Boolean {
var x = 20.short
var x = 20.toShort()
val foo = {
val bar = {
x = 30.short
x = 30.toShort()
#()
}
bar()
#()
}
foo()
return x == 30.short
return x == 30.toShort()
}
fun t9(var x: Int) : Boolean {
+10 -10
View File
@@ -3,24 +3,24 @@ class A() {
var xin : Int? = 0
var xinn : Int? = null
var xl = 0.long
var xln : Long? = 0.long
var xl = 0.toLong()
var xln : Long? = 0.toLong()
var xlnn : Long? = null
var xb = 0.byte
var xbn : Byte? = 0.byte
var xb = 0.toByte()
var xbn : Byte? = 0.toByte()
var xbnn : Byte? = null
var xf = 0.float
var xfn : Float? = 0.float
var xf = 0.toFloat()
var xfn : Float? = 0.toFloat()
var xfnn : Float? = null
var xd = 0.double
var xdn : Double? = 0.double
var xd = 0.toDouble()
var xdn : Double? = 0.toDouble()
var xdnn : Double? = null
var xs = 0.short
var xsn : Short? = 0.short
var xs = 0.toShort()
var xsn : Short? = 0.toShort()
var xsnn : Short? = null
}
@@ -27,7 +27,7 @@ class Luhny() {
// Commented for KT-621
// when (it) {
// .isDigit() => digits.addLast(it.int - '0'.int)
// .isDigit() => digits.addLast(it.toInt() - '0'.toInt())
// ' ', '-' => {}
// else => {
// printAll()
@@ -36,7 +36,7 @@ class Luhny() {
// }
if (it.isDigit()) {
digits.addLast(it.int - '0'.int)
digits.addLast(it.toInt() - '0'.toInt())
} else if (it == ' ' || it == '-') {
} else {
printAll()
@@ -123,6 +123,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
body(i.char)
body(i.toChar())
} while(true)
}
@@ -25,13 +25,13 @@ class Luhny() {
// Commented for KT-621
// when (it) {
// .isDigit() => digits.addLast(it.int - '0'.int)
// .isDigit() => digits.addLast(it.toInt() - '0'.toInt())
// ' ', '-' => {}
// else => printAll()
// }
if (it.isDigit()) {
digits.addLast(it.int - '0'.int)
digits.addLast(it.toInt() - '0'.toInt())
} else if (it == ' ' || it == '-') {
} else {
printAll()
@@ -102,6 +102,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
body(i.char)
body(i.toChar())
} while(true)
}
@@ -26,7 +26,7 @@ class Luhny() {
// Commented for KT-621
// when (it) {
// .isDigit() => digits.push(it.int - '0'.int)
// .isDigit() => digits.push(it.toInt() - '0'.toInt())
// ' ', '-' => {}
// else => {
// printAll()
@@ -35,7 +35,7 @@ class Luhny() {
// }
if (it.isDigit()) {
digits.push(it.int - '0'.int)
digits.push(it.toInt() - '0'.toInt())
} else if (it == ' ' || it == '-') {
} else {
printAll()
@@ -139,6 +139,6 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
body(i.char)
body(i.toChar())
} while(true)
}
@@ -2,9 +2,9 @@ package name
class Test() {
var i = 5
val ten = 10.long
val ten = 10.toLong()
fun Long.t() = this.int + i++ + ++i
fun Long.t() = this.toInt() + i++ + ++i
fun tt() = ten.t()
}
@@ -5,5 +5,5 @@ fun Long?.inv() : Long = this.sure().inv()
fun box() : String {
val x : Long? = 10
System.out?.println(x.inv())
return if(x.inv() == -11.long) "OK" else "fail"
return if(x.inv() == -11.toLong()) "OK" else "fail"
}
@@ -1,11 +1,11 @@
fun box() : String {
System.out?.println(System.out?.println(10.float..11.float))
System.out?.println(System.out?.println(10.toFloat()..11.toFloat()))
for(f in 10.float..11.float step 0.3.float) {
for(f in 10.toFloat()..11.toFloat() step 0.3.toFloat()) {
System.out?.println(f)
}
for(f in 10.double..11.double step 0.3.double) {
for(f in 10.toDouble()..11.toDouble() step 0.3.toDouble()) {
System.out?.println(f)
}
@@ -9,22 +9,22 @@ fun box() : String {
if(r4.end != 5 || r4.isReversed || r4.size != 6) return "fail"
val r5 = ByteRange(1, 4)
if(r5.end != 4.byte || r5.isReversed || r5.size != 4) return "fail"
if(r5.end != 4.toByte() || r5.isReversed || r5.size != 4) return "fail"
val r7 = -(0.byte..5.byte)
if(r7.start != 5.byte || r7.end != 0.byte || !r7.isReversed) return "fail"
val r7 = -(0.toByte()..5.toByte())
if(r7.start != 5.toByte() || r7.end != 0.toByte() || !r7.isReversed) return "fail"
val r9 = -r7
if(r9.end != 5.byte || r9.isReversed) return "fail"
if(r9.end != 5.toByte() || r9.isReversed) return "fail"
val r10 = ShortRange(1, 4)
if(r10.end != 4.short || r10.isReversed || r10.size != 4) return "fail"
if(r10.end != 4.toShort() || r10.isReversed || r10.size != 4) return "fail"
val r12 = -(0.short..5.short)
if(r12.start != 5.short || r12.end != 0.short || !r12.isReversed) return "fail"
val r12 = -(0.toShort()..5.toShort())
if(r12.start != 5.toShort() || r12.end != 0.toShort() || !r12.isReversed) return "fail"
val r13 = -r12
if(r13.end != 5.short || r13.isReversed) return "fail"
if(r13.end != 5.toShort() || r13.isReversed) return "fail"
val r14 = CharRange('a', 4)
if(r14.end != 'd' || r14.isReversed || r14.size != 4) return "fail"
@@ -1,11 +1,11 @@
fun box() : String {
val fps : Double = 1.double
val fps : Double = 1.toDouble()
var mspf : Long
{
if ((fps.int == 0))
if ((fps.toInt() == 0))
mspf = 0
else
mspf = (((1000.0 / fps)).long)
mspf = (((1000.0 / fps)).toLong())
}
return "OK"
}
@@ -1,5 +1,5 @@
val _0 : Double = 0.0
val _0dbl : Double = 0.double
val _0dbl : Double = 0.toDouble()
fun box() : String {
if(_0 != _0dbl) return "fail"
@@ -8,7 +8,7 @@ public open class PerfectNumberFinder() {
var factors : List<Int?>? = ArrayList<Int?>()
factors?.add(1)
factors?.add(number)
for (i in 2..(Math.sqrt((number).double) - 1).int)
for (i in 2..(Math.sqrt((number).toDouble()) - 1).toInt())
if (((number % i) == 0)) {
factors?.add(i)
if (((number / i) != i))
@@ -8,7 +8,7 @@ fun test1() : Boolean {
}
fun test2() : Boolean {
val r1 = 1.byte..10.byte
val r1 = 1.toByte()..10.toByte()
var s1 = 0
for(e in r1 step 2) {
s1 += e
@@ -17,21 +17,21 @@ fun test2() : Boolean {
}
fun test3() : Boolean {
val r1 = 1.byte..10.long
var s1 = 0.long
val r1 = 1.toByte()..10.toLong()
var s1 = 0.toLong()
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.long
return s1 == 25.toLong()
}
fun test4() : Boolean {
val r1 = 1.byte..10.short
var s1 = 0.short
val r1 = 1.toByte()..10.toShort()
var s1 = 0.toShort()
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.short
return s1 == 25.toShort()
}
fun test5() : Boolean {
+26 -26
View File
@@ -15,51 +15,51 @@ fun testInt () : String {
}
fun testByte () : String {
val r1 = 1.byte upto 4.byte
if(r1.end != 4.byte || r1.isReversed || r1.size != 4) return "byte upto fail"
val r1 = 1.toByte() upto 4.toByte()
if(r1.end != 4.toByte() || r1.isReversed || r1.size != 4) return "byte upto fail"
val r2 = 4.byte upto 1.byte
if(r2.start != 0.byte || r2.size != 0) return "byte negative upto fail"
val r2 = 4.toByte() upto 1.toByte()
if(r2.start != 0.toByte() || r2.size != 0) return "byte negative upto fail"
val r3 = 5.byte downto 0.byte
if(r3.start != 5.byte || r3.end != 0.byte || !r3.isReversed || r3.size != 6) return "byte downto fail"
val r3 = 5.toByte() downto 0.toByte()
if(r3.start != 5.toByte() || r3.end != 0.toByte() || !r3.isReversed || r3.size != 6) return "byte downto fail"
val r4 = 5.byte downto 6.byte
if(r4.start != 0.byte || r4.end != 0.byte || !r3.isReversed || r4.size != 0) return "byte negative downto fail"
val r4 = 5.toByte() downto 6.toByte()
if(r4.start != 0.toByte() || r4.end != 0.toByte() || !r3.isReversed || r4.size != 0) return "byte negative downto fail"
return "OK"
}
fun testShort () : String {
val r1 = 1.short upto 4.short
if(r1.end != 4.short || r1.isReversed || r1.size != 4) return "short upto fail"
val r1 = 1.toShort() upto 4.toShort()
if(r1.end != 4.toShort() || r1.isReversed || r1.size != 4) return "short upto fail"
val r2 = 4.short upto 1.short
if(r2.start != 0.short || r2.size != 0) return "short negative upto fail"
val r2 = 4.toShort() upto 1.toShort()
if(r2.start != 0.toShort() || r2.size != 0) return "short negative upto fail"
val r3 = 5.short downto 0.short
if(r3.start != 5.short || r3.end != 0.short || !r3.isReversed || r3.size != 6) return "short downto fail"
val r3 = 5.toShort() downto 0.toShort()
if(r3.start != 5.toShort() || r3.end != 0.toShort() || !r3.isReversed || r3.size != 6) return "short downto fail"
val r4 = 5.short downto 6.short
if(r4.start != 0.short || r4.end != 0.short || !r3.isReversed || r4.size != 0) return "short negative downto fail"
val r4 = 5.toShort() downto 6.toShort()
if(r4.start != 0.toShort() || r4.end != 0.toShort() || !r3.isReversed || r4.size != 0) return "short negative downto fail"
return "OK"
}
fun testLong () : String {
val r1 = 1.long upto 4.long
if(r1.end != 4.long || r1.isReversed || r1.size != 4.long) return "long upto fail"
val r1 = 1.toLong() upto 4.toLong()
if(r1.end != 4.toLong() || r1.isReversed || r1.size != 4.toLong()) return "long upto fail"
val r2 = 4.long upto 1.long
if(r2.start != 0.long || r2.size != 0.long) return "short negative long fail"
val r2 = 4.toLong() upto 1.toLong()
if(r2.start != 0.toLong() || r2.size != 0.toLong()) return "short negative long fail"
val r3 = 5.long downto 0.long
if(r3.start != 5.long || r3.end != 0.long || !r3.isReversed || r3.size != 6.long) return "long downto fail"
val r3 = 5.toLong() downto 0.toLong()
if(r3.start != 5.toLong() || r3.end != 0.toLong() || !r3.isReversed || r3.size != 6.toLong()) return "long downto fail"
val r4 = 5.long downto 6.long
if(r4.start != 0.long || r4.end != 0.long || !r3.isReversed || r4.size != 0.long) return "long negative downto fail"
val r4 = 5.toLong() downto 6.toLong()
if(r4.start != 0.toLong() || r4.end != 0.toLong() || !r3.isReversed || r4.size != 0.toLong()) return "long negative downto fail"
return "OK"
}
@@ -70,13 +70,13 @@ fun testChar () : String {
if(r1.end != 'd' || r1.isReversed || r1.size != 4) return "char upto fail"
val r2 = 'd' upto 'a'
if(r2.start != 0.char || r2.size != 0) return "char negative long fail"
if(r2.start != 0.toChar() || r2.size != 0) return "char negative long fail"
val r3 = 'd' downto 'a'
if(r3.start != 'd' || r3.end != 'a' || !r3.isReversed || r3.size != 4) return "char downto fail"
val r4 = 'a' downto 'd'
if(r4.start != 0.char || r4.end != 0.char || !r3.isReversed || r4.size != 0) return "char negative downto fail"
if(r4.start != 0.toChar() || r4.end != 0.toChar() || !r3.isReversed || r4.size != 0) return "char negative downto fail"
return "OK"
}
@@ -18,8 +18,8 @@ abstract class B() : A {
override fun foo2() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> {
}
override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.double
override val <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>a1<!> = 1.double
override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.toDouble()
override val <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>a1<!> = 1.toDouble()
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><!>
@@ -21,7 +21,7 @@ fun bbb() {
fun foo(<!UNUSED_PARAMETER!>expr<!>: StringBuilder): Int {
val c = 'a'
when(c) {
0.char -> throw Exception("zero")
0.toChar() -> throw Exception("zero")
else -> throw Exception("nonzero" + c)
}
}
@@ -1,8 +1,8 @@
var x : Int = 1 + x
get() : Int = 1
set(value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) {
$x = value.int
$x = <!TYPE_MISMATCH!>1.long<!>
$x = value.toInt()
$x = <!TYPE_MISMATCH!>1.toLong()<!>
}
val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!>
@@ -23,5 +23,5 @@ fun test() {
fooi(1, 2, 3)
fool(1, 2, 3)
food(1.0, 2.0, 3.0)
foof(1.0.float, 2.0.float, 3.0.float)
foof(1.0.toFloat(), 2.0.toFloat(), 3.0.toFloat())
}
@@ -5,7 +5,7 @@ package kt1066
import java.util.Set
fun randomDigit() = 0.char
fun randomDigit() = 0.toChar()
fun foo(excluded: Set<Char>) {
var digit : Char
@@ -41,7 +41,7 @@ public class AnnotationGenTest extends CodegenTestCase {
public void testPropSetter() throws NoSuchFieldException, NoSuchMethodException {
loadText("var x = 0\n" +
"[Deprecated] set");
System.out.println(generateToText());
// System.out.println(generateToText());
Class aClass = generateNamespaceClass();
assertNull(aClass.getDeclaredMethod("getX").getAnnotation(Deprecated.class));
assertNotNull(aClass.getDeclaredMethod("setX", int.class).getAnnotation(Deprecated.class));
@@ -78,7 +78,7 @@ public class ArrayGenTest extends CodegenTestCase {
public void testIterator () throws Exception {
loadText("fun box() { val x = Array<Int>(5, { it } ).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }");
System.out.println(generateToText());
// System.out.println(generateToText());
Method foo = generateFunction();
foo.invoke(null);
}
@@ -285,9 +285,9 @@ public class ArrayGenTest extends CodegenTestCase {
public void testLongDouble () throws Exception {
loadText(
"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.get(index: Long) = this[index.int]");
"fun box() : Int { var l = IntArray(1); l[0.toLong()] = 4; l[0.toLong()] += 6; return l[0.toLong()];}\n" +
"fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem }\n" +
"fun IntArray.get(index: Long) = this[index.toInt()]");
// System.out.println(generateToText());
Method foo = generateFunction("box");
assertTrue((Integer)foo.invoke(null) == 10);
@@ -314,6 +314,6 @@ public class ArrayGenTest extends CodegenTestCase {
public void testNonNullArray() throws Exception {
blackBoxFile("classes/nonnullarray.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
}
@@ -38,7 +38,7 @@ public class ClassGenTest extends CodegenTestCase {
public void testArrayListInheritance() throws Exception {
loadFile("classes/inheritingFromArrayList.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
final Class aClass = loadClass("Foo", generateClassesInFile());
assertInstanceOf(aClass.newInstance(), List.class);
}
@@ -214,7 +214,7 @@ public class ClassGenTest extends CodegenTestCase {
public void testKt508 () throws Exception {
loadFile("regressions/kt508.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
blackBox();
}
@@ -48,7 +48,7 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
public void testShared() throws Exception {
blackBoxFile("extensionFunctions/shared.kt");
System.out.println(generateToText());
// System.out.println(generateToText());
}
public void testKt475() throws Exception {
@@ -377,7 +377,7 @@ public class NamespaceGenTest extends CodegenTestCase {
}
public void testArrayAugAssignLong() throws Exception {
loadText("fun foo(c: LongArray) { c[0] *= 2.long }");
loadText("fun foo(c: LongArray) { c[0] *= 2.toLong() }");
// System.out.println(generateToText());
final Method main = generateFunction();
long[] data = new long[] { 5 };
@@ -147,20 +147,20 @@ public class PrimitiveTypesTest extends CodegenTestCase {
}
public void testDoubleToInt() throws Exception {
loadText("fun foo(a: Double): Int = a.int");
loadText("fun foo(a: Double): Int = a.toInt()");
// System.out.println(generateToText());
final Method main = generateFunction();
assertEquals(1, main.invoke(null, 1.0));
}
public void testCastConstant() throws Exception {
loadText("fun foo(): Double = 1.double");
loadText("fun foo(): Double = 1.toDouble()");
final Method main = generateFunction();
assertEquals(1.0, main.invoke(null));
}
public void testCastOnStack() throws Exception {
loadText("fun foo(): Double = System.currentTimeMillis().double");
loadText("fun foo(): Double = System.currentTimeMillis().toDouble()");
final Method main = generateFunction();
double currentTimeMillis = (double) System.currentTimeMillis();
double result = (Double) main.invoke(null);
@@ -327,7 +327,7 @@ public class PrimitiveTypesTest extends CodegenTestCase {
}
public void testKt737() throws Exception {
loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.byte.compareTo(10.long) >= 0) \"fail\" else \"OK\"");
loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.toByte().compareTo(10.toLong()) >= 0) \"fail\" else \"OK\"");
assertEquals("OK", blackBox());
}
@@ -125,7 +125,7 @@ public class PropertyGenTest extends CodegenTestCase {
public void testAccessorsWithoutBody() throws Exception {
loadText("class AccessorsWithoutBody() { protected var foo: Int = 349\n get\n private set\n fun setter() { foo = 610; } } ");
System.out.println(generateToText());
// System.out.println(generateToText());
final Class aClass = loadImplementationClass(generateClassesInFile(), "AccessorsWithoutBody");
final Object instance = aClass.newInstance();
final Method getFoo = findMethodByName(aClass, "getFoo");
@@ -167,7 +167,7 @@ public class PropertyGenTest extends CodegenTestCase {
public void testVolatileProperty() throws Exception {
loadText("abstract class Foo { public volatile var x: String = \"\"; }");
System.out.println(generateToText());
// System.out.println(generateToText());
final ClassFileFactory codegens = generateClassesInFile();
final Class aClass = loadClass("Foo", codegens);
Field x = aClass.getDeclaredField("x");
@@ -104,7 +104,7 @@ public class StdlibTest extends CodegenTestCase {
public void testForInString() throws Exception {
loadText("fun foo() : Int { var sum = 0\n" +
" for(c in \"239\")\n" +
" sum += (c.int - '0'.int)\n" +
" sum += (c.toInt() - '0'.toInt())\n" +
" return sum" +
"}" );
final Method main = generateFunction();
@@ -19,6 +19,6 @@ package org.jetbrains.jet.codegen;
public class TupleGenTest extends CodegenTestCase {
public void testBasic() {
blackBoxFile("/tuples/basic.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
}
@@ -147,12 +147,12 @@ public class TypeInfoTest extends CodegenTestCase {
public void testInner() throws Exception {
blackBoxFile("typeInfo/inner.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
public void testInheritance() throws Exception {
blackBoxFile("typeInfo/inheritance.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
public void testkt1113() throws Exception {
@@ -58,7 +58,7 @@ public class VarArgTest extends CodegenTestCase {
}
public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException {
loadText("fun test() = testf(239.byte, 7.byte); fun testf(vararg ts: Byte?) = ts");
loadText("fun test() = testf(239.toByte(), 7.toByte()); fun testf(vararg ts: Byte?) = ts");
// System.out.println(generateToText());
final Method main = generateFunction("test");
Object res = main.invoke(null);
@@ -78,7 +78,7 @@ public class VarArgTest extends CodegenTestCase {
public void testArrayT () throws InvocationTargetException, IllegalAccessException {
loadText("fun test() = _array(2, 4); fun <T> _array(vararg elements : T) = elements");
System.out.println(generateToText());
// System.out.println(generateToText());
final Method main = generateFunction("test");
Object res = main.invoke(null);
assertTrue(((Integer[])res).length == 2);
@@ -79,14 +79,14 @@ public class JetTypeCheckerTest extends JetLiteFixture {
assertType("0b1", library.getIntType());
assertType("0B1", library.getIntType());
assertType("1.long", library.getLongType());
assertType("1.toLong()", library.getLongType());
assertType("1.0", library.getDoubleType());
assertType("1.0.double", library.getDoubleType());
assertType("1.0.toDouble()", library.getDoubleType());
assertType("0x1.fffffffffffffp1023", library.getDoubleType());
assertType("1.0.float", library.getFloatType());
assertType("0x1.fffffffffffffp1023.float", library.getFloatType());
assertType("1.0.toFloat()", library.getFloatType());
assertType("0x1.fffffffffffffp1023.toFloat()", library.getFloatType());
assertType("true", library.getBooleanType());
assertType("false", library.getBooleanType());
@@ -401,53 +401,53 @@ public class JetTypeCheckerTest extends JetLiteFixture {
assertType("f()", "Unit");
assertType("f(1)", "Int");
assertType("f(1.float, 1)", "Float");
assertType("f<String>(1.float)", "String");
assertType("f(1.toFloat(), 1)", "Float");
assertType("f<String>(1.toFloat())", "String");
}
public void testPlus() throws Exception {
assertType("1.0.plus(1.double)", "Double");
assertType("1.0.plus(1.float)", "Double");
assertType("1.0.plus(1.long)", "Double");
assertType("1.0.plus(1.toDouble())", "Double");
assertType("1.0.plus(1.toFloat())", "Double");
assertType("1.0.plus(1.toLong())", "Double");
assertType("1.0.plus(1)", "Double");
assertType("1.float.plus(1.double)", "Double");
assertType("1.float.plus(1.float)", "Float");
assertType("1.float.plus(1.long)", "Float");
assertType("1.float.plus(1)", "Float");
assertType("1.toFloat().plus(1.toDouble())", "Double");
assertType("1.toFloat().plus(1.toFloat())", "Float");
assertType("1.toFloat().plus(1.toLong())", "Float");
assertType("1.toFloat().plus(1)", "Float");
assertType("1.long.plus(1.double)", "Double");
assertType("1.long.plus(1.float)", "Float");
assertType("1.long.plus(1.long)", "Long");
assertType("1.long.plus(1)", "Long");
assertType("1.toLong().plus(1.toDouble())", "Double");
assertType("1.toLong().plus(1.toFloat())", "Float");
assertType("1.toLong().plus(1.toLong())", "Long");
assertType("1.toLong().plus(1)", "Long");
assertType("1.plus(1.double)", "Double");
assertType("1.plus(1.float)", "Float");
assertType("1.plus(1.long)", "Long");
assertType("1.plus(1.toDouble())", "Double");
assertType("1.plus(1.toFloat())", "Float");
assertType("1.plus(1.toLong())", "Long");
assertType("1.plus(1)", "Int");
assertType("'1'.plus(1.double)", "Double");
assertType("'1'.plus(1.float)", "Float");
assertType("'1'.plus(1.long)", "Long");
assertType("'1'.plus(1.toDouble())", "Double");
assertType("'1'.plus(1.toFloat())", "Float");
assertType("'1'.plus(1.toLong())", "Long");
assertType("'1'.plus(1)", "Int");
assertType("'1'.minus('1')", "Int"); // Plus is not available for char
assertType("(1:Short).plus(1.double)", "Double");
assertType("(1:Short).plus(1.float)", "Float");
assertType("(1:Short).plus(1.long)", "Long");
assertType("(1:Short).plus(1.toDouble())", "Double");
assertType("(1:Short).plus(1.toFloat())", "Float");
assertType("(1:Short).plus(1.toLong())", "Long");
assertType("(1:Short).plus(1)", "Int");
assertType("(1:Short).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1.double)", "Double");
assertType("(1:Byte).plus(1.float)", "Float");
assertType("(1:Byte).plus(1.long)", "Long");
assertType("(1:Byte).plus(1.toDouble())", "Double");
assertType("(1:Byte).plus(1.toFloat())", "Float");
assertType("(1:Byte).plus(1.toLong())", "Long");
assertType("(1:Byte).plus(1)", "Int");
assertType("(1:Byte).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1:Byte)", "Int");
assertType("\"1\".plus(1.double)", "String");
assertType("\"1\".plus(1.float)", "String");
assertType("\"1\".plus(1.long)", "String");
assertType("\"1\".plus(1.toDouble())", "String");
assertType("\"1\".plus(1.toFloat())", "String");
assertType("\"1\".plus(1.toLong())", "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
// Solution:
val MICROS_PER_DAY : Long = 24.long * 60 * 60 * 1000 * 1000;
val MILLIS_PER_DAY : Long = 24.long * 60 * 60 * 1000
val MICROS_PER_DAY : Long = 24.toLong() * 60 * 60 * 1000 * 1000;
val MILLIS_PER_DAY : Long = 24.toLong() * 60 * 60 * 1000
println(MICROS_PER_DAY / MILLIS_PER_DAY)
}
@@ -3,8 +3,8 @@ namespace long.division.solution
import std.io.*
fun main(args : Array<String>) {
val MICROS_PER_DAY : Long = 24.long * 60 * 60 * 1000 * 1000;
val MILLIS_PER_DAY : Long = 24.long * 60 * 60 * 1000
val MICROS_PER_DAY : Long = 24.toLong() * 60 * 60 * 1000 * 1000;
val MILLIS_PER_DAY : Long = 24.toLong() * 60 * 60 * 1000
println(MICROS_PER_DAY / MILLIS_PER_DAY)
}
@@ -7,5 +7,5 @@ fun main(args : Array<String>) {
// println(12345 + 5432l)
// Correct syntax:
println(12345 + 5432.long)
println(12345 + 5432.toLong())
}
@@ -3,6 +3,6 @@ namespace multicast
import std.io.*
fun main(args : Array<String>) {
println(-1.byte.char.int)
println((-1).byte.char.int)
println(-1.toByte().toChar().toInt())
println((-1).toByte().toChar().toInt())
}
@@ -5,6 +5,6 @@ import std.*
fun main(args : Array<String>) {
// Note: \u000A is Unicode representation of linefeed (LF)
val c : Char = 0x000A .char;
val c : Char = 0x000A .toChar();
println(c);
}
@@ -5,12 +5,12 @@ import std.io.*
fun main(args : Array<String>) {
// for (b : Byte in Byte.MIN_VALUE..Byte.MAX_VALUE) {
// // Problematic code does not compile
// if (b == 0x90 .byte)
// if (b == 0x90 .toByte())
// println("joy")
// }
for (b : Byte in Byte.MIN_VALUE to Byte.MAX_VALUE) {
// Problematic code does not compile
if (b == 0x90 .byte)
if (b == 0x90 .toByte())
println("joy")
}
}
@@ -40,4 +40,4 @@ class NumberRange<T : Comparable<T>>(val from : Int, val to : Int) : Range<Int>,
}
}
fun Byte.to(to : Byte) = NumberRange<Byte>(this.int, to.int)
fun Byte.to(to : Byte) = NumberRange<Byte>(this.toInt(), to.toInt())
@@ -3,8 +3,8 @@ namespace ghost.of.looper
import std.io.*
fun main(args : Array<String>) {
var i : Short = -1.short
while (i != 1.short)
var i : Short = -1.toShort()
while (i != 1.toShort())
// Lots of magic made explicit:
i = (i.int ushr 1).short
i = (i.toInt() ushr 1).toShort()
}
+1 -1
View File
@@ -31,7 +31,7 @@ internal object RefreshQueue {
}
}
fixedRateTimer(daemon=true, name="refresher timer", period=5000.long) {
fixedRateTimer(daemon=true, name="refresher timer", period=5000.toLong()) {
scheduleRefresh(FileSystem.watchedDirectories)
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ class Point(val x: Int, val y: Int) {
fun distanceTo(other: Point): Double {
val dx = x - other.x
val dy = y - other.y
return Math.sqrt((dx*dx + dy*dy).double)
return Math.sqrt((dx*dx + dy*dy).toDouble())
}
}
+1 -1
View File
@@ -167,7 +167,7 @@ abstract class Actor(protected val executor: Executor, val fair: Boolean = false
val messagesSent = AtomicLong()
val messagesProcessed = AtomicLong()
val timer = fixedRateTimer(daemon=true, period=5000.long) {
val timer = fixedRateTimer(daemon=true, period=5000.toLong()) {
val sent = messagesSent.get()
val received = messagesProcessed.get()
println("Actors stat: Sent: $sent Processed: $received Pending: ${sent-received}")
+1 -1
View File
@@ -23,7 +23,7 @@ fun main(args: Array<String>) {
}
for (k in 1..stocksPerClient) {
val stock = (Math.random() * numberOfSymbols).int
val stock = (Math.random() * numberOfSymbols).toInt()
stockServer post Subscribe(stock.toString(), client)
}
}
+4 -4
View File
@@ -7,11 +7,11 @@ import java.util.LinkedList
class StatCalculator() : Actor(Executors.newSingleThreadExecutor().sure()) {
val list = LinkedList<Long> ()
var average = 0.long
var sum = 0.long
var cnt = 0.long
var average = 0.toLong()
var sum = 0.toLong()
var cnt = 0.toLong()
val timer = fixedRateTimer(period=2000.long, daemon=true) {
val timer = fixedRateTimer(period=2000.toLong(), daemon=true) {
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 timer = fixedRateTimer(period=1000.long, daemon=true) {
private val timer = fixedRateTimer(period=1000.toLong(), daemon=true) {
for(s in shards)
s post StockMessage.UpdateModel
}
@@ -37,8 +37,8 @@ fun spectralnormGame(n: Int) : Double {
Approximate (u, v, tmp, r1, r2)
})
var vBv = 0.double
var vv = 0.double;
var vBv = 0.toDouble()
var vv = 0.toDouble();
for (i in 0..nthread-1) {
try {
ap[i].join ();
@@ -100,7 +100,7 @@ class Approximate(val u: DoubleArray, val v: DoubleArray, val _tmp: DoubleArray,
{
for (i in rbegin..rend)
{
var sum = 0.double
var sum = 0.toDouble()
for (j in v.indices)
sum += eval_A (j, i) * v[j];
+94 -59
View File
@@ -58,19 +58,28 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="GuiceDsl.kt" pinned="false" current="true" current-in-tab="true">
<file leaf-file-name="GuiceDsl.kt" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/GuiceDsl.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="59" selection-start="859" selection-end="859" vertical-scroll-proportion="0.3951613">
<state line="41" column="0" selection-start="1211" selection-end="1211" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Singleton.java" pinned="false" current="false" current-in-tab="false">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Singleton.java">
<file leaf-file-name="LinkedBindingBuilder.java" pinned="false" current="false" current-in-tab="false">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/LinkedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="18" selection-start="1107" selection-end="1107" vertical-scroll-proportion="0.0">
<state line="50" column="0" selection-start="1509" selection-end="1509" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="BindingBuilder.java" pinned="false" current="false" current-in-tab="false">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="129" column="53" selection-start="4384" selection-end="4384" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -121,10 +130,10 @@
</provider>
</entry>
</file>
<file leaf-file-name="GuiceExample.kt" pinned="false" current="false" current-in-tab="false">
<file leaf-file-name="GuiceExample.kt" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/GuiceExample.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="45" column="87" selection-start="1494" selection-end="1494" vertical-scroll-proportion="0.0">
<state line="31" column="50" selection-start="860" selection-end="860" vertical-scroll-proportion="0.5938967">
<folding />
</state>
</provider>
@@ -158,9 +167,10 @@
</option>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="32" />
<option name="width" value="1429" />
<option name="height" value="790" />
<option name="x" value="1" />
<option name="y" value="22" />
<option name="width" value="1411" />
<option name="height" value="826" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
@@ -193,6 +203,16 @@
<sortByType />
</navigator>
<panes>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="ProjectPane">
<subPane>
<PATH>
@@ -217,16 +237,6 @@
</PATH>
</subPane>
</pane>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="PackagesPane">
<subPane>
<PATH>
@@ -496,7 +506,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="0" y="32" width="1429" height="790" extended-state="0" />
<frame x="1" y="22" width="1411" height="826" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@@ -505,23 +515,22 @@
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39886847" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Kotlin" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3294714" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="CodeWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39985326" sideWeight="0.6718529" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Gradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24909486" sideWeight="0.671151" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24944974" sideWeight="0.6718529" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3281471" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="ResolveWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.37655678" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="CodeWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39985326" sideWeight="0.6718529" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32884902" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="ResolveWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.37655678" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
@@ -581,86 +590,112 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Stage.java">
<provider selected="true" editor-type-id="text-editor">
<state line="23" column="12" selection-start="720" selection-end="720" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Scope.java">
<provider selected="true" editor-type-id="text-editor">
<state line="16" column="0" selection-start="597" selection-end="597" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/Scoping.java">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="0" selection-start="1182" selection-end="1182" vertical-scroll-proportion="0.0" />
<state line="32" column="0" selection-start="1182" selection-end="1182" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/AnnotatedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="25" column="63" selection-start="850" selection-end="850" vertical-scroll-proportion="0.0" />
<state line="25" column="63" selection-start="850" selection-end="850" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Provider.java">
<provider selected="true" editor-type-id="text-editor">
<state line="44" column="17" selection-start="1946" selection-end="1946" vertical-scroll-proportion="0.0" />
<state line="44" column="17" selection-start="1946" selection-end="1946" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Binder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="243" column="14" selection-start="11110" selection-end="11110" vertical-scroll-proportion="0.0" />
<state line="243" column="14" selection-start="11110" selection-end="11110" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/LinkedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="50" column="0" selection-start="1509" selection-end="1509" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="129" column="53" selection-start="4384" selection-end="4384" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Singleton.java">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="18" selection-start="1107" selection-end="1107" vertical-scroll-proportion="0.0" />
<state line="50" column="0" selection-start="1509" selection-end="1509" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/spi/InjectionPoint.java">
<provider selected="true" editor-type-id="text-editor">
<state line="374" column="30" selection-start="14896" selection-end="14896" vertical-scroll-proportion="0.0" />
<state line="374" column="30" selection-start="14896" selection-end="14896" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="129" column="53" selection-start="4384" selection-end="4384" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/ScopedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="0" selection-start="936" selection-end="936" vertical-scroll-proportion="0.0" />
<state line="31" column="0" selection-start="936" selection-end="936" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/AbstractBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="88" column="34" selection-start="3438" selection-end="3438" vertical-scroll-proportion="0.0" />
<state line="88" column="34" selection-start="3438" selection-end="3438" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingImpl.java">
<provider selected="true" editor-type-id="text-editor">
<state line="99" column="0" selection-start="2736" selection-end="2736" vertical-scroll-proportion="0.0" />
<state line="99" column="0" selection-start="2736" selection-end="2736" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/ProviderInstanceBindingImpl.java">
<provider selected="true" editor-type-id="text-editor">
<state line="79" column="24" selection-start="3009" selection-end="3009" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/GuiceExample.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="45" column="87" selection-start="1494" selection-end="1494" vertical-scroll-proportion="0.0" />
<state line="79" column="24" selection-start="3009" selection-end="3009" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Injector.java">
<provider selected="true" editor-type-id="text-editor">
<state line="148" column="0" selection-start="6054" selection-end="6054" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../../../dist/kotlinc/lib/kotlin-runtime.jar!/std/namespace.class">
<provider selected="true" editor-type-id="text-editor">
<state line="336" column="0" selection-start="40990" selection-end="40990" vertical-scroll-proportion="0.32130584">
<state line="148" column="0" selection-start="6054" selection-end="6054" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/GuiceDsl.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="59" selection-start="859" selection-end="859" vertical-scroll-proportion="0.3951613">
<state line="41" column="0" selection-start="1211" selection-end="1211" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/GuiceExample.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="50" selection-start="860" selection-end="860" vertical-scroll-proportion="0.5938967">
<folding />
</state>
</provider>
+1 -1
View File
@@ -92,4 +92,4 @@ class Luhny() {
}
fun Char.isDigit() = Character.isDigit(this)
fun Char.toDigit() = this.int - '0'.int
fun Char.toDigit() = this.toInt() - '0'.toInt()
+3 -3
View File
@@ -144,7 +144,7 @@ fun computeLast(allButLast : String) : Char {
}
var remainder = sum % 10
return if (remainder == 0) '0' else ('0' + (10 - remainder)).char
return if (remainder == 0) '0' else ('0' + (10 - remainder)).toChar()
}
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. */
fun randomDigit() : Char = ('0' + random.nextInt(10)).char
fun randomDigit() : Char = ('0' + random.nextInt(10)).toChar()
fun nonDigits() : String {
val nonDigits = StringBuilder()
for (i in 0..999)
nonDigits.append((random.nextInt(68) + ':').char)
nonDigits.append((random.nextInt(68) + ':').toChar())
return nonDigits.toString().sure()
}
+3 -3
View File
@@ -63,15 +63,15 @@ var JFrame.title : String
set(t) {setTitle(t)}
var JFrame.size : #(Int, Int)
get() = #(getSize().sure().getWidth().int, getSize().sure().getHeight().int)
get() = #(getSize().sure().getWidth().toInt(), getSize().sure().getHeight().toInt())
set(dim) {setSize(Dimension(dim._1, dim._2))}
var JFrame.height : Int
get() = getSize().sure().getHeight().int
get() = getSize().sure().getHeight().toInt()
set(h) {setSize(width, h)}
var JFrame.width : Int
get() = getSize().sure().getWidth().int
get() = getSize().sure().getWidth().toInt()
set(w) {setSize(height, w)}
var JFrame.defaultCloseOperation : Int
@@ -16,7 +16,7 @@ fun bbb() {
fun foo(<warning>expr</warning>: StringBuilder): Int {
val c = 'a'
when(c) {
0.char -> throw Exception("zero")
0.toChar() -> throw Exception("zero")
else -> throw Exception("nonzero" + c)
}
}
+2 -2
View File
@@ -1,8 +1,8 @@
var x : Int = 1 + x
get() : Int = 1
set(value : <error>Long</error>) {
$x = value.int
$x = <error>1.long</error>
$x = value.toInt()
$x = <error>1.toLong()</error>
}
val xx : Int = <error>1 + x</error>
+3 -3
View File
@@ -330,8 +330,8 @@ public class Converter {
final String typeToKotlin = f.getType().toKotlin();
if (typeToKotlin.equals("Boolean")) return "false";
if (typeToKotlin.equals("Char")) return "' '";
if (typeToKotlin.equals("Double")) return "0." + OperatorConventions.DOUBLE;
if (typeToKotlin.equals("Float")) return "0." + OperatorConventions.FLOAT;
if (typeToKotlin.equals("Double")) return "0." + OperatorConventions.DOUBLE + "()";
if (typeToKotlin.equals("Float")) return "0." + OperatorConventions.FLOAT + "()";
return "0";
}
}
@@ -799,7 +799,7 @@ public class Converter {
conversions.put(JAVA_LANG_CHARACTER, CHAR);
if (conversions.containsKey(type)) {
return "." + conversions.get(type);
return "." + conversions.get(type) + "()";
}
return "";
}
@@ -76,8 +76,8 @@ public class ArrayInitializerExpression extends Expression {
@NotNull
private static String getConversion(@NotNull final String afterReplace) {
if (afterReplace.contains("double")) return DOT + OperatorConventions.DOUBLE;
if (afterReplace.contains("float")) return DOT + OperatorConventions.FLOAT;
if (afterReplace.contains("double")) return DOT + OperatorConventions.DOUBLE + "()";
if (afterReplace.contains("float")) return DOT + OperatorConventions.FLOAT + "()";
return "";
}
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.j2k.Converter;
import org.jetbrains.jet.j2k.ast.*;
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
import java.util.Collections;
import java.util.List;
@@ -208,7 +209,7 @@ public class ExpressionVisitor extends StatementVisitor {
text = text.replace("D", "").replace("d", "");
}
if (canonicalTypeStr.equals("float") || canonicalTypeStr.equals(JAVA_LANG_FLOAT)) {
text = text.replace("F", "").replace("f", "") + "." + "float";
text = text.replace("F", "").replace("f", "") + "." + OperatorConventions.FLOAT + "()";
}
if (canonicalTypeStr.equals("long") || canonicalTypeStr.equals(JAVA_LANG_LONG)) {
text = text.replace("L", "").replace("l", "");
@@ -1,4 +1,4 @@
var a : Double = 0
var b : Double = 0
var c : Double = 0
var ds : DoubleArray? = doubleArray((a).double, (b).double, (c).double)
var ds : DoubleArray? = doubleArray((a).toDouble(), (b).toDouble(), (c).toDouble())
@@ -1,8 +1,8 @@
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 var a : Boolean = false
private var b : Double = 0.double
private var c : Float = 0.float
private var b : Double = 0.toDouble()
private var c : Float = 0.toFloat()
private var d : Long = 0
private var e : Int = 0
private var f : Short = 0
@@ -19,11 +19,11 @@ g = _g
}
class object {
open public fun init() : Test {
val __ = Test(null, false, 0.double, 0.float, 0, 0, 0, ' ')
val __ = Test(null, false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ')
return __
}
open public fun init(name : String?) : Test {
val __ = Test(foo(name), false, 0.double, 0.float, 0, 0, 0, ' ')
val __ = Test(foo(name), false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ')
return __
}
open fun foo(n : String?) : String? {
@@ -4,8 +4,8 @@ open fun putInt(i : Int?) : Unit {
}
open fun test() : Unit {
var b : Byte = 10
putInt((b).int)
putInt((b).toInt())
var b2 : Byte? = 10
putInt((b2).int)
putInt((b2).toInt())
}
}
+1 -1
View File
@@ -4,6 +4,6 @@ open fun putInt(i : Int) : Unit {
}
open fun test() : Unit {
var b : Byte = 10
putInt((b).int)
putInt((b).toInt())
}
}
+1 -1
View File
@@ -2,6 +2,6 @@ package demo
open class Test(i : Int) {
open fun test() : Unit {
var b : Byte = 10
Test((b).int)
Test((b).toInt())
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
open class Test() {
open fun getInt() : Int {
var b : Byte = 10
return b.int
return b.toInt()
}
}
@@ -8,5 +8,5 @@ var myContainer : Container? = Container()
}
}
open class Test() {
var b : Byte = One.myContainer?.myInt.sure().byte
var b : Byte = One.myContainer?.myInt.sure().toByte()
}
+1 -1
View File
@@ -9,6 +9,6 @@ var myContainer : Container? = Container()
}
open class Test() {
open fun test() : Unit {
var b : Byte = One.myContainer?.myInt.sure().byte
var b : Byte = One.myContainer?.myInt.sure().toByte()
}
}
@@ -2,17 +2,17 @@ open class Test() {
open fun test() : Unit {
var l1 : Long = 10
var d1 : Double = 10.0
var f1 : Float = 10.0.float
var f1 : Float = 10.0.toFloat()
var l2 : Long = 10
var d2 : Double = 10.0
var f2 : Float = 10.0.float
var f2 : Float = 10.0.toFloat()
}
open fun testBoxed() : Unit {
var l1 : Long? = 10
var d1 : Double? = 10.0
var f1 : Float? = 10.0.float
var f1 : Float? = 10.0.toFloat()
var l2 : Long? = 10
var d2 : Double? = 10.0
var f2 : Float? = 10.0.float
var f2 : Float? = 10.0.toFloat()
}
}
+2 -2
View File
@@ -49,7 +49,7 @@ private val stdin : BufferedReader = BufferedReader(InputStreamReader(object : I
}
override fun skip(n: Long): Long {
return System.`in`?.skip(n) ?: -1.long
return System.`in`?.skip(n) ?: -1.toLong()
}
override fun available(): Int {
@@ -98,7 +98,7 @@ fun InputStream.iterator() : ByteIterator =
override val hasNext : Boolean
get() = available() > 0
override fun nextByte() = read().byte
override fun nextByte() = read().toByte()
}
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
}
fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.long, period: Long, action: TimerTask.()->Unit) : Timer {
fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, action: TimerTask.()->Unit) : Timer {
val timer = if(name == null) Timer(daemon) else Timer(name, daemon)
timer.schedule(initialDelay, period, action)
return timer
@@ -52,7 +52,7 @@ fun timer(name: String? = null, daemon: Boolean = false, startAt: Date, period:
return timer
}
fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.long, period: Long, action: TimerTask.()->Unit) : Timer {
fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, action: TimerTask.()->Unit) : Timer {
val timer = if(name == null) Timer(daemon) else Timer(name, daemon)
timer.scheduleAtFixedRate(initialDelay, period, action)
return timer
+1 -1
View File
@@ -24,7 +24,7 @@ class OldStdlibTest() : TestSupport() {
val x = ByteArray (10)
for(index in 0..9) {
x [index] = index.byte
x [index] = index.toByte()
}
for(b in x.inputStream) {
+2 -2
View File
@@ -9,7 +9,7 @@ class StringTest() : TestCase() {
fun testStringIterator() {
var sum = 0
for(c in "239")
sum += (c.int - '0'.int)
sum += (c.toInt() - '0'.toInt())
assertTrue(sum == 14)
}
@@ -22,7 +22,7 @@ class StringTest() : TestCase() {
println(sb)
for(c in sb)
sum += (c.int - '0'.int)
sum += (c.toInt() - '0'.toInt())
assertTrue(sum == 14)
}
}