src/contracts: Fix `null` omit argument error
authorDelja <deljarry.florian@gmail.com>
Fri, 14 Aug 2020 15:17:33 +0000 (11:17 -0400)
committerDelja <deljarry.florian@gmail.com>
Thu, 20 Aug 2020 21:36:06 +0000 (17:36 -0400)
Resolve contract error when the null parameter is omitted.

Signed-off-by: Delja <deljarry.florian@gmail.com>

src/contracts.nit

index f7b81fa..f732065 100644 (file)
@@ -587,7 +587,9 @@ redef class MMethod
                if not exist_contract_facet then
                        # If has no contract facet in intro just create it
                        if classdef != intro_mclassdef then
-                               create_facet(v, intro_mclassdef, contract_facet, self)
+                               var n_intro_face = create_facet(v, intro_mclassdef, contract_facet, self)
+                               n_intro_face.location = self.intro.location
+                               n_intro_face.do_all(v.toolcontext)
                        end
                        n_contract_facet = create_facet(v, classdef, contract_facet, self)
                else
@@ -834,6 +836,8 @@ redef class ASendExpr
                var actual_callsite = callsite
                if actual_callsite != null then
                        callsite = v.drive_callsite_to_contract(actual_callsite)
+                       # Set the signature mapping with the old value, this avoids having to re-check the callsite.
+                       callsite.signaturemap = actual_callsite.signaturemap
                end
        end
 end
@@ -844,6 +848,8 @@ redef class ANewExpr
                var actual_callsite = callsite
                if actual_callsite != null then
                        callsite = v.drive_callsite_to_contract(actual_callsite)
+                       # Set the signature mapping with the old value, this avoids having to re-check the callsite
+                       callsite.signaturemap = actual_callsite.signaturemap
                end
        end
 end