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 when using Nullable with third party library that does not have null-safety #1158

Closed
violetagg opened this issue Mar 5, 2025 · 2 comments

Comments

@violetagg
Copy link

I have a problem when I try to use @Nullable and third party library that does not have null-safety, this snippet:

class B {
	static final AttributeKey<@Nullable Object> RESULT_UPDATER = AttributeKey.valueOf("result");

	final Channel channel = new EmbeddedChannel();

	B() {
		System.out.println("Current Attribute " + channel.attr(RESULT_UPDATER).get());
	}
}

Gives the following error:

/nullaway-mismatched-nullability/src/main/java/org/example/B.java:9: error: [NullAway] Cannot assign from type AttributeKey<Object> to type AttributeKey<@Nullable Object> due to mismatched nullability of type parameters
	static final AttributeKey<@Nullable Object> RESULT_UPDATER = AttributeKey.valueOf("result");
	                                            ^

The repository with the reproducible example can be found here
https://github.com/violetagg/nullaway-mismatched-nullability

@msridhar
Copy link
Collaborator

msridhar commented Mar 5, 2025

Thanks again for the report! This is again #1075 and you can work around with an explicit type argument to the call. I will report back when we have a fix.

@msridhar msridhar closed this as completed Mar 5, 2025
@violetagg
Copy link
Author

Thanks

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