Specificity supported for dynamic types

This commit is contained in:
Andrey Breslav
2014-11-09 14:05:58 +02:00
parent 20513abe04
commit 65794183e7
7 changed files with 75 additions and 4 deletions
@@ -0,0 +1,26 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE[js]: m1
// FILE: k.kt
fun dyn(d: dynamic) {}
fun foo(d: dynamic): String = ""
fun foo(d: Int): Int = 1
fun nothing(d: dynamic): Int = 1
fun nothing(d: Nothing): String = ""
fun test(d: dynamic) {
dyn(1)
dyn("")
foo(1).checkType { it : _<Int> }
foo("").checkType { it : _<String> }
// Checking specificity of `dynamic` vs `Nothing`
nothing(d).checkType { it : _<String> }
nothing("").checkType { it : _<Int> }
[suppress("UNREACHABLE_CODE")] nothing(null!!).checkType { it : _<String> }
}
@@ -0,0 +1,8 @@
package
internal fun dyn(/*0*/ d: (kotlin.Nothing..kotlin.Any?)): kotlin.Unit
internal fun foo(/*0*/ d: (kotlin.Nothing..kotlin.Any?)): kotlin.String
internal fun foo(/*0*/ d: kotlin.Int): kotlin.Int
internal fun nothing(/*0*/ d: dynamic): kotlin.Int
internal fun nothing(/*0*/ d: kotlin.Nothing): kotlin.String
internal fun test(/*0*/ d: dynamic): kotlin.Unit