It is fixed internally. asArray API replaced with asList API

On Mon, Jul 24, 2017 at 3:11 PM, Goktug Gokdogan <[email protected]> wrote:

> For following code:
>
> class A<T> {
>   T[] asArray {}..
> }
>
> A<String> st;
> String[] arr = st.asArray();
>
> I wasn't expecting an erasure cast at the call site for this but seems
> like I was wrong and erasure cast seems right here otherwise you cannot
> guarantee that arr[0] which won't have a cast to return String.
>
> We should be able to repro this in jsinterop.base; will take a look.
>
>
> On Sun, Jul 23, 2017 at 8:18 PM, Colin Alworth <[email protected]> wrote:
>
>> Using GWT 2.8.1, I'm trying to iterate through items found via a query
>> selector:
>>
>> Arrays.asList(document.querySelectorAll("button.with-some-class").asArray
>> ()).forEach(
>>         item -> doSomething(item)
>> );
>>
>> Unfortunately, this seems to always fail - querySelectorAll returns a
>> NodeList<Element>, and while asArray() seems to specify Js.uncheckedCast,
>> the resulting generated code is
>>
>> $forEach_1(new Arrays$ArrayList(*castToJsArray*(($clinit_DomGlobal() ,
>> document_0).querySelectorAll('button.with-some-class'))), new
>> SampleClass$lambda$0$Type);
>>
>> Predictable, the bolded castToJsArray causes an exception at runtime,
>> since a NodeList isn't actually a JS Array at all.
>>
>> Is there a correct way to do this, or perhaps a nicer way to iterate
>> through NodeLists?
>>
>> I assume this should be a bug filed against jsinterop-base, but am not
>> seeing a repo for it, or is this a bug in GWT itself?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "GWT Contributors" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/google-web-toolkit-contributors/4764126b-ed92-409a-bb4b-
>> d1d1fead2e3c%40googlegroups.com
>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/4764126b-ed92-409a-bb4b-d1d1fead2e3c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA3o45d%3DO9nDyVX0z_gb%2BTzkgAh_EVwOdfmO2qhxNQ5p3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to