src: Update init
[nit.git] / src / metrics / static_types_metrics.nit
index 5276632..4dd38d0 100644 (file)
@@ -41,20 +41,13 @@ private class ATypeCounterVisitor
 
        var typecount: Counter[MType]
 
-       # Get a new visitor on a classef to add type count in `typecount`.
-       init(modelbuilder: ModelBuilder, nclassdef: AClassdef, typecount: Counter[MType])
-       do
-               self.modelbuilder = modelbuilder
-               self.nclassdef = nclassdef
-               self.typecount = typecount
-       end
-
        redef fun visit(n)
        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)