Lambda and parameterized ref of an inline type doesn't work well
Srikanth
srikanth.adayapalam at oracle.com
Sun May 10 12:32:54 UTC 2020
On 09/05/20 5:03 pm, forax at univ-mlv.fr wrote:
> ----- Mail original -----
>> De: "Srikanth" <srikanth.adayapalam at oracle.com>
>> À: "Remi Forax" <forax at univ-mlv.fr>
>> Cc: "valhalla-dev" <valhalla-dev at openjdk.java.net>
>> Envoyé: Samedi 9 Mai 2020 02:52:26
>> Objet: Re: Lambda and parameterized ref of an inline type doesn't work well
>> On 08/05/20 8:36 pm, Remi Forax wrote:
>>> [move to valhalla-dev]
>>>
>>> Hi Srikanth,
>>> This seems to fix the lambda bug but not the one with the enhanced for loop.
>> "not the one with enhanced for loop" - I'll take a look, but was this
>> reported earlier ?
>> Your wording seems to indicate so, but I seem to have missed the report
>> and am hearing it only now.
> I've mention it in the comment section of JDK-8244559, for me it comes from the same piece code but it's maybe another error.
Ah, you are right, I missed noticing that - anyway it is a separate
problem so I will tackle it on a separate ticket.
Srikanth
>
>> In any case, I expect to have a fix soon. Thanks so much for testing and
>> the defect reports!
> No, thank you for your impressive work.
>
>> Srikanth
> Rémi
>
> [1] https://bugs.openjdk.java.net/browse/JDK-8244559
>
>>> Here, the inline type is itself a generics so it should work as usual.
>>>
>>> @__inline__ static class Foo<V> implements Iterable<V> {
>>> int x = 3;
>>>
>>> public Iterator<V> iterator() {
>>> return null;
>>> }
>>> }
>>>
>>>
>>> public static void main(String[] args) {
>>> Foo<String> foo = new Foo<String>();
>>> for(var s: foo) {
>>> }
>>> }
>>>
>>>
>>> $javac Hello.java
>>> Hello.java:15: error: for-each not applicable to expression type
>>> for(var s: foo) {
>>> ^
>>> required: array or java.lang.Iterable
>>> found: Foo<String>
>>> 1 error
>>>
>>> regards,
>>> Rémi
>>>
>>> ----- Mail original -----
>>>> De: "Srikanth" <srikanth.adayapalam at oracle.com>
>>>> À: "amber-dev" <amber-dev at openjdk.java.net>
>>>> Envoyé: Vendredi 8 Mai 2020 15:00:46
>>>> Objet: Re: Lambda and parameterized ref of an inline type doesn't work well
>>>> Hello Remi,
>>>>
>>>> Thanks for the report - this should be fixed by the commit
>>>> https://github.com/openjdk/valhalla/commit/e586cdbe made for
>>>> https://bugs.openjdk.java.net/browse/JDK-8244559
>>>>
>>>> With this all three problems reported are solved and should work now.
>>>>
>>>> (The inline + record synthesized methods is open)
>>>>
>>>> Srikanth
>>>>
>>>> On 07/05/20 4:07 am, Remi Forax wrote:
>>>>> @__inline__ static class Foo<V> {
>>>>> int x;
>>>>> Foo(int x) { this.x = x; }
>>>>> }
>>>>>
>>>>> static void m(Foo foo) {
>>>>> System.out.println("inline");
>>>>> }
>>>>> static void m(Foo.ref foo) {
>>>>> System.out.println("ref");
>>>>> }
>>>>>
>>>>> public static void main(String[] args) {
>>>>> List<Foo.ref<Integer>> list = List.of(new Foo<Integer>(3));
>>>>> list.stream().forEach(e -> m(e));
>>>>> }
>>>>>
>>>>> I don't even understand the error message when playing with parameterized ref of
>>>>> an inline type.
>>>>>
>>>>> error: cannot select a static class from a parameterized type
>>>>> Hello.java:19: error: incompatible types: incompatible parameter types in lambda
>>>>> expression
>>>>> list.stream().forEach(e -> m(e));
>>>>> ^
>>>>>
>>>>> regards,
>>>>> Rémi
More information about the valhalla-dev
mailing list