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

Undetected @Nullable annotation in a method reference #1128

Open
sdeleuze opened this issue Jan 13, 2025 · 1 comment
Open

Undetected @Nullable annotation in a method reference #1128

sdeleuze opened this issue Jan 13, 2025 · 1 comment

Comments

@sdeleuze
Copy link

With the JSpecify mode enabled, I have this interface:

public interface WebFluxConfigurer {

	default @Nullable WebSocketService getWebSocketService() {
		return null;
	}
}

And:

	public @Nullable WebSocketService getWebSocketService() {
		return createSingleBean(WebFluxConfigurer::getWebSocketService, WebSocketService.class);
	}

	private <T> @Nullable T createSingleBean(Function<WebFluxConfigurer, @Nullable T> factory, Class<T> beanType) {
		// ...
	}

I get the following IMO invalid error:

error: [NullAway] Cannot pass parameter of type Function<WebFluxConfigurer, WebSocketService>, as formal parameter has type Function<WebFluxConfigurer, @org.jspecify.annotations.Nullable T>, which has mismatched type parameter nullability
@sdeleuze sdeleuze changed the title Undetected @Nullable annotation in a default method reference Undetected @Nullable annotation in a method reference Jan 13, 2025
@msridhar
Copy link
Collaborator

I can reproduce this one. It's not about default methods, but the fact that the call is to a generic method and we don't handle the instances of @Nullable T correctly. This one will be a bit trickier to fix and will take a bit; probably best to just suppress for now.

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

2 participants