model: MVirtualType fast resolution for the special type `SELF`
authorJean Privat <jean@pryen.org>
Mon, 8 Aug 2016 17:39:00 +0000 (13:39 -0400)
committerJean Privat <jean@pryen.org>
Mon, 8 Aug 2016 19:21:32 +0000 (15:21 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit

index 8e39f9b..0357df2 100644 (file)
@@ -1454,6 +1454,9 @@ class MVirtualType
        do
                if not cleanup_virtual then return self
                assert can_resolve_for(mtype, anchor, mmodule)
+
+               if mproperty.is_selftype then return mtype
+
                # self is a virtual type declared (or inherited) in mtype
                # The point of the function it to get the bound of the virtual type that make sense for mtype
                # But because mtype is maybe a virtual/formal type, we need to get a real receiver first
@@ -2263,6 +2266,9 @@ class MVirtualTypeProp
 
        # The formal type associated to the virtual type property
        var mvirtualtype = new MVirtualType(self)
+
+       # Is `self` the special virtual type `SELF`?
+       var is_selftype: Bool is lazy do return name == "SELF"
 end
 
 # A definition of a property (local property)