rta: no-op when AExpr::mtype or AExpr::cast_type is null
authorJean Privat <jean@pryen.org>
Tue, 16 Jun 2015 13:30:17 +0000 (09:30 -0400)
committerJean Privat <jean@pryen.org>
Tue, 16 Jun 2015 13:30:17 +0000 (09:30 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/rapid_type_analysis.nit

index 8fd6ed4..365f6a4 100644 (file)
@@ -603,7 +603,8 @@ end
 redef class ACrangeExpr
        redef fun accept_rapid_type_visitor(v)
        do
-               var mtype = self.mtype.as(MClassType)
+               var mtype = self.mtype
+               if not mtype isa MClassType then return
                v.add_type(mtype)
                v.add_callsite(init_callsite)
        end
@@ -612,7 +613,8 @@ end
 redef class AOrangeExpr
        redef fun accept_rapid_type_visitor(v)
        do
-               var mtype = self.mtype.as(MClassType)
+               var mtype = self.mtype
+               if not mtype isa MClassType then return
                v.add_type(mtype)
                v.add_callsite(init_callsite)
        end
@@ -635,14 +637,18 @@ end
 redef class AIsaExpr
        redef fun accept_rapid_type_visitor(v)
        do
-               v.add_cast_type(self.cast_type.as(not null))
+               var cast_type = self.cast_type
+               if cast_type == null then return
+               v.add_cast_type(cast_type)
        end
 end
 
 redef class AAsCastExpr
        redef fun accept_rapid_type_visitor(v)
        do
-               v.add_cast_type(self.mtype.as(not null))
+               var mtype = self.mtype
+               if mtype == null then return
+               v.add_cast_type(mtype)
        end
 end