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

Some method resolution diagnostic should be improved

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 7
    • tools
    • b40
    • unknown
    • generic
    • Not verified

      The latest refactoring of diagnostic formatters (6720185) contained also an inprovement of method resolution error messages; that is instead of printing a message of the kind:

      Test.java:8: test(X1, X2, ... Xn) in Test cannot be applied to (A1, A2, ... An)

      javac now prints the following message:

      Test.java:8: method test in class Test cannot be applied to given types
      required: X1, X2 ... Xn
      found: A1, A2 ... An

      This diagnostic works better than the former one, as it is more compact and easier to read. However there is a problem with this diagnostic: since either the actual argument list or the formal argument list can be an empty list (no arguments accepted/provided) this causes weird error messages:

      Test.java:8: method test in class Test cannot be applied to given types
      required:
      found: A1, A2 ... An

      The diagnostic output could be improved as follows:

      Test.java:8: method test in class Test cannot be applied to given types
      required: no arguments
      found: A1, A2 ... An

      Moreover, the diagnostic for unchecked method call should reflect this new layout; it currently sticks to the old layout for resolution errors:

      Test2.java:8: warning: [unchecked] unchecked method invocation: <T>m2(Test<T>) in Test is applied to (Test)

      instead of:

      Test2.java:8: warning: [unchecked] unchecked method invocation: method <T>m2(Test<T>) in class Test is applied to given types
      required: Test<T>
      found: Test

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: