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
Generic mismatch message omits the wildcard-bound note when the bound is a subclass of an inner-class type #2224
When a wildcard's implicit bound is a top-level class that extends an inner-class type, and the mismatch lies in the enclosing type of that inner class, the message names the mismatch but gives no note: line explaining where the nullable type argument comes from.
incompatible nullability in type argument for T of Holder -> upper bound of wildcard -> enclosing type -> type argument for X of Enclosing: source has @Nullable String where target requires String
source: TopSub<?>
^
target: Holder<? extends Enclosing<String>.Nested<String>>
^^^^^^
Expected: a note: line like the one printed when the bound is a subclass and the mismatch is in a type argument (NoteTests.aHolderNoteIsPrintedOnlyWhereItsBoundHasTheNullnessTheCheckCompared, key BOUND_IS_A_SUBCLASS_OF_THE_COMPARED_CLASS), naming the bound TopNested of U in TopSub. Viewed as Nested, that bound holds @Nullable String at X, which is the nullness the first line reports.
The test key NO_NOTE_BELOW_AN_ENCLOSING_TYPE_OF_A_SUBCLASS_BOUND in the same test pins the current output.
Analysis, from reading the source (the report stands without it): NullabilityMismatchMessage.hasNullnessAt views a node as the step's class only for a type-argument step (typeArgumentAt calls asSuper). For an enclosing-type step it takes the enclosing type of TopNested itself, which is noType, so the note's agreement check fails. A TypePath.Step for an enclosing type carries no class to view the node as.
Found in the final review of the round-4 fixes for #1828.
Activity
Name a bound's type parameter only where it declares the compared bound