Bug 193265 - [1.5][compiler] Incorrect ambiguous method error involving abstract classes and enums
Summary: [1.5][compiler] Incorrect ambiguous method error involving abstract classes a...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3.1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-19 03:04 EDT by Maxime Daniel CLA
Modified: 2007-09-17 10:43 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2007-06-19 03:04:47 EDT
I20070608-1718
The following test case yields an ambiguous method error with JDT, while neither javac 1.5.0_12 nor javac 6_02 complain.

public class X {
  enum A implements B {
    X;
  }
  interface B {
  }
  interface Spec {
    <T extends Enum<T> & B> void method(T t);
  }
  static abstract class TestAbstract implements Spec {
    public <T extends Enum<T> & B> void method(T t) {
    }
    public void test() {
      method(A.X); // ambiguous by JDT, but not javac
    }
  }
  static class TestConcrete implements Spec {
    public <T extends Enum<T> & B> void method(T t) {
    }
    public void test() {
      method(A.X);
    }
  }
}
Comment 1 Kent Johnson CLA 2007-06-19 12:10:27 EDT
This is a strange case.

We do not report a problem with this :

enum E implements I {
	F;
}
interface I {}
interface Spec {
	<T extends Enum<T> & I> void method(T t);
}
//abstract class X implements Spec {
class X implements Spec {
	public <T extends Enum<T> & I> void method(T t) {}
	void test() { method(E.F); }
}

But we do report an incorrect ambiguous error when X is abstract.
Comment 2 Kent Johnson CLA 2007-08-21 15:07:24 EDT
Added AmbiguousMethodTest 62

Released into HEAD for 3.4 M2

Released for 3.3.1
Comment 3 Philipe Mulet CLA 2007-08-29 06:25:13 EDT
+1 for 3.3.1
Comment 4 Maxime Daniel CLA 2007-09-03 07:42:56 EDT
The regression test leverages the scenario of comment 1, not the original test case provided. The former might well be a true proxy for the latter (at least the same fix addresses both situations), but since this is not that obvious when reading both, you may consider adding a regression test for the original test case.
Anyway,
Verified for 3.3.1 using build M20070831-2000.
Comment 5 Jerome Lanneluc CLA 2007-09-17 10:43:18 EDT
Verified for 3.4 using I20070917-0010