Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 485058 - [1.8][null] problem with wildcards and null-annotated type bounds
Summary: [1.8][null] problem with wildcards and null-annotated type bounds
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 4.6 M5   Edit
Assignee: Till Brychcy CLA
QA Contact: Stephan Herrmann CLA
URL:
Whiteboard:
Keywords:
Depends on: 484981
Blocks:
  Show dependency tree
 
Reported: 2015-12-31 11:44 EST by Till Brychcy CLA
Modified: 2016-01-23 00:23 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Till Brychcy CLA 2015-12-31 11:44:13 EST
DESCRIPTION:
The following code compiles with an error:

package test;
import org.eclipse.jdt.annotation.NonNullByDefault;
@NonNullByDefault
class Feature4<Q extends java.io.Serializable> {
}
@NonNullByDefault
public class Test4 {
	public static <Q1 extends java.io.Serializable, F extends Feature4<Q1>> Q1[] getValues(F feature) {
		throw new RuntimeException();
	}
	public static void f(Feature4<?> feature) {
		getValues(feature);
	}
}

	getValues(feature);
	^^^^^^^^^^^^^^^^^^
Null constraint mismatch: The type \'@NonNull Feature4<capture#of ?>\' is not a valid substitute for the type parameter \'F extends @NonNull Feature4<Q1 extends @NonNull Serializable>\'

ANALYSIS:
In CaptureBinding.initializeBounds, the null-related tagbits are not updated after invoking setSuperClass and setSuperinterfaces

PATCH (via gerrit).
Invokes TVB.evaluateNullAnnotations (with null as TypeParameter, which now means that now conflicts should be reported which should be ok as they should have been already reported on the actual type that was captured)
Comment 1 Eclipse Genie CLA 2015-12-31 11:46:49 EST
New Gerrit change created: https://git.eclipse.org/r/63399
Comment 2 Stephan Herrmann CLA 2016-01-04 12:58:54 EST
(In reply to Till Brychcy from comment #0)
> PATCH (via gerrit).
> Invokes TVB.evaluateNullAnnotations (with null as TypeParameter, which now
> means that now conflicts should be reported which should be ok as they
> should have been already reported on the actual type that was captured)

Can you please include a test case demonstrating this error reporting part?
Comment 3 Stephan Herrmann CLA 2016-01-04 13:16:29 EST
(In reply to Eclipse Genie from comment #1)
> New Gerrit change created: https://git.eclipse.org/r/63399

I'm too late to inspect the failure of hudson build #830. Did you have a look at that failure?
Comment 4 Till Brychcy CLA 2016-01-04 14:39:25 EST
(In reply to Stephan Herrmann from comment #3)
> (In reply to Eclipse Genie from comment #1)
> > New Gerrit change created: https://git.eclipse.org/r/63399
> 
> I'm too late to inspect the failure of hudson build #830. Did you have a
> look at that failure?

I can't remember any failed tests so probably it was a Hudson problem ( or i have overlooked it). I have just pushed an updated change to trigger another build (and used the opportunity to correct the indentation in TVB)
Comment 5 Stephan Herrmann CLA 2016-01-04 16:06:11 EST
(In reply to Till Brychcy from comment #4)
> (In reply to Stephan Herrmann from comment #3)
> > (In reply to Eclipse Genie from comment #1)
> > > New Gerrit change created: https://git.eclipse.org/r/63399
> > 
> > I'm too late to inspect the failure of hudson build #830. Did you have a
> > look at that failure?
> 
> I can't remember any failed tests so probably it was a Hudson problem ( or i
> have overlooked it). I have just pushed an updated change to trigger another
> build (and used the opportunity to correct the indentation in TVB)

Hudson signals: Regression

org.eclipse.jdt.core.tests.compiler.regression.NullTypeAnnotationTest.testTypeBounds1 - 1.8

We no longer report this one:

----------
3. ERROR in C.java (at line 17)
 la2.add(null); // ERR3
         ^^^^
Null type mismatch: required '? extends @Nullable A' but the provided value is null
----------
Comment 6 Till Brychcy CLA 2016-01-04 16:36:29 EST
i forgot, when testing locally i had tested with the fix for bug 484981 applied, which needs to be fixed first
Comment 7 Till Brychcy CLA 2016-01-06 18:31:00 EST
(In reply to Stephan Herrmann from comment #2)
> Can you please include a test case demonstrating this error reporting part?
OK, I have prepared one (I found bug 485302 on the way).
But let's fix bug 484981 first, before I push it to gerrit.
Comment 8 Till Brychcy CLA 2016-01-12 18:22:41 EST
rebased patch; extended test case so it shows error reporting for conflicting annotations. 

But I have noted (bug 485708) that (unrelated to type bounds) null annotations on the wildcards are not checked against those on the corresponding type variables
Comment 10 Stephan Herrmann CLA 2016-01-14 17:33:45 EST
(In reply to Till Brychcy from comment #8)
> rebased patch; extended test case so it shows error reporting for
> conflicting annotations. 

thanks, the new test illustrates well what you mean by "should have been already reported on the actual type that was captured". It also shows an unavoidable error on the method invocation, since no type argument can match the contradictory type parameter. We my consider avoiding such secondary problems by clearing the contradiction, but that's not essential for this bug.

Change has been merged for 4.6 M5, Thanks!
Comment 11 Jay Arthanareeswaran CLA 2016-01-23 00:23:14 EST
Verified for 4.6 M5 with build I20160119-0800