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

Bug 499817

Summary: The JDT compiler allows different return types for the same method name and parameters
Product: [Eclipse Project] JDT Reporter: Christian Schwarz <chriss.dev>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
The java project to reproduce this bug. none

Description Christian Schwarz CLA 2016-08-17 06:29:30 EDT
Created attachment 263631 [details]
The java project to reproduce this bug.

The following test case compiles fine JDT core version 3.10.2.v20150220-1634 but it should not complile.

public class Test {

    public  static <T> T foo(Matcher<T> p){
        return null;
    }
    
    public static long foo(Matcher<Long> p){
        return 0;
    }
    
    public  static int foo(Matcher<Integer> p){
        return 0;
    }
}

To reproduce it do the following:
 - create a new java project with execution enviroment J2SE-1.5
 - go to the project properies and set the compiler compliance level to "1.6"
 - now the above code compiles

The installed JRE was to one of JDK1.8.0_25
Comment 1 Eclipse Genie CLA 2020-04-21 05:25:39 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.
Comment 2 Stephan Herrmann CLA 2020-04-21 05:37:46 EDT
For posterity: the only weirdness here is, that at compliance 1.6 all name clashes are reported as warnings only, all other compliance levels (older as well as newer) correctly report errors.

This detail concerning compliance 1.6 is not a priority in JDT development.