----- Mail original -----
> De: "Stuart Marks" <stuart.ma...@oracle.com>
> À: "Remi Forax" <fo...@univ-mlv.fr>
> Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net>
> Envoyé: Mercredi 21 Avril 2021 20:53:25
> Objet: Re: [External] : Re: ReversibleCollection proposal

> On 4/19/21 2:01 PM, Remi Forax wrote:
>> ----- Mail original -----
>> Thinking a little bit about your proposal,
>> introducing an interface right in the middle of a hierarchy is not a backward
>> compatible change
>> (you have an issue when the compiler has to use the lowest upper bound).
>> 
>> By example
>>    void m(List<Collection<String>> list) { ... }
>> 
>>    var list = List.of(new LinkedHashSet<String>(), List.of("foo"));
>>    m(list);  // does not compile anymore
>> 
>> currently the type of list is List<Collection<String>> but with your 
>> proposal,
>> the type will be List<ReversibleCollection<String>>
> 
> Yes, interesting. Not too difficult to fix though. Either change the method
> declaration to
> 
>     void m(List<? extends Collection<String>> list)
> 
> or change the 'var' to an explicit declaration of List<Collection<String>>.


or specify the type argument in between '.' and 'of'
  var list = List.<Collection<String>>of(new LinkedHashSet<String>(), 
List.of("foo"));

anyway, the issue here is that adding ReversibleCollection is a source breaking 
change,
which significantly raises the bar to add this interface.

> 
> s'marks

Rémi

Reply via email to