Merge: contracts: fix usage of contract with `--erasure`
[nit.git] / src / saf / saf_base.nit
index 26d55ba..fcc409e 100644 (file)
@@ -56,6 +56,13 @@ abstract class StaticAnalysis
        # implementation of this method is the responsability the subclass.
        fun new_initial_flow: FLOW is abstract
 
+       # Initial flow set to use within methods.
+       #
+       # Returns `new_initial_flow` by default.
+       # Redefine this method to inject things in the inset like parameters from
+       # the signature.
+       fun new_initial_method_flow(v: AMethPropdef): FLOW do return new_initial_flow
+
        # The merge operation on sets for confluence.
        #
        # Depends on the analysis performed.
@@ -227,3 +234,13 @@ redef class AForExpr
                accept_loop_forward_analysis(v)
        end
 end
+
+redef class AMethPropdef
+       redef fun accept_forward_analysis(v) do
+               v.current_inset = v.new_initial_method_flow(self)
+               v.current_outset = v.current_inset.clone
+               v.insets[self] = v.current_inset
+               visit_all(v)
+               v.outsets[self] = v.current_outset
+       end
+end