Bug 14440

Summary: Possible bug in compiling inner classes
Product: [Eclipse Project] JDT Reporter: Randy Hudson <hudsonr>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M6   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Randy Hudson CLA 2002-04-23 13:57:19 EDT
public class Outer extends BaseClass {
  static class Inner extends ClassWithAMethodCalledFoo {
    void bar(){
      foo();//COMPILER COMPLAINS THAT THIS IS AMBIGUOUS.
    }
  }

  void foo(){}
}

Note that Outer.this.foo() is not really visible because there is no enclosing 
instance with which Inner could call Outer's foo.  Yet, the compiler says it is 
ambiguous.
Comment 1 Olivier Thomann CLA 2002-04-23 16:12:34 EDT
This seems to be a compliance problem. If you are compiling such a code with a JDK 1.3.x compiler, it 
will complain as well. If you compile with a 1.4 compiler, it doesn't complain.
Our compiler has 
two compliance modes. If you compile such a senario with -1.3 (compliance 1.3), it complains that 
there is an ambiguity. But if you compile with -1.4 (compliance 1.4), it doesn't complain. The 
compliance can be set on the compiler preference page.
Does it work for you if you set the 
compliance to 1.4?
Comment 2 Randy Hudson CLA 2002-04-23 16:44:20 EDT
I have refactored my code already to remove this inner class, so I can't test 
it right now.  I knew it seemed strange.  At least the 1.4 compiler spec 
is "smarter".  I'm closing.
Comment 3 Philipe Mulet CLA 2002-04-23 18:18:06 EDT
This is the intended behavior. With 1.4 compliance, inherited members will 
prevail against enclosing ones. In 1.3 mode, we had to find ambiguities in 
order to pass JCK tests. The new behavior is following the JLS 1.2, and 
shouldn't change (I hope).
Comment 4 Randy Hudson CLA 2002-04-23 21:44:15 EDT
This really isn't an ambiguous call.  It is a falsely reported ambiguity.  If I 
try to call Outer.this.foo(), I get an error saying there is no enclosing 
instance because the inner class is *static*.

I understood from the first response that reporting this false ambiguity was 
required to pass 1.3 compatibility tests.

Now it sounds as though you are saying that in 1.4 the ambiguity is handled by 
preferring the inherited method.  Is this for static inner classes, or both 
static and instance?