Do not lose information about contracts if call uses default value
It is safe to treat DefaultValueArgument as UNKNOWN_COMPUTATION, because default arguments can't break smartcasts. Possibly, they can add new ones, but it can be supported later. ^KT-25278 Fixed
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
|
||||
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
|
||||
|
||||
import kotlin.internal.contracts.*
|
||||
|
||||
fun myAssert(condition: Boolean, message: String = "") {
|
||||
contract {
|
||||
returns() implies (condition)
|
||||
}
|
||||
if (!condition) throw kotlin.IllegalArgumentException(message)
|
||||
}
|
||||
|
||||
fun test(x: Any?) {
|
||||
myAssert(x is String)
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun myAssert(/*0*/ condition: kotlin.Boolean, /*1*/ message: kotlin.String = ...): kotlin.Unit
|
||||
Returns(WILDCARD) -> condition
|
||||
|
||||
public fun test(/*0*/ x: kotlin.Any?): kotlin.Unit
|
||||
Reference in New Issue
Block a user