提交 1792a71a 编写于 作者: A Andrey Breslav

IntRanges + fixes in tests

上级 cd2b128f
......@@ -24,6 +24,19 @@ class Range<in T : Comparable<T>> {
fun contains(item : T) : Boolean
}
class Iterator<out T> {
fun next() : T
val hasNext : Boolean
}
class Iterable<out T> {
fun iterator() : Iterator<T>
}
class IntRange<T> : Range<T>, Iterable<T> {
}
class Number {
val d : Double
val f : Float
......@@ -205,11 +218,11 @@ class Long : Number, Comparable<Long> {
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Long>
fun rangeTo(other : Short) : Range<Long>
fun rangeTo(other : Byte) : Range<Long>
fun rangeTo(other : Char) : Range<Long>
fun rangeTo(other : Long) : IntRange<Long>
fun rangeTo(other : Int) : IntRange<Long>
fun rangeTo(other : Short) : IntRange<Long>
fun rangeTo(other : Byte) : IntRange<Long>
fun rangeTo(other : Char) : IntRange<Long>
fun inc() : Long
fun dec() : Long
......@@ -266,11 +279,11 @@ class Int : Number, Comparable<Int> {
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun rangeTo(other : Long) : IntRange<Long>
fun rangeTo(other : Int) : IntRange<Int>
fun rangeTo(other : Short) : IntRange<Int>
fun rangeTo(other : Byte) : IntRange<Int>
fun rangeTo(other : Char) : IntRange<Int>
fun inc() : Int
fun dec() : Int
......@@ -327,11 +340,11 @@ class Char : Number, Comparable<Char> {
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun rangeTo(other : Long) : IntRange<Long>
fun rangeTo(other : Int) : IntRange<Int>
fun rangeTo(other : Short) : IntRange<Int>
fun rangeTo(other : Byte) : IntRange<Int>
fun rangeTo(other : Char) : IntRange<Int>
fun inc() : Char
fun dec() : Char
......@@ -388,11 +401,11 @@ class Short : Number, Comparable<Char> {
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun rangeTo(other : Long) : IntRange<Long>
fun rangeTo(other : Int) : IntRange<Int>
fun rangeTo(other : Short) : IntRange<Int>
fun rangeTo(other : Byte) : IntRange<Int>
fun rangeTo(other : Char) : IntRange<Int>
fun inc() : Short
fun dec() : Short
......@@ -449,11 +462,11 @@ class Byte : Number, Comparable<Char> {
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun rangeTo(other : Long) : IntRange<Long>
fun rangeTo(other : Int) : IntRange<Int>
fun rangeTo(other : Short) : IntRange<Int>
fun rangeTo(other : Byte) : IntRange<Int>
fun rangeTo(other : Char) : IntRange<Int>
fun inc() : Byte
fun dec() : Byte
......
......@@ -35,7 +35,7 @@ class B : `java::java.lang.Object`Object {
}
}
~c~fun c(~x~x : `java::java.lang.Number`Number) {
~c~fun c(~x~x : java.lang.`java::java.lang.Number`Number) {
`x`x.`java::java.lang.Number.intValue()`intValue()
}
......
......@@ -105,25 +105,25 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertType("if (true) 1 else null", "Int?");
assertType("if (true) null else null", "Nothing?");
assertType("if (true) 1 else '1'", "Comparable<out Any>");
assertType("if (true) 1 else '1'", "Any");
}
public void testWhen() throws Exception {
assertType("when (1) { is 1 => 2; } ", "Int");
assertType("when (1) { is 1 => 2; is 1 => '2'} ", "Comparable<out Any>");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => null} ", "Comparable<out Any>?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else => null} ", "Comparable<out Any>?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else continue} ", "Comparable<out Any>");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 when(e) {is 1 => null}} ", "Comparable<out Any>?");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => when(e) {is 1 => null}} ", "Comparable<out Any>?");
assertType("when (1) { is 1 => 2; is 1 => '2'} ", "Any");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => null} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else => null} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else continue} ", "Any");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 when(e) {is 1 => null}} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => when(e) {is 1 => null}} ", "Any?");
}
public void testTry() throws Exception {
assertType("try {1} finally{2}", "Int");
assertType("try {1} catch (e : e) {'a'} finally{2}", "Int");
assertType("try {1} catch (e : e) {'a'} finally{'2'}", "Comparable<out Any>");
assertType("try {1} catch (e : e) {'a'}", "Comparable<out Any>");
assertType("try {1} catch (e : e) {'a'} catch (e : e) {null}", "Comparable<out Any>?");
assertType("try {1} catch (e : e) {'a'} finally{'2'}", "Any");
assertType("try {1} catch (e : e) {'a'}", "Any");
assertType("try {1} catch (e : e) {'a'} catch (e : e) {null}", "Any?");
assertType("try {} catch (e : e) {}", "Unit");
}
......@@ -137,7 +137,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertCommonSupertype("Int?", "Int", "Nothing?");
assertCommonSupertype("Nothing?", "Nothing?", "Nothing?");
assertCommonSupertype("Comparable<out Any>", "Int", "Char");
assertCommonSupertype("Any", "Int", "Char");
assertCommonSupertype("Base_T<*>", "Base_T<*>", "Derived_T<*>");
assertCommonSupertype("Any", "Base_inT<*>", "Derived_T<*>");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册