import java.util.Objects; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; @NullMarked public final class Calculator { public Integer sum(Integer summand, @Nullable Integer @Nullable ... others ) { int sum = Objects.requireNonNull(summand); if (others != null) { for (var other : others) { sum += Objects.requireNonNullElse(other, 0); } } return sum; } } import kotlin.test.Test import kotlin.test.assertEquals class KalkulatorTests { @Test fun sumShouldWork() { val a: Int? = 1 val b: Int? = null assertEquals(2, Calculator() .sum(a, b, 1)) } } Kotlin: Argument type mismatch: actual type is 'Int?', but 'Int' was expected.