rta: guard `add_send` with a specific set, instead of overusing `live_methods`.
authorJean Privat <jean@pryen.org>
Tue, 22 Apr 2014 13:29:02 +0000 (09:29 -0400)
committerJean Privat <jean@pryen.org>
Fri, 25 Apr 2014 13:16:57 +0000 (09:16 -0400)
Eg. a monomorph method could be live, without being subject to try_send.

Signed-off-by: Jean Privat <jean@pryen.org>

src/rapid_type_analysis.nit

index c68d33a..1017b08 100644 (file)
@@ -161,9 +161,13 @@ class RapidTypeAnalysis
                return tree
        end
 
-       # Methods that are are still candidate to the try_send
+       # Methods that are still candidate to the try_send
        private var totry_methods = new HashSet[MMethod]
 
+       # Methods that are or were candidate to the try_send
+       # Used to ensure that try_send is only used once
+       private var try_methods = new HashSet[MMethod]
+
        # The method definitions that remain to visit
        private var todo = new List[MMethodDef]
 
@@ -379,9 +383,10 @@ class RapidTypeAnalysis
 
        fun add_send(recv: MType, mproperty: MMethod)
        do
-               if live_methods.has(mproperty) then return
+               if try_methods.has(mproperty) then return
                #print "new prop: {mproperty}"
                live_methods.add(mproperty)
+               try_methods.add(mproperty)
                if mproperty.mpropdefs.length == 1 then
                        # If there is only one definition, just add the definition and do not try again the property
                        var d = mproperty.mpropdefs.first