Skip to content

Commit a338561

Browse files
committed
refactor: drop the redundant contract block from checkRequired
checkNotNull already declares returns() implies (value != null) and checkRequired returns a non-null T by signature, so the explicit contract only added smart-casting of the argument variable after the call. Neither builder call site relies on that (both consume the return value directly), so remove the contract and its ExperimentalContracts opt-in and collapse to a single expression.
1 parent cbf920f commit a338561

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

sdk-core/src/main/kotlin/org/dexpace/sdk/core/generics/BuilderChecks.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
package org.dexpace.sdk.core.generics
99

10-
import kotlin.contracts.ExperimentalContracts
11-
import kotlin.contracts.contract
12-
1310
/**
1411
* Asserts that a required builder field [value] has been set, returning it non-null.
1512
*
@@ -38,13 +35,7 @@ import kotlin.contracts.contract
3835
* @return [value], guaranteed non-null.
3936
* @throws IllegalStateException If [value] is `null`.
4037
*/
41-
@OptIn(ExperimentalContracts::class)
4238
public fun <T : Any> checkRequired(
4339
name: String,
4440
value: T?,
45-
): T {
46-
contract {
47-
returns() implies (value != null)
48-
}
49-
return checkNotNull(value) { "$name is required" }
50-
}
41+
): T = checkNotNull(value) { "$name is required" }

0 commit comments

Comments
 (0)