Merge branch 'master' of ssh://git.labs.intellij.net/jet

This commit is contained in:
svtk
2011-09-13 12:20:48 +04:00
21 changed files with 385 additions and 161 deletions
+25 -1
View File
@@ -1,10 +1,16 @@
class A() {}
class B<T>() {
open class B<T>() {
fun isT (a : Any?) : Boolean {
return a is T
}
}
class C() : B<String>() {
}
class D<T>() : B<B<T>>() {
}
fun t1() : Boolean {
val a = A()
if(a !is A) return false
@@ -148,6 +154,18 @@ fun t24 () : Boolean {
return true
}
fun t25 () : Boolean {
val c = C()
if(!c.isT("aaa")) return false
return true
}
fun t26 () : Boolean {
val d = D<String>()
if(!d.isT(B<String>())) return false
return true
}
fun box() : String {
if(!t1()) {
return "t1 failed"
@@ -221,5 +239,11 @@ fun box() : String {
if(!t24()) {
return "t24 failed"
}
if(!t25()) {
return "t25 failed"
}
if(!t26()) {
return "t26 failed"
}
return "OK"
}
@@ -0,0 +1,4 @@
// KT-297 Overload resolution ambiguity with required in trait
trait ALE<T> : java.util.ArrayList<T> {
fun getOrValue(index: Int, value : T) : T = if(index >= 0 && index < size()) get(index) else value
}
+15
View File
@@ -0,0 +1,15 @@
trait AL {
fun get(index: Int) : Any? = null
}
trait ALE<T> : AL {
fun getOrNull(index: Int, value : T) = get(index) as? T ?: value
}
class SmartArrayList() : ALE<String> {
}
fun box() : String {
val c = SmartArrayList()
return if("239" == c.getOrNull(0, "239")) "OK" else "fail"
}
@@ -0,0 +1,15 @@
open class AL<T> {
fun get(index: Int) : T? = null
}
trait ALE<T> : AL<T> {
fun getOrValue(index: Int, value : T) : T = get(index) ?: value
}
class SmartArrayList() : ALE<String>, AL<String> {
}
fun box() : String {
val c = SmartArrayList()
return if("239" == c.getOrValue(0, "239")) "OK" else "fail"
}
@@ -0,0 +1,9 @@
// KT-300 Overload ambiguity while accessing range
class MyRange() : Range<Int> {
~in~override fun contains(item: Int) = true
}
fun foo(x: Int?, range: MyRange) {
x `in`in range // Int? found, but Int expected
}