+ var mapcla = v.try_get_mclass(self, "Map")
+ if mapcla != null and v.is_subtype(mtype, mapcla.get_mtype([objcla.mclass_type.as_nullable, objcla.mclass_type.as_nullable])) then
+ var coltype = mtype.supertype_to(v.mmodule, v.anchor, mapcla)
+ self.coltype = coltype
+ var variables = self.variables
+ if variables.length != 2 then
+ v.error(self, "Type Error: Expected two variables")
+ else
+ variables[0].declared_type = coltype.arguments[0]
+ variables[1].declared_type = coltype.arguments[1]
+ end
+ is_map = true
+ end
+
+ if is_col or is_map then
+ # get iterator method
+ var coltype = self.coltype.as(not null)
+ var itdef = v.get_method(self, coltype, "iterator", true)
+ if itdef == null then
+ v.error(self, "Type Error: Expected method 'iterator' in type {coltype}")
+ return
+ end
+ self.method_iterator = itdef.mproperty
+
+ # get iterator type
+ var ittype = itdef.msignature.return_mtype
+ if ittype == null then
+ v.error(self, "Type Error: Expected method 'iterator' to return an Iterator type")
+ return
+ end
+
+ # get methods is_ok, next, item
+ var ikdef = v.get_method(self, ittype, "is_ok", false)
+ if ikdef == null then
+ v.error(self, "Type Error: Expected method 'is_ok' in Iterator type {ittype}")
+ return
+ end
+ self.method_is_ok = ikdef.mproperty
+
+ var itemdef = v.get_method(self, ittype, "item", false)
+ if itemdef == null then
+ v.error(self, "Type Error: Expected method 'item' in Iterator type {ittype}")
+ return
+ end
+ self.method_item = itemdef.mproperty
+
+ var nextdef = v.get_method(self, ittype, "next", false)
+ if nextdef == null then
+ v.error(self, "Type Error: Expected method 'next' in Iterator type {ittype}")
+ return
+ end
+ self.method_next = nextdef.mproperty
+
+ if is_map then
+ var keydef = v.get_method(self, ittype, "key", false)
+ if keydef == null then
+ v.error(self, "Type Error: Expected method 'key' in Iterator type {ittype}")
+ return
+ end
+ self.method_key = keydef.mproperty
+ end
+ return
+ end
+
+ v.modelbuilder.error(self, "NOT YET IMPLEMENTED: Do 'for' on {mtype}")
+ end
+
+ redef fun accept_typing(v)
+ do
+ var mtype = v.visit_expr(n_expr)
+ if mtype == null then return
+
+ self.do_type_iterator(v, mtype)
+