Skip to content

Optimize unconditional return null to no return or void return #10332

@niloc132

Description

@niloc132

In Javascript, a method that ends without a return, or a return with no value, will return the value undefined. Since GWT already can handle undefined/null interchangably, we should then be able to support undefined in more places and save a few bytes by replacing return null with either return where we need the control break, or remove it entirely such as at the end of a method.

This must be done in JS optimizations, since it would be illegal in Java. It should be done fairly late too, as it shouldn't impact inlining, just improve output. Care must however be taken to not apply this to code originally writing in JS (e.g. JSNI), as it could in theory break Cast.maskUndefined() or the like, and force it to return undefined instead of the expected null.

This could impact native JsInterop types, so #10331 should be resolved first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions