hg: lambda/lambda/langtools: Fix: Add extra checks when lambda/method ref is converted to intersection type
Remi Forax
forax at univ-mlv.fr
Wed Nov 28 11:07:18 PST 2012
On 11/28/2012 07:41 PM, Boaz Nahum wrote:
> Can you explain why?
> If I1 and I2 have same SAM why (I1 & I2) is not valid?
The main issue is that the current implementation relies on the fact
that there is only one SAM descriptor.
And trying to support more than one SAM descriptor will likely to reduce
our chance to optimize the object lambda creation in the VM.
> Can also explain why the order does matter?
When the compiler erase an intersection type, the first type is used as
primary type by the compiler
By example, Collections.max is written
<T extends Object & Comparable<? super T>> max(Collection<? extends
T> collection) (1)
and not
<T extends Comparable<? super T>> max(Collection<? extends T>
collection) (2)
once erased the return type of (1) is Object, the return type of (2) is
Comparable.
>
> Thx
> (sorry foy English )
> Boaz
cheers,
Rémi
> On Nov 28, 2012 12:34 PM, <maurizio.cimadamore at oracle.com> wrote:
>
>> Changeset: 7fa8e7c02baa
>> Author: mcimadamore
>> Date: 2012-11-28 10:31 +0000
>> URL:
>> http://hg.openjdk.java.net/lambda/lambda/langtools/rev/7fa8e7c02baa
>>
>> Fix: Add extra checks when lambda/method ref is converted to intersection
>> type
>>
>> A lambda/methdod reference can be converted to an intersection type
>> provided that:
>>
>> *) All types in the intersection are interface types
>> *) The first type of the intersection is a functional interface
>> *) The additional bounds of the intersection are marker interfaces
>>
>> ! src/share/classes/com/sun/tools/javac/code/Type.java
>> ! src/share/classes/com/sun/tools/javac/code/Types.java
>> ! src/share/classes/com/sun/tools/javac/comp/Attr.java
>> ! src/share/classes/com/sun/tools/javac/resources/compiler.properties
>> ! test/tools/javac/diags/examples.not-yet.txt
>> + test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java
>>
>>
>>
More information about the lambda-dev
mailing list