Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4033865

Identical signatures cause ambiguity during overload resolution

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1
    • tools
    • None
    • x86
    • windows_95



      Name: mc57594 Date: 02/21/97


      if the primary expression of a method invocation has interface
      type, and that interface inherits two methods with the same signature, the
      compiler reports an ambiguity if f() is called through the derived
      interface, even though the signatures are identical and so should be
      treated as one entity for the purposes of overload resolution. (Guy Steele
      has confirmed this interpretation of the JLS.)

      Sample code:

      interface A {
          void f ();
      }

      interface B {
          void f ();
      }

      interface C extends A, B {
      }

      class D {
          void g (C c) {
              c.f(); // this should not be ambiguous
          }
      }

      Note that if C is an abstract class not an interface the code compiles
      correctly.
      ======================================================================

            tturnidgsunw Todd Turnidge (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: