Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/contracts/newSyntax/propertyAccessorsContractDescription.kt
T
Dmitriy Novozhilov 4c96495eef [FIR] Put new contract syntax under feauture flag
^KT-55171 Fixed
2023-01-31 07:53:09 +00:00

20 lines
454 B
Kotlin
Vendored

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