nitmetrics: dont crash if nclassdef.mclassdef is null
authorJean Privat <jean@pryen.org>
Thu, 3 Aug 2017 13:20:18 +0000 (09:20 -0400)
committerJean Privat <jean@pryen.org>
Thu, 3 Aug 2017 13:20:18 +0000 (09:20 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/metrics/static_types_metrics.nit

index 5276632..45c429b 100644 (file)
@@ -53,8 +53,9 @@ private class ATypeCounterVisitor
        do
                if n isa AAnnotation then return
 
-               if n isa AType then
-                       var mclassdef = self.nclassdef.mclassdef.as(not null)
+               if n isa AType then do
+                       var mclassdef = self.nclassdef.mclassdef
+                       if mclassdef == null then break
                        var mtype = modelbuilder.resolve_mtype(mclassdef, n)
                        if mtype != null then
                                self.typecount.inc(mtype)