From 1fa216c686a8e24bebbde7a8076ceeedf784a88b Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 10 Mar 2017 10:32:15 -0500 Subject: [PATCH] nitc: adaptive typing apply non-nullness when fallbacking Signed-off-by: Jean Privat --- src/semantize/typing.nit | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- 1.7.9.5