model: bring back call site doc to highlight as `CallSite::mdoc_or_fallback`
[nit.git] / src / semantize / typing.nit
index 9813284..fc89e5f 100644 (file)
@@ -81,11 +81,6 @@ private class TypeVisitor
 
        fun anchor_to(mtype: MType): MType
        do
-               var anchor = anchor
-               if anchor == null then
-                       assert not mtype.need_anchor
-                       return mtype
-               end
                return mtype.anchor_to(mmodule, anchor)
        end
 
@@ -580,7 +575,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
@@ -781,6 +785,8 @@ class CallSite
        fun dump_info(v: ASTDump): String do
                return "{recv}.{mpropdef}{msignature}"
        end
+
+       redef fun mdoc_or_fallback do return mproperty.intro.mdoc
 end
 
 redef class Variable