Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 522142

Summary: [1.8][null] Bogus error with @NonNullByDefault on generified inherited class
Product: [Eclipse Project] JDT Reporter: Clovis Seragiotto <clovis.seragiotto>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED MOVED QA Contact:
Severity: major    
Priority: P2 CC: mike, stephan.herrmann
Version: 4.8   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
See Also: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/682
Whiteboard:

Description Clovis Seragiotto CLA 2017-09-11 09:42:57 EDT
This produces no warning (even though <@NonNull A> is redundant):

@org.eclipse.jdt.annotation.NonNullByDefault({PARAMETER, RETURN_TYPE, FIELD, TYPE_PARAMETER, TYPE_BOUND, TYPE_ARGUMENT})
interface Foo<A> {
    interface Bar<@NonNull A> extends Iterable<Foo<A>> {
    }
}

while this produces an error (Null constraint mismatch: The type 'A' is not a valid substitute for the type parameter '@NonNull A')

@org.eclipse.jdt.annotation.NonNullByDefault({PARAMETER, RETURN_TYPE, FIELD, TYPE_PARAMETER, TYPE_BOUND, TYPE_ARGUMENT})
interface Foo<A> {
    interface Bar<A> extends Iterable<Foo<A>> {
    }
}
Comment 1 Michael Vorburger CLA 2017-10-03 12:53:26 EDT
Hit similar same problem, also illustrated in https://github.com/lastnpe/eclipse-null-eea-augments/pull/44/files ...

> This produces no warning (even though <@NonNull A> is redundant):

who cares... ;-) perhaps that problem could be a separate minor bug?

> while this produces an error

now that IMHO is real confusing (I just sank about 2h into getting my head around it), and perhaps more of a major problem?  FYI what I found particularly confusing is that if one hovers over the (in your example) Bar<A> then it will show Bar<@NonNull A> so you like bang your head against the table "but so it IS @NonNull, so ... what?!" ;-)
Comment 2 Till Brychcy CLA 2017-10-03 12:56:20 EDT
i can reproduce this. The type variables are copied before @NNBD is applied, so the copies don't have the @NonNull.
Comment 3 Eclipse Genie CLA 2020-04-20 17:57:40 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Stephan Herrmann CLA 2020-04-20 18:33:54 EDT
Still relevant
Comment 5 Stephan Herrmann CLA 2020-06-10 03:35:33 EDT
.
Comment 6 Eclipse Genie CLA 2023-01-27 13:31:08 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Stephan Herrmann CLA 2023-01-31 15:58:16 EST
Over to github: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/682