Bug 337751

Summary: COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS misses references in conditional expression
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, jarthana
Version: 3.7   
Target Milestone: 3.7 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch under consideration none

Description Markus Keller CLA 2011-02-21 13:44:52 EST
HEAD, follow-up to bug 322817

The JavaCore.COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS option misses references in conditional expressions.

In the example below, generifying Project#getOptions() gets rid of the type safety warning, and the compiler option should also hide it.


package problems;
import java.util.Map;

public class Project {
    //raw return type (assume in 1.4 code)
    public Map/*<String, String>*/ getOptions(boolean b) {
        return null;
    }
}

package problems;
import java.util.Map;

public class GenericConditional {
    void foo(Project project) {
        // Bad warning: "Type safety: The expression of type Map needs
        //    unchecked conversion to conform to Map<String,String>"
        Map<String, String> options=
                        project != null ? project.getOptions(true) : null;
        System.out.println(options);
    }
}
Comment 1 Ayushman Jain CLA 2011-02-21 14:34:06 EST
Srikanth, please investigate. Thanks!
Comment 2 Srikanth Sankaran CLA 2011-03-14 10:58:35 EDT
Created attachment 191125 [details]
Patch under consideration
Comment 3 Srikanth Sankaran CLA 2011-03-15 01:46:39 EDT
Added regression tests
org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest.test337751
org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest.test337751a

Released in HEAD for 3.7 M7
Comment 4 Jay Arthanareeswaran CLA 2011-04-25 04:56:52 EDT
Verified for 3.7M7 using build I20110421-1800
Comment 5 Ayushman Jain CLA 2011-05-03 06:07:00 EDT
Verified for 3.7RC0 using I20110428-0845