corneil
08/28/2019, 7:05 PMcontract
will be able to ensure that if you do precondition(someThing != null) { "Something is required" }
that someThing
be detected as not null afterwards? Is this in the works?Dominaezzz
08/28/2019, 7:28 PMDominaezzz
08/28/2019, 7:29 PMassertTrue
currently allows this.corneil
08/28/2019, 7:30 PMassertTrue
in my non-test code. 😶Dominaezzz
08/28/2019, 7:31 PMassertTrue
. I'm saying assertTrue
uses the contract you described.corneil
08/28/2019, 7:31 PMDominaezzz
08/28/2019, 7:32 PM/** Asserts that the expression is `true` with an optional [message]. */
fun assertTrue(actual: Boolean, message: String? = null) {
contract { returns() implies actual }
return asserter.assertTrue(message ?: "Expected value to be true.", actual)
}
corneil
08/28/2019, 7:33 PMcorneil
08/28/2019, 7:37 PMprecondition
I have been using is my own. 🤦 So I'm adding contract
! and -Xuse-experimental=kotlin.contracts.ExperimentalContracts
😀Dominaezzz
08/28/2019, 7:39 PMrequire
if you don't want to add the experimental flag.corneil
08/28/2019, 7:40 PM!!
corneil
08/28/2019, 7:41 PMDominaezzz
08/28/2019, 7:41 PMcorneil
08/28/2019, 9:03 PMcorneil
08/28/2019, 9:09 PM