Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: What's the best way to make a cross string set? Date: Thu, 3 Aug 2017 14:33:23 -0000 (UTC) Organization: A noiseless patient Spider Lines: 42 Message-ID: References: <6f9ff338-1944-4b64-83b8-4a921ce57a89@googlegroups.com> <69ec0210-e2a0-4823-98f0-8fc72e5c5db9@googlegroups.com> <3664ab4d-9619-43d0-9535-1ce7ab4d4438@googlegroups.com> Reply-To: avl@logic.at Injection-Date: Thu, 3 Aug 2017 14:33:23 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="3372b44961abf9e24369633da1e6adcb"; logging-data="9393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YSuRTqInVosbKUe5tkeP7" User-Agent: slrn/1.0.2 (Linux) Cancel-Lock: sha1:wGG59E/Yd5p809E1H3b21wBAldI= Xref: csiph.com comp.lang.java.programmer:37054 Eric Douglas wrote: > On Wednesday, August 2, 2017 at 5:27:01 AM UTC-4, Andreas Leitgeb wrote: >> Are you sure that you had to change it? The could be just fine >> in many cases. It just means that the generics class itself doesn't >> give a dime about it's parameter type or any restrictions on it. >> It's certainly *not* just eclipse saying "dunno". > Yes, for instance I have a method declared as > protected Comparable getCompareValue() { > I call this method from > final Comparable compareMe = getCompareValue(); > Eclipse auto-changes this to > final Comparable> compareMe = getCompareValue(); I cannot reproduce that with my (oldish) Eclipse 3.8.1 here. With "add type arguments" it seems to just add "", and with "Change type to Comparable" it obviously changes it to Comparable, but I didn't get it to change it to Comparable>. Generally, Comparable makes little sense based on what Comparable is designed for, namely as an anti-symmetric operation. I was even surprised that Comparable does not restrict its type argument, but then I remembered that were it defined like Comparable> then it wouldn't be possible to use it with anonymous classes. Maybe a newer eclipse than mine has some hardcoded "knowledge" of Comparable and therefore tries to make something more sensible than the locked-down interface would imply. > If I just fix it to match it works fine. > final Comparable compareMe = getCompareValue(); Consider changing already getCompareValue() to return something better than Comparable. > Somehow Eclipse didn't know it needed to be Comparable > even though it auto-added the to the return value on > the method. That might have been deduced from your implementation of getCompareValue().