Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] Improving capture readable names

Currently, the following (invalid) program is rejected, but the error
message is slightly misleading.


   import java.util.List;

   public class X {
      void foo(List<? extends Exception> l1, List<? extends Exception> l2)
   {
            l1.add(l2.get(0));
      }
   }

Compiler says:
      The method add(capture-of ? extends Exception) in the type
List<capture-of ? extends Exception> is not applicable for the arguments
(capture-of ? extends Exception)

Note that there are 2 instances of captures, which end up being not
distinguishable in the message. Along the lines of
http://blogs.sun.com/ahe?entry=diagnosing_captured_wildcards, I am
proposing to improve the rendering into something telling the capture
number.


Like one of the following:

1-The method add(capture$1-of ? extends Exception) in the type
List<capture$1-of ? extends Exception> is not applicable for the arguments
(capture$2-of ? ? extends Exception)

2-The method add(capture#1-of ? extends Exception) in the type
List<capture#1-of ? extends Exception> is not applicable for the arguments
(capture#2-of ? ? extends Exception)

3-The method add(capture-1-of ? extends Exception) in the type
List<capture-1-of ? extends Exception> is not applicable for the arguments
(capture-2-of ? ? extends Exception)

4-The method add(capture1-of ? extends Exception) in the type
List<capture1-of ? extends Exception> is not applicable for the arguments
(capture2-of ? ? extends Exception)

5-The method add(capture[1]-of ? extends Exception) in the type
List<capture[1]-of ? extends Exception> is not applicable for the arguments
(capture[2]-of ? ? extends Exception)

6-The method add(capture'1-of ? extends Exception) in the type
List<capture'1-of ? extends Exception> is not applicable for the arguments
(capture'2-of ? ? extends Exception)

7-Other?

Please indicate your preference.



Back to the top