Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/contracts/newSyntax/propertyAccessorsContractDescription.fir.kt
T
Kirill Rakhman f946ddeb40 [FIR] Implement checks for contract not allowed
^KT-55423 Fixed
2023-03-09 08:32:02 +00:00

20 lines
472 B
Kotlin
Vendored

// LANGUAGE: +ContractSyntaxV2
import kotlin.contracts.*
class A {
var x: Int = 0
get() = f(x)
set(value) contract <!CONTRACT_NOT_ALLOWED!>[returns() implies (value != null)]<!> {
field = value + 1
}
var y: Double = 0.0
get() = g(y)
set(value) contract <!CONTRACT_NOT_ALLOWED!>[returns() implies (value != null)]<!> {
field = value * 2
}
fun f(arg: Int) = arg * arg
fun g(arg: Double) = arg / 2
}