Not that it's an issue - as I can't see why that signature would ever be needed.
brianTue 29 Sep 2015
But led me to the interesting observation that MapType, and hence Maps in general, can't truly be nullable:
Subtle differences, but you need to separate the parameterized type of a Map instance versus a type signature - they are two separate things. For example this is allowed:
[Int:Int]? someMethod() { return null }
The method returns a map types Int:Int or null. However a given map instance by definition cannot be nullable. So the map type associated with it is non-nullable by definition.
SlimerDudeTue 29 Sep 2015
Okay, that makes sense - thanks for the explanation!
SlimerDude Tue 29 Sep 2015
Hi, I'm nit-picking here and I've largely written this for documentation reasons, but the following gives a compilation Err:
I tried creating one at runtime but got an
ArgErr:This patch fixes the
ArgErr:diff -r fe538d44fa4d src/sys/java/fan/sys/Map.java --- a/src/sys/java/fan/sys/Map.java Mon Sep 28 13:18:07 2015 -0400 +++ b/src/sys/java/fan/sys/Map.java Tue Sep 29 10:26:24 2015 +0100 @@ -32,6 +32,11 @@ public static Map make(Type type) { + if (type instanceof NullableType) + { + type = ((NullableType) type).root; + } + MapType t = null; try {But led me to the interesting observation that
MapType, and hence Maps in general, can't truly be nullable:Not that it's an issue - as I can't see why that signature would ever be needed.
brian Tue 29 Sep 2015
Subtle differences, but you need to separate the parameterized type of a Map instance versus a type signature - they are two separate things. For example this is allowed:
[Int:Int]? someMethod() { return null }The method returns a map types Int:Int or null. However a given map instance by definition cannot be nullable. So the map type associated with it is non-nullable by definition.
SlimerDude Tue 29 Sep 2015
Okay, that makes sense - thanks for the explanation!