tests for KT-606 dependents & duplicates
#KT-1489 fixed #KT-1728 fixed
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
package kt606
|
||||
|
||||
//KT-606 wrong resolved call
|
||||
|
||||
class StandardPipelineFactory(val config : ChannelPipeline.() -> Unit) : ChannelPipelineFactory {
|
||||
override fun getPipeline() : ChannelPipeline {
|
||||
val pipeline : ChannelPipeline = DefaultChannelPipeline()
|
||||
@@ -19,7 +23,43 @@ trait ChannelPipelineFactory {
|
||||
fun getPipeline() : ChannelPipeline
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
fun testKt606() {
|
||||
StandardPipelineFactory({ print("OK") }).getPipeline()
|
||||
}
|
||||
|
||||
//Tests for duplicates
|
||||
//KT-1061 Can't call function defined as a val
|
||||
object X {
|
||||
val doit = { (i: Int) -> i }
|
||||
}
|
||||
|
||||
fun testKt1061() : String = if (X.doit(3) == 3) "OK" else "fail"
|
||||
|
||||
|
||||
//KT-1249 IllegalStateException invoking function property
|
||||
class TestClass(val body : () -> Unit) : Any {
|
||||
fun run() {
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun testKt1249() {
|
||||
TestClass({}).run()
|
||||
}
|
||||
|
||||
class Foo<T>(val filter: (T) -> Boolean) {
|
||||
public fun bar(tee: T) : Boolean {
|
||||
return filter(tee);
|
||||
}
|
||||
}
|
||||
|
||||
//KT-1290 Method property in constructor causes NPE
|
||||
fun testKt1290() = Foo({ (i: Int) -> i < 5 }).bar(2)
|
||||
|
||||
fun box() : String {
|
||||
testKt606()
|
||||
testKt1061()
|
||||
testKt1249()
|
||||
if (!testKt1290()) return "fail"
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package kt606_dependents
|
||||
|
||||
//KT-1489 Code analyzer fails with assertion
|
||||
trait AutoCloseable{
|
||||
fun close()
|
||||
}
|
||||
|
||||
class C {
|
||||
class Resource : AutoCloseable {
|
||||
override fun close() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo<X : AutoCloseable>(<!UNUSED_PARAMETER!>x<!> : X, <!UNUSED_PARAMETER!>body<!> : (X) -> Unit) {
|
||||
}
|
||||
|
||||
fun p() : Resource? = null
|
||||
|
||||
fun bar() {
|
||||
<!TYPE_INFERENCE_FAILED!>foo(<!TYPE_MISMATCH!>p()<!>) {
|
||||
|
||||
}<!>
|
||||
}
|
||||
}
|
||||
|
||||
//KT-1728 Can't invoke extension property as a function
|
||||
|
||||
val Int.ext : () -> Int = { 5 }
|
||||
val x = 1.ext()
|
||||
Reference in New Issue
Block a user