nitc&lib: MapIterator keys can be nullable
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 15 Dec 2014 13:39:15 +0000 (08:39 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 13 Jan 2015 18:45:49 +0000 (13:45 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/standard/collection/abstract_collection.nit
lib/standard/string.nit
src/semantize/typing.nit

index d5621a9..bb17064 100644 (file)
@@ -377,7 +377,7 @@ interface Set[E: Object]
 end
 
 # MapRead are abstract associative collections: `key` -> `item`.
-interface MapRead[K: Object, V]
+interface MapRead[K, V]
        # Get the item at `key`
        #
        #     var x = new HashMap[String, Int]
@@ -492,7 +492,7 @@ end
 #     assert map.values.has(1)      ==  true
 #     assert map.values.has(3)      ==  false
 #
-interface Map[K: Object, V]
+interface Map[K, V]
        super MapRead[K, V]
 
        # Set the `value` at `key`.
@@ -552,7 +552,7 @@ interface Map[K: Object, V]
 end
 
 # Iterators for Map.
-interface MapIterator[K: Object, V]
+interface MapIterator[K, V]
        # The current item.
        # Require `is_ok`.
        fun item: V is abstract
@@ -583,7 +583,7 @@ interface MapIterator[K: Object, V]
 end
 
 # Iterator on a 'keys' point of view of a map
-class MapKeysIterator[K: Object, V]
+class MapKeysIterator[K, V]
        super Iterator[K]
        # The original iterator
        var original_iterator: MapIterator[K, V]
@@ -594,7 +594,7 @@ class MapKeysIterator[K: Object, V]
 end
 
 # Iterator on a 'values' point of view of a map
-class MapValuesIterator[K: Object, V]
+class MapValuesIterator[K, V]
        super Iterator[V]
        # The original iterator
        var original_iterator: MapIterator[K, V]
@@ -941,7 +941,7 @@ end
 
 # Associative arrays that internally uses couples to represent each (key, value) pairs.
 # This is an helper class that some specific implementation of Map may implements.
-interface CoupleMap[K: Object, V]
+interface CoupleMap[K, V]
        super Map[K, V]
 
        # Return the couple of the corresponding key
@@ -968,7 +968,7 @@ end
 # Iterator on CoupleMap
 #
 # Actually it is a wrapper around an iterator of the internal array of the map.
-private class CoupleMapIterator[K: Object, V]
+private class CoupleMapIterator[K, V]
        super MapIterator[K, V]
        redef fun item do return _iter.item.second
        
index c4ae7b0..f1d3288 100644 (file)
@@ -2174,7 +2174,7 @@ redef class Map[K,V]
                var i = iterator
                var k = i.key
                var e = i.item
-               s.append("{k}{couple_sep}{e or else "<null>"}")
+               s.append("{k or else "<null>"}{couple_sep}{e or else "<null>"}")
 
                # Concat other items
                i.next
@@ -2182,7 +2182,7 @@ redef class Map[K,V]
                        s.append(sep)
                        k = i.key
                        e = i.item
-                       s.append("{k}{couple_sep}{e or else "<null>"}")
+                       s.append("{k or else "<null>"}{couple_sep}{e or else "<null>"}")
                        i.next
                end
                return s.to_s
index ae697d4..8fb3852 100644 (file)
@@ -975,7 +975,7 @@ redef class AForExpr
                        is_col = true
                end
 
-               if mapit_cla != null and v.is_subtype(ittype, mapit_cla.get_mtype([objcla.mclass_type, objcla.mclass_type.as_nullable])) then
+               if mapit_cla != null and v.is_subtype(ittype, mapit_cla.get_mtype([objcla.mclass_type.as_nullable, objcla.mclass_type.as_nullable])) then
                        # Map Iterator
                        var coltype = ittype.supertype_to(v.mmodule, v.anchor, mapit_cla)
                        var variables = self.variables