typing: new PostTypingVisitor that is run after the visit
authorJean Privat <jean@pryen.org>
Thu, 18 Jun 2015 01:49:38 +0000 (21:49 -0400)
committerJean Privat <jean@pryen.org>
Thu, 18 Jun 2015 01:49:38 +0000 (21:49 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/typing.nit

index 4868fc9..ffd68e7 100644 (file)
@@ -748,6 +748,9 @@ redef class AMethPropdef
                        if not v.has_loop or not v.dirty then break
                end
 
+               var post_visitor = new PostTypingVisitor(v)
+               post_visitor.enter_visit(self)
+
                if not nblock.after_flow_context.is_unreachable and msignature.return_mtype != null then
                        # We reach the end of the function without having a return, it is bad
                        v.error(self, "Error: reached end of function; expected `return` with a value.")
@@ -755,6 +758,19 @@ redef class AMethPropdef
        end
 end
 
+private class PostTypingVisitor
+       super Visitor
+       var type_visitor: TypeVisitor
+       redef fun visit(n) do
+               n.visit_all(self)
+               n.accept_post_typing(type_visitor)
+       end
+end
+
+redef class ANode
+       private fun accept_post_typing(v: TypeVisitor) do end
+end
+
 redef class AAttrPropdef
        redef fun do_typing(modelbuilder: ModelBuilder)
        do