[FE 1.0] Don't fail on calls of functions with contracts from object
^KT-51704 Fixed
This commit is contained in:
committed by
teamcity
parent
993021a71d
commit
4d5a4ccd6b
+38
@@ -0,0 +1,38 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-51704
|
||||
|
||||
import Foo.Companion.checkSomethingCompanion
|
||||
import Bar.checkSomethingObject
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
class Foo {
|
||||
companion object {
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun checkSomethingCompanion(condition: Boolean, message: String) {
|
||||
contract {
|
||||
returns() implies (condition)
|
||||
}
|
||||
if (!condition)
|
||||
throw Exception(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Bar {
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun checkSomethingObject(condition: Boolean, message: String) {
|
||||
contract {
|
||||
returns() implies (condition)
|
||||
}
|
||||
if (!condition)
|
||||
throw Exception(message)
|
||||
}
|
||||
}
|
||||
|
||||
fun usage() {
|
||||
Foo.checkSomethingCompanion(1 == 2, "wat") // ok
|
||||
checkSomethingCompanion(1 == 2, "wat") // compiler crash
|
||||
Bar.checkSomethingObject(1 == 2, "wat") // ok
|
||||
checkSomethingObject(1 == 2, "wat") // compiler crash
|
||||
}
|
||||
Reference in New Issue
Block a user