From: Jean Privat Date: Fri, 10 Mar 2017 15:32:15 +0000 (-0500) Subject: nitc: adaptive typing apply non-nullness when fallbacking X-Git-Url: http://nitlanguage.org nitc: adaptive typing apply non-nullness when fallbacking Signed-off-by: Jean Privat --- diff --git a/src/semantize/typing.nit b/src/semantize/typing.nit index 9813284..0bbe61b 100644 --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@ -580,7 +580,16 @@ private class TypeVisitor return mtypes.first else var res = merge_types(node,mtypes) - if res == null then res = variable.declared_type + if res == null then + res = variable.declared_type + # Try to fallback to a non-null version + if res != null and can_be_null(res) then do + for t in mtypes do + if t != null and can_be_null(t) then break label + end + res = res.as_notnull + end label + end return res end end