Bug 104655 - [1.5] inconsistent compiler behavior in generic methods
Summary: [1.5] inconsistent compiler behavior in generic methods
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-21 09:59 EDT by Adam Kiezun CLA
Modified: 2005-09-26 11:49 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2005-07-21 09:59:08 EDT
3.1
method1 compiles, method2 fails. As far as I can tell, their typing should be
the same.

class Test {
  <Sup, E1 extends Sup, E2 extends Sup> Sup method1(boolean b, E1 e1, E2 e2) {
    if (b)
      return e1;
    else
      return e2;
  }

  <Sup, E1 extends Sup, E2 extends Sup> Sup method2(boolean b, E1 e1, E2 e2) {
    return b ? e1 : e2;
  }
}
Comment 1 Philipe Mulet CLA 2005-07-21 12:40:58 EDT
Agree it looks strange. Now the rules for conditional operator have been changed
with 1.5 to infer most common supertype; which seems to yield Object.

Interestingly, javac agrees with us.
Comment 2 Adam Kiezun CLA 2005-07-21 12:43:01 EDT
just checked, it's a bug in javac too: 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042462
Comment 3 Philipe Mulet CLA 2005-07-22 10:33:46 EDT
Problem comes from that our LUB computation is performing erasure of supertypes,
thus getting rid of type parameters.

Added GenericTypeTest#test791
Fixed
Comment 4 Olivier Thomann CLA 2005-08-09 11:44:08 EDT
Verified for 3.2M1 (I20050808-2000)
Comment 5 David Audel CLA 2005-09-26 11:49:03 EDT
Verified using M20050923-1430 for 3.1.1