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

Bug 532819

Summary: [10][compiler] eclipse rejects code that is accepted by javac involving wildcards, generic methods and var declarations
Product: [Eclipse Project] JDT Reporter: Sasikanth Bharadwaj <sasikanth.bharadwaj>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, manoj.palat, stephan.herrmann
Version: 4.8   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard: stalebug

Description Sasikanth Bharadwaj CLA 2018-03-23 07:29:52 EDT
The code below compiles with javac but is rejected by eclipse
Not yet sure what causes this, but initial analysis reveals that this has to do with the nested generic method invocation. Somewhere along the line, U is instantiated to be Integer instead of ? super Integer resulting in the error.

public class Test {

	<T> A<? super T> getA(T t) {
		return null;
	}
	<U> A<U> getAU(A<U> u) {
		return null;
	}
	
	void foo() {
		A<? super Integer> a = getA(100);
		var var = getAU(getA(100)); 
		var = a; // error here - cannot convert from A<capture of ? super Integer> to A <Integer>
	}
}
class A<Q> {
	A(Q e) {	}
	
	A(A<Q> ae) {	}
}
Comment 1 Eclipse Genie CLA 2020-03-13 10:23:26 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.