Add regression tests for obsolete issues

#KT-1291 Obsolete
 #KT-2895 Obsolete
 #KT-3060 Obsolete
 #KT-3298 Obsolete
 #KT-3613 Obsolete
 #KT-3862 Obsolete
This commit is contained in:
Alexander Udalov
2014-02-13 04:41:38 +04:00
parent 320c23494f
commit 8b918ef1aa
7 changed files with 119 additions and 0 deletions
@@ -0,0 +1,18 @@
open class A<T> {
open fun foo(a: T): Int = 2
}
trait B<T> : A<T> {
override fun foo(a: T): Int = 1
}
class D : B<Int>, A<Int>() {
fun boo(): Int {
return super<B>.foo(1)
}
}
fun box(): String {
if (D().boo() != 1) return "Fail"
return "OK"
}
@@ -0,0 +1,10 @@
class Foo private(val param: String = "OK") {
class object {
val s = Foo()
}
}
fun box(): String {
Foo.s.param
return "OK"
}
@@ -0,0 +1,13 @@
var result = ""
fun result(r: String) { result = r }
object Foo {
private fun String.plus() = "(" + this + ")"
fun foo() = { result(+"Stuff") }()
}
fun box(): String {
Foo.foo()
return if (result == "(Stuff)") "OK" else "Fail $result"
}
@@ -0,0 +1,27 @@
var result = 0
fun <T> Iterator<T>.foreach(action: (T) -> Unit) {
while (this.hasNext()) {
(action)(this.next())
}
}
fun <In, Out> Iterator<In>.select(f: (In) -> Out) : Iterator<Out> {
return Selector(this, f);
}
class Selector<In, Out>(val source: Iterator<In>, val f: (In) -> Out) : Iterator<Out> {
override fun hasNext(): Boolean = source.hasNext()
override fun next(): Out {
return (f)(source.next())
}
}
fun box(): String {
Array(4, { it + 1 }).iterator()
.select({i -> i * 10})
.foreach({k -> result += k})
if (result != 10+20+30+40) return "Fail: $result"
return "OK"
}
@@ -0,0 +1,15 @@
fun outer() {
fun inner(i: Int) {
if (i > 0){
{
(it: Int) -> inner(0) // <- invocation of literal itself is generated instead
}.invoke(1)
}
}
inner(1)
}
fun box(): String {
outer()
return "OK"
}
@@ -0,0 +1,6 @@
fun foo(): Int? = 42
fun box(): String {
if (foo()!! > 239) return "Fail"
return "OK"
}