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

Bug 77665

Summary: [infer type arguments] passing List to Object
Product: [Eclipse Project] JDT Reporter: Dirk Baeumer <dirk_baeumer>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Dirk Baeumer CLA 2004-11-03 11:17:55 EST
M3 test candidate

public class A {
	void foo() {
		List l= new ArrayList();
		l.add("Eclipse");
		l.add(new Integer(10));
		bar(l);
	}
	void bar(Object o) {
		((List)o).add(new A());
	}
}

Shouldn't we leave l as raw since we don't know what happens inside bar and we
don't analyze it.
Comment 1 Markus Keller CLA 2005-03-29 08:49:48 EST
Moving Milestone.
Comment 2 Markus Keller CLA 2005-05-27 03:56:23 EDT
The problem is that we don't follow the flow of l's element variable through the
Object o. The cast to List is dangerous anyway, and the cast to List<A> will
still be flagged with a Type Safety warning.

Deferring to 3.2.


Here's a more general example:

public class Try {
    public static void main(String[] args) {
        Sub<String, Integer> sub= new Sub<String, Integer>();
        Top<String> top= sub;
        // would have to leave sub raw, since element type B of sub is lost here
        Object object= sub; 
    }
}

class Top<A> {
    A a;
}

class Sub<A, B> extends Top<A> {
    B b;
}
Comment 3 Eclipse Genie CLA 2020-02-20 12:39:12 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. 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.