KT-2752: fix support of typealiases

This commit is contained in:
Alexey Andreev
2016-10-05 18:38:38 +03:00
parent 831ac97ecd
commit c814a9d1d2
10 changed files with 27 additions and 65 deletions
@@ -1,10 +0,0 @@
class C() {
fun getInstance(): Runnable = C
companion object: Runnable {
override fun run(): Unit {
}
}
}
fun foo() = C().getInstance()
@@ -1,7 +0,0 @@
class GameError(msg: String) : Exception(msg) {
}
fun box(): String {
val e = GameError("foo")
return if (e.getMessage() == "foo") "OK" else "fail"
}
@@ -1,14 +0,0 @@
class Foo() {
}
class Bar() {
}
fun <T> isInstance(obj: Any?) = obj is T
fun <T> isInstance2(obj: Any?) = isInstance<T>(obj)
fun box(): String {
if (!isInstance2<Foo>(Foo())) return "fail 1"
if (isInstance2<Bar>(Foo())) return "fail 2"
return "OK"
}
@@ -1,9 +0,0 @@
package foo
class A() {
}
val a1 = Array<Int>(3)
val a2 = Array<A>(2)
fun box() = if (a1[4] == null) "OK" else "fail"
@@ -1,23 +0,0 @@
package foo
class MyThrowable(message: String? = null) : Exception(message) {
override val message: String?
get() = "My message: " + super.message
override val cause: Throwable?
get() = super.cause ?: this
}
fun box(): String {
try {
throw MyThrowable("test")
} catch (t: MyThrowable) {
if (t.cause != t) return "fail t.cause"
if (t.message != "My message: test") return "fail t.message"
return "OK"
}
return "fail: MyThrowable wasn't catched."
}