Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-11106

Failed to detect an ambiguous method call?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Information Provided
    • None
    • None
    • Static Type Checker

    Description

      I have the following code:

      import java.io.*;
      import java.util.*;
      
      
      class Main {
        void test() {
          ObjectOutputStream y = null;
          m(y); 
        }
      
        Number m(OutputStream x) { return 1; }
        Number m(DataOutput x) { return 2; }
      }
      

      Actual behaviour

      The code compiles successfully. The compiler resolves the second method, that is m(DataOutput).

      Expected behaviour

      It seems that the method call is ambiguous, and thus the compiler should have rejected the above program. javac seems to reject the program with a method ambiguity error.

      Attachments

        Activity

          People

            Unassigned Unassigned
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: