Are function types a requirement?
Reinier Zwitserloot
reinier at zwitserloot.com
Sat Feb 20 15:22:47 PST 2010
... but the compiler catches this.
class B {
void m(String... a) {}
}
class C extends B {
void m(String[] a) {}
}
new C().m("a", "b");
is legal. It's not exactly a leap of faith to consider that the compiler
already knows that C's m() method is virtually varargs, and therefore gets
the same checks applied to it. At worst they get a warning, not a compiler
error.
If this is a bridge too far for the spec, then just drop it. That means you
get a warning when you pass a varargs on to another varargs, and the
strength of the proposal drops from eliminating completely unnecessary
warnings from 99.9999% of the time to merely 95% of the time. Worth it? Oh
yes.
--Reinier Zwitserloot
On Sat, Feb 20, 2010 at 12:31 AM, Neal Gafter <neal at gafter.com> wrote:
> On Fri, Feb 19, 2010 at 3:04 PM, Reinier Zwitserloot <
> reinier at zwitserloot.com> wrote:
>
>> I believe I mentioned that chaining varargs into another varargs is
>> actually allowed (and, as the same rules apply to the chained method, does
>> not weaken type safety, unless you mix compilation units compiled by
>> different versions of java, an act which has always had ample opportunity
>> for uncaught type errors). If not, that's an omission in putting it down in
>> this thread, it's always been part of this set of rules.
>>
>
> I'm afraid it does weaken type safety. A varargs method can override, and
> be overridden by, a non-varargs method.
>
More information about the lambda-dev
mailing list