Tuesday, September 13, 2016

Re: Strange (BAD?) code generated


On Tuesday, September 13, 2016 at 5:27:50 PM UTC+2, Kirill Prazdnikov wrote:
This means that the compiler must throw an error:

If a type is not isNative=true
  and the type is never instantiated
  and the type is returned form JSNI\JsInterop

right ?

No, just like the compiler doesn't generate an error for other cases where it's guaranteed you'll have an NPE at runtime, even without jsinterop.

If your GwtNativeUtil.getBoundingClientRect(element) wasn't JSNI and returned 'null' (for example, a typo where you write 'if (element != null) return null;' instead of 'if (element == null) return null;' and somehow the compiler can infer that 'element' won't ever be 'null'; or of course the reverse: without the typo and the compiler somehow can infer that 'element' will always be 'null'), then it'd generate the same code (just without the call to getBoundingRect here).

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment