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

Bug 289307

Summary: [infer type arguments] Refactoring incorrectly infers the generic type of a returned variable (recursive List<List<...>>)
Product: [Eclipse Project] JDT Reporter: Vilas Jagannath <vbangal2>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug

Description Vilas Jagannath CLA 2009-09-13 21:24:43 EDT
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.14) Gecko/2009090216 Ubuntu/9.04 (jaunty) Firefox/3.0.14
Build Identifier: M20080221-1800

When the infer generic type refactoring is applied to a program using the generic List type along with a complex class hierarchy, the refactoring incorrectly infers the generic type for one of the variables which leads to the program not compiling any more. Please look at the steps for more details on how to reproduce this bug.

Reproducible: Always

Steps to Reproduce:
1. Copy the following code into a java file called A.java:

import java.util.List;

class A implements B, D {
    public List m() {
        List l = null;
        A a = null;
        l.add(a.m());
        return l;
    }
}

interface D {
    public List m();
}

interface B extends C {
    public List m();
}

interface C {
    public List m();
}

2. Apply the infer generic type refactoring on the program (with default options).

3. The application of the refactoring leads to the program not compiling any more because the generic type for A.m().l is incorrectly inferred. Here is the resulting non compilable program:

import java.util.List;

class A implements B, D {
    public List<List> m() {
        List<List<List>> l = null;
        A a = null;
        l.add(a.m());
        return l;
    }
}

interface D {
    public List<List> m();
}

interface B extends C {
    public List<List> m();
}

interface C {
    public List<List> m();
}
Comment 1 Eclipse Genie CLA 2020-03-08 04:51:24 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.