Integrated: Improve support for nullable types and arrays

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Aug 28 14:10:46 UTC 2024


On Wed, 28 Aug 2024 11:58:56 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR improves general support for arrays with `!` and `?` nullness markers.
> 
> The parser was parsing nullness markers associated to array brackets "backwards" - that is, when we have a type like this:
> 
> 
> String* []? []!
> 
> 
> * `*` should refer to `String`
> * `?` should refer to the outermost array type
> * `!` should refer to the innermost array type
> 
> The same is true with an array creation expression, like:
> 
> 
> new String*[3]?[]!
> 
> 
> (in this case, one might even wonder what sense does it make to say `?` for an array dimension that is going to be filled with `null` elements, but that's for another day).
> 
> Most of the `toString` implementation for array types and array trees were also wrong and they either dropped markers, or they displayed them in the "wrong order". So I've fixed that too (which helps when debugging).
> 
> Finally, I realized that there were no nullness warnings generated when going from nullable arrays to non-nullable arrays, so I've added some more code in `Types` for that.

This pull request has now been integrated.

Changeset: 4999dfe1
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/valhalla/commit/4999dfe1c5679ff80e6d7fddabcb5d53bc3fd937
Stats:     237 lines in 12 files changed: 188 ins; 16 del; 33 mod

Improve support for nullable types and arrays

-------------

PR: https://git.openjdk.org/valhalla/pull/1227


More information about the valhalla-dev mailing list