Skip to content

Commit

Permalink
Mark @JsOptional parameters as @nullable
Browse files Browse the repository at this point in the history
J2CL team is in the process of disallowing JsOptional parameters to be non-nullable to improve type safety.

RELNOTES=n/a
PiperOrigin-RevId: 576205896
  • Loading branch information
mollyibot authored and Google Java Core Libraries committed Oct 24, 2023
1 parent 1cb8203 commit adde55e
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public interface ListenableFuture<V extends @Nullable Object> extends Future<V>,
@JsMethod
@Override
default <R extends @Nullable Object> IThenable<R> then(
@JsOptional IThenOnFulfilledCallbackFn<? super V, ? extends R> onFulfilled,
@JsOptional IThenOnRejectedCallbackFn<? extends R> onRejected) {
@JsOptional @Nullable IThenOnFulfilledCallbackFn<? super V, ? extends R> onFulfilled,
@JsOptional @Nullable IThenOnRejectedCallbackFn<? extends R> onRejected) {
return new Promise<V>(
(resolve, reject) -> {
Futures.addCallback(
Expand Down Expand Up @@ -65,8 +65,8 @@ public void onFailure(Throwable throwable) {
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "IThenable")
interface IThenable<T extends @Nullable Object> {
<V extends @Nullable Object> IThenable<V> then(
@JsOptional IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
@JsOptional IThenOnRejectedCallbackFn<? extends V> onRejected);
@JsOptional @Nullable IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
@JsOptional @Nullable IThenOnRejectedCallbackFn<? extends V> onRejected);

@JsFunction
interface IThenOnFulfilledCallbackFn<T extends @Nullable Object, V extends @Nullable Object> {
Expand Down Expand Up @@ -102,6 +102,6 @@ public Promise(PromiseExecutorCallbackFn<T> executor) {}

@Override
public native <V extends @Nullable Object> Promise<V> then(
@JsOptional IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
@JsOptional IThenOnRejectedCallbackFn<? extends V> onRejected);
@JsOptional @Nullable IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
@JsOptional @Nullable IThenOnRejectedCallbackFn<? extends V> onRejected);
}

0 comments on commit adde55e

Please sign in to comment.