Back to Intellij Community

AmbiguousMethodCall

java/java-impl/resources/inspectionDescriptions/AmbiguousMethodCall.html

2025.3-rc-2840 B
Original Source

Reports calls to a superclass method from an anonymous, inner or local class, if a method with the same signature exists in the code surrounding the class. In this case it may seem that a method from the surrounding code is called, when in fact it is a call to a method from the superclass.

To clarify the intent of the code, it is recommended to add an explicit super qualifier to the method call.

Example:

class Parent {
    void ambiguous(){}
  }

  class Example {
    void ambiguous(){}

    class Inner extends Parent {
      void example(){
        ambiguous(); //warning
      }
    }
  }

After the quick-fix is applied:

class Parent {
    void ambiguous(){}
  }

  class Example {
    void ambiguous(){}

    class Inner extends Parent {
      void example(){
        super.ambiguous();
      }
    }
  }