You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nullness bound for unbounded wildcard in a nullness-annotated context #83
This issue is pretty closely related to #12. Sometimes an option is to first make the decision that two issues must be decided in the same direction as each other consistently, then debate that direction. In this case I think it will make the argument way more complicated than it already is, so I'm making an attempt to have us first get a working decision for #83, then take that decision into account in getting a working decision for #12.
Under the current assumptions in the document, the arguments seem to be favoring making the <?> nullable-bounded aka unconstrained. (Even the arguments were split down the middle, that should still point toward matching existing eclipse/CF behavior.)
Copying an observation from @kevin1e100 here: Foo<@NonNull ?> would be one of the few cases (possibly the only case) in which @NonNull has an effect in a @DefaultNonNull context. Other usages of @NonNull in that context would be redundant.
This isn't a huge deal, just a small negative worth nothing.
(And while I'm here, I'll note that I found the need for this concept -- <? extends @NonNull Object>, to be explicit about it -- to be vanishingly small in Guava.)
changed the title [-]Nullness bound for unbounded wildcard [/-][+]Nullness bound for unbounded wildcard in a nullness-annotated context (resolved: nullable)[/+]on May 8, 2020
changed the title [-]Nullness bound for unbounded wildcard in a nullness-annotated context (resolved: nullable)[/-][+]Nullness bound for unbounded wildcard in a nullness-annotated context (working decision: nullable)[/+]on May 8, 2020
Current decision: In null-marked code, the wildcard in Foo<?> can capture nullable types (assuming the corresponding type parameter isn't bounded by a non-null type). If you want it not to capture nullable types you'd have to write Foo<? extends Object>. (Unlike type parameter declarations, bytecode does distinguish between Foo<?> and Foo<? extends Object>).
Argument for changing: The current decision is inconsisitent with the fact that nullability must be explicit in all other type usages in null-marked code.
However, no strong case was made for changing the decision.
Timing: This must be decided before version 1.0 of the jar because it's mentioned in the Javadoc for @NullMarked.
Proposal for 1.0: Finalize the current decision. If you agree, please add a thumbs-up emoji (👍) to this comment. If you disagree, please add a thumbs-down emoji (👎) to this comment and briefly explain your disagreement. Please only add a thumbs-down if you feel you can make a strong case why this decision will be materially worse for users or tool providers than an alternative.
Results: This proposal received six 👍s and no other votes. It is finalized. I'll edit the title to reflect that.
Reacted by Chris Povirk, David P. Baker, Kevin Bourrillion, Manu Sridharan, Werner Dietl and Lázaro Clapp
Decision: In null-marked code, the wildcard in Foo<?> can capture nullable types (assuming the corresponding type parameter isn't bounded by a non-null type). If you want it not to capture nullable types you'd have to write Foo<? extends Object>.
changed the title [-]Nullness bound for unbounded wildcard in a nullness-annotated context (working decision: nullable)[/-][+]Nullness bound for unbounded wildcard in a nullness-annotated context[/+]on May 17, 2024
Activity
kevinb9n commentedon Dec 3, 2019
I have attempted to start exploring both sides of this issue in a document:
https://docs.google.com/document/d/1HGupJjYkFs6OPjH4tQFmivNr1sPcHicaXDdMVvGfu4A/edit#
Please direct any substantive debate into comments or direct edits of that doc.
kevinb9n commentedon Dec 3, 2019
This issue is pretty closely related to #12. Sometimes an option is to first make the decision that two issues must be decided in the same direction as each other consistently, then debate that direction. In this case I think it will make the argument way more complicated than it already is, so I'm making an attempt to have us first get a working decision for #83, then take that decision into account in getting a working decision for #12.
kevinb9n commentedon Dec 18, 2019
Under the current assumptions in the document, the arguments seem to be favoring making the
<?>nullable-bounded aka unconstrained. (Even the arguments were split down the middle, that should still point toward matching existing eclipse/CF behavior.)kevin1e100 commentedon Dec 18, 2019
Yep I went ahead and updated the doc accordingly a few days ago.
cpovirk commentedon Feb 5, 2020
Copying an observation from @kevin1e100 here:
Foo<@NonNull ?>would be one of the few cases (possibly the only case) in which@NonNullhas an effect in a@DefaultNonNullcontext. Other usages of@NonNullin that context would be redundant.This isn't a huge deal, just a small negative worth nothing.
(And while I'm here, I'll note that I found the need for this concept --
<? extends @NonNull Object>, to be explicit about it -- to be vanishingly small in Guava.)[-]Nullness bound for unbounded wildcard [/-][+]Nullness bound for unbounded wildcard in a nullness-annotated context (resolved: nullable)[/+][-]Nullness bound for unbounded wildcard in a nullness-annotated context (resolved: nullable)[/-][+]Nullness bound for unbounded wildcard in a nullness-annotated context (working decision: nullable)[/+]Treat `<?>` as unbounded.
netdpb commentedon Apr 9, 2024
Current decision: In null-marked code, the wildcard in
Foo<?>can capture nullable types (assuming the corresponding type parameter isn't bounded by a non-null type). If you want it not to capture nullable types you'd have to writeFoo<? extends Object>. (Unlike type parameter declarations, bytecode does distinguish betweenFoo<?>andFoo<? extends Object>).Argument for changing: The current decision is inconsisitent with the fact that nullability must be explicit in all other type usages in null-marked code.
However, no strong case was made for changing the decision.
Timing: This must be decided before version 1.0 of the jar because it's mentioned in the Javadoc for
@NullMarked.Proposal for 1.0: Finalize the current decision. If you agree, please add a thumbs-up emoji (👍) to this comment. If you disagree, please add a thumbs-down emoji (👎) to this comment and briefly explain your disagreement. Please only add a thumbs-down if you feel you can make a strong case why this decision will be materially worse for users or tool providers than an alternative.
Results: This proposal received six 👍s and no other votes. It is finalized. I'll edit the title to reflect that.
netdpb commentedon May 17, 2024
Decision: In null-marked code, the wildcard in
Foo<?>can capture nullable types (assuming the corresponding type parameter isn't bounded by a non-null type). If you want it not to capture nullable types you'd have to writeFoo<? extends Object>.[-]Nullness bound for unbounded wildcard in a nullness-annotated context (working decision: nullable)[/-][+]Nullness bound for unbounded wildcard in a nullness-annotated context[/+]