Bug 211354 - [compiler] JDT compiler wrongly reports "The method ... is ambiguous for the type ..." (1.3 compliance)
Summary: [compiler] JDT compiler wrongly reports "The method ... is ambiguous for the ...
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-28 18:54 EST by Mirko Raner CLA
Modified: 2008-04-29 05:43 EDT (History)
2 users (show)

See Also:


Attachments
Zip file containing two projects that demonstrate the bug (8.28 KB, application/zip)
2007-11-28 18:54 EST, Mirko Raner CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mirko Raner CLA 2007-11-28 18:54:23 EST
Created attachment 84028 [details]
Zip file containing two projects that demonstrate the bug

Build ID: M20060921-0945

Steps To Reproduce:
1. Import the projects ast.api and ast.api.test into the workspace
2. Notice that there are 4 compilation errors in ReferenceCollectorTest
3. Change the compiler compliance of project ast.api.test to 1.4
4. Notice that the compilation errors go away



More information:
There is apparently a JDT compilation problem in Eclipse 3.2.1. The setup to reproduce the bug consists minimally of the following classes:

- class MethodInvocation extends java.lang.Object
  (empty dummy class)

- class AdapterMethodInvocation extends MethodInvocation
  (empty dummy class)

- class FactoryMethodInvocation extends MethodInvocation
  (empty dummy class)

- abstract class ASTVisitor
  - boolean visit(MethodInvocation)
  - boolean visit(FactoryMethodInvocation)
  - boolean visit(AdapterMethodInvocation)

- abstract class ASTVisitorAdapter extends ASTVisitor
  (has dummy implementations for all ASTVisitor methods)

- class ReferenceCollector extends ASTVisitorAdapter
  (overrides visit(MethodInvocation))

- class ReferenceCollectorTest (in a separate project)
  (calls ReferenceCollector.visit(MethodInvocation))

Both projects must have a compiler compliance of 1.3 for the bug to occur. The JDT compiler falsely reports

  "The method visit(MethodInvocation) is ambiguous for the type ReferenceCollector."

There is actually no reason for any ambiguity. The bug goes away if the compiler compliance of the second project (the one that contains ReferenceCollectorTest) is switched to 1.4.
Comment 1 Mirko Raner CLA 2007-12-05 20:55:12 EST
This problem can be observed not only with 3.2.1 but also with 3.3.1.1.
Comment 2 Kent Johnson CLA 2008-03-26 12:17:01 EDT
Actually there is a reason for the ambiguity according to the spec in 1.3 (both the methods in ReferenceCollector and its superclass match)

The spec was changed in 1.4 so that is why you do not see the problem anymore.

Compiling your example with javac 1.3 results in the same ambiguous errors as you see in Eclipse & changing to 1.4, the errors go away.
Comment 3 Mirko Raner CLA 2008-04-16 16:24:26 EDT
(In reply to comment #2)
> Actually there is a reason for the ambiguity according to the spec in 1.3 (both
> the methods in ReferenceCollector and its superclass match)
> 
> The spec was changed in 1.4 so that is why you do not see the problem anymore.

Wow, you're right. I was trying to find out where in the JLS this change is described. Can you point me to the paragraph in the JLS (or JVMS) by any chance?
Comment 4 David Audel CLA 2008-04-29 05:43:45 EDT
Verified for 3.4M7 using I20080427-2000