Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatched nullability of type parameters in sub-expression #1127

Open
sdeleuze opened this issue Jan 13, 2025 · 0 comments
Open

Mismatched nullability of type parameters in sub-expression #1127

sdeleuze opened this issue Jan 13, 2025 · 0 comments

Comments

@sdeleuze
Copy link

With the JSpecify mode enabled, I have a method defined as:

protected @Nullable ParameterNameDiscoverer getParameterNameDiscoverer() {
	return this.parameterNameDiscoverer;
}

And an interface defined as:

public interface ParameterNameDiscoverer {
	@Nullable String @Nullable [] getParameterNames(Method method);
	@Nullable String @Nullable [] getParameterNames(Constructor<?> ctor);
}

Used in:

ParameterNameDiscoverer paramNameDiscoverer = getParameterNameDiscoverer();
		@Nullable String[] paramNames = (paramNameDiscoverer != null ? paramNameDiscoverer.getParameterNames(method) : null);

Which generate the following error:

 error: [NullAway] Conditional expression must have type String[] but the sub-expression has type @Nullable String[], which has mismatched nullability of type parameters

Looks like a valid use case to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant