Bug 531202 - Java compilation succeeds when functions collide by type variable
Summary: Java compilation succeeds when functions collide by type variable
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7.2   Edit
Hardware: PC Windows 10
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact: Srikanth Sankaran CLA
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-15 08:55 EST by Bence Sipka CLA
Modified: 2023-06-01 06:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bence Sipka CLA 2018-02-15 08:55:20 EST
When the following code is compiled with Eclipse, it succeeds, but javac displays the following error:

interface Templated {
	public <K extends List<Integer> & Map<Float, Float>> K func();
}

Error: types java.util.Map<java.lang.Float,java.lang.Float> and java.util.List<java.lang.Integer> are incompatible; both define remove(java.lang.Object), but with unrelated return types
Comment 1 Eclipse Genie CLA 2020-06-11 20:16:31 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.

If you have further information on the current state of the bug, please add it. 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 Eclipse Genie CLA 2023-01-27 14:04:06 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.

If you have further information on the current state of the bug, please add it. 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 3 Srikanth Sankaran CLA 2023-06-01 06:04:27 EDT
Thanks, can reproduce. Apparently we check well formedness of type variable bounds only for class type variables and not for generic method's type variables.

This program generates an error at the declaration of T:

import java.util.List;
import java.util.Map;

interface Templated<T extends List<Integer> & Map<Float, Float>> {
	public <K extends List<Integer> & Map<Float, Float>> K func(); 
}

Description	Resource	Path	Location	Type
The return types are incompatible for the inherited methods Collection<Integer>.remove(Object), List<Integer>.remove(Object), Map<Float,Float>.remove(Object)	test.java	/_pasted_code_/src	line 4	Java Problem