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

Bug 308682

Summary: [1.5][compiler] Complicated generic inference confuses the compiler
Product: [Eclipse Project] JDT Reporter: Kengo Hashimoto <kengo.hashimoto>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: CLOSED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: kreved, Olivier_Thomann
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
Junit tests none

Description Kengo Hashimoto CLA 2010-04-09 14:10:24 EDT
Build Identifier: 20100218-1602

We have a complicated set of types referring to each other, which seems to confuse the compiler. 

Sun's javac, version 1.6.0_18, compiles it with no warnings or errors.

-----
public interface Type {}
public interface ExtType extends Type {}
public class TypeImpl<STORE extends Store<? extends Type, ? extends TypeImpl<STORE>>> {}
public class Store<TYPE extends Type, IMPLTYPE extends TypeImpl<? extends Store<TYPE,IMPLTYPE>>> {}
public class ExtStore<TYPE extends ExtType, IMPLTYPE extends TypeImpl<? extends Store<TYPE,IMPLTYPE>>> extends Store<TYPE,IMPLTYPE> {}
public class ExtTypeImpl<STORE extends ExtStore<? extends ExtType,? extends TypeImpl<STORE>>> extends TypeImpl<STORE> {}

Reproducible: Always

Steps to Reproduce:
1. place the above classes in appropriate files
2. compile them using Eclipse
Comment 1 Srikanth Sankaran CLA 2010-07-14 04:32:27 EDT
Created attachment 174264 [details]
Junit tests

These tests capture the current (suspect) behavior.

This case works alright at 3.3.2 and seems to have
been broken since 3.4.

FWIW, see that the compile error goes away if the
code is changed to:

public interface Type {}
interface ExtType extends Type {}
class TypeImpl<STORE extends Store<? extends Type, ? extends TypeImpl<STORE>>> {}
class Store<TYPE extends Type, IMPLTYPE extends TypeImpl<? extends Store<TYPE,IMPLTYPE>>> {}
class ExtStore<TYPE extends ExtType, IMPLTYPE extends TypeImpl<? extends ExtStore<TYPE,IMPLTYPE>>> extends Store<TYPE,IMPLTYPE> {}
class ExtTypeImpl<STORE extends ExtStore<? extends ExtType,? extends TypeImpl<STORE>>> extends TypeImpl<STORE> {}

Under investigation.
Comment 2 burdakovd CLA 2010-10-28 15:03:49 EDT
The following generic code also failed to compile with Eclipse (3.6.0, 3.6.1) but successfully compiles under javac 1.6.0_20 / 1.6.0_22 .

Not sure if this is the same issue or should I create another bug?


class Main {
	
    interface Transformable<T extends Transformable<?>> {
        T transform();
    }
 
    <I extends Transformable<? extends I>> I test(final I input) {
 
        final I ans = input.transform().transform(); // can't compile!
 
        // final I ans1 = input.transform();
        // final I ans = ans1.transform(); // this works!
 
        return ans;
    }
}
Comment 3 Eclipse Genie CLA 2020-02-20 12:38:19 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.