Support deserialized contracts in common code

#KT-26687 Fixed
This commit is contained in:
Denis Zharkov
2018-09-16 23:58:11 +03:00
parent ed8aad6149
commit 956f8ad5e9
11 changed files with 126 additions and 2 deletions
@@ -0,0 +1,14 @@
package test.common
fun test(x: List<Int>?) {
// If the function returns false, the value is definitely not null:
if (!x.isNullOrEmpty()) {
println(x.size) // Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type List<Int>?
}
}
fun test(x: Any?) {
// If the function returns (does not throw), then the argument is true:
require(x is String)
println(x.length) // Unresolved reference: length
}
@@ -0,0 +1,14 @@
package test.js
fun test(x: List<Int>?) {
// If the function returns false, the value is definitely not null:
if (!x.isNullOrEmpty()) {
println(x.size) // Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type List<Int>?
}
}
fun test(x: Any?) {
// If the function returns (does not throw), then the argument is true:
require(x is String)
println(x.length) // Unresolved reference: length
}
@@ -0,0 +1,14 @@
package test.jvm
fun test(x: List<Int>?) {
// If the function returns false, the value is definitely not null:
if (!x.isNullOrEmpty()) {
println(x.size) // Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type List<Int>?
}
}
fun test(x: Any?) {
// If the function returns (does not throw), then the argument is true:
require(x is String)
println(x.length) // Unresolved reference: length
}