Inheritance

Mark Mahieu mark at twistedbanana.demon.co.uk
Fri May 16 11:20:12 PDT 2008


Well, the compiler should work the way the specification says it  
should ;)

Seriously though, while I can see that perhaps the spec could be  
changed to allow this in very specific circumstances - where it's  
possible to unambiguously generate a single bridge method for example  
(?) - I can't think of a convincing use case... do you have one?

Every time I've wanted a single class to implement the same generic  
interface multiple times with different type arguments, the types in  
question have been disjoint.

Or am I missing the point?

Mark


On 16 May 2008, at 15:24, tronicek at fel.cvut.cz wrote:

> Hi Mark,
>
> this is a perfect answer to question "Why the compiler prototype  
> does not compile it?". But should the compiler work this way? This  
> is the question I asked in my previous email.
>
> Z.
> -- 
> Zdenek Tronicek
> Department of Computer Science and Engineering
> Prague                   tel: +420 2 2435 7410
> http://cs.felk.cvut.cz/~tronicek
>
>
> Quoting Mark Mahieu <mark at twistedbanana.demon.co.uk>:
>
>> Hi Zdeněk,
>>
>> I think the problem here is that the types { => Integer }, { =>   
>> Number
>> } and { => Object } are all instances of the same generic  interface
>> (javax.lang.function.O<R,X>) but with different type  arguments, and
>> according to the JLS :
>>
>>
>> "A class may not at the same time be a subtype of two interface types
>> which are different invocations of the same generic interface
>> (§9.1.2), or an invocation of a generic interface and a raw type
>> naming that same generic interface.
>>
>> ...
>>
>> This requirement was introduced in order to support translation by
>> type erasure (§4.6)."
>>
>> (From http://java.sun.com/docs/books/jls/third_edition/html/
>> classes.html#8.1.5 )
>>
>>
>> Regards,
>>
>> Mark
>>
>>
>> On 16 May 2008, at 08:32, tronicek at fel.cvut.cz wrote:
>>
>>> Hi,
>>>
>>> this is compilable:
>>>
>>>    interface J1 {
>>>        Integer invoke();
>>>    }
>>>
>>>    interface J2 {
>>>        Number invoke();
>>>    }
>>>
>>>    interface J3 {
>>>        Object invoke();
>>>    }
>>>
>>>    interface J4 extends J1, J2, J3 { }
>>>
>>>    class C3 implements J1, J2, J3 {
>>>        public Integer invoke() { return null; }
>>>    }
>>>
>>>    class C4 implements J4 {
>>>        public Integer invoke() { return null; }
>>>    }
>>>
>>> and this is not:
>>>
>>>    interface I1 extends { => Integer } { }
>>>
>>>    interface I2 extends { => Number } { }
>>>
>>>    interface I3 extends { => Object } { }
>>>
>>>    interface I4 extends I1, I2, I3 { }
>>>
>>>    class C1 implements I1, I2, I3 {
>>>        public Integer invoke() { return null; }
>>>    }
>>>
>>>    class C2 implements I4 {
>>>        public Integer invoke() { return null; }
>>>    }
>>>
>>> But probably should be. As well as this:
>>>
>>>    interface Simple extends { => Integer }, { => Number }, { =>    
>>> Object } { }
>>>
>>> Zdenek
>>> -- 
>>> Zdenek Tronicek
>>> Department of Computer Science and Engineering
>>> Prague                   tel: +420 2 2435 7410
>>> http://cs.felk.cvut.cz/~tronicek
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
>




More information about the closures-dev mailing list