diff --git a/lib/7.8/modules/__default.pmod b/lib/7.8/modules/__default.pmod
index 51c6b13fc4763fa4adf0ce1b2edbf2c6f362a5ae..60807418b950bea68cd3b2fdeb377fc8bd5e2168 100644
--- a/lib/7.8/modules/__default.pmod
+++ b/lib/7.8/modules/__default.pmod
@@ -9,9 +9,28 @@
 
 //! @decl inherit predef::
 
+array|mapping|multiset|string map(array|mapping|multiset|string|object|program stuff, function(mixed,mixed...:mixed) f, mixed ... args)
+{
+  if(objectp(stuff))
+  {
+    if( catch { stuff = (array)stuff; } )
+      if( catch { stuff = (mapping)stuff; } )
+        if( catch { stuff = (multiset)stuff; } )
+          if( catch {
+              object o = stuff;
+              stuff = allocate(sizeof(o));
+              for( int i; i<sizeof(stuff); i++ )
+                stuff[i] = o[i];
+            } )
+           error("Bad argument 1 to map. Expected object that works in map.\n");
+  }
+  return 7.9::map(stuff, f, @args);
+}
+
 protected Mapping.ShadowedMapping compat_all_constants =
   Mapping.ShadowedMapping(predef::all_constants(),
 			  ([
+                            "map" : map,
 			  ]), 1);
 
 mapping(string:mixed) all_constants()
diff --git a/lib/7.8/modules/testsuite.in b/lib/7.8/modules/testsuite.in
index dafc7a258976e7e34501db661aa7860de611670f..78569d8599fed606ebeb9a0cfbc00cd85c337802 100644
--- a/lib/7.8/modules/testsuite.in
+++ b/lib/7.8/modules/testsuite.in
@@ -302,5 +302,6 @@ test_do([[
   class A { static int foo = 1; int bar() { return foo; } }
 ]])
 
+test_any_equal([[ class A { int a0=1,a1=2; protected int `[](int what) { return ::`[]("a"+what); } protected int _sizeof() { return 2; } }; return map(A(), `+, 1);]], ({2,3}))
 
 END_MARKER
diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index f1d69fbaa54662769e89e1cd601f583ed281fccf..b76b9a2692283475bffbcbe2658369121f72ca5c 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -8818,37 +8818,6 @@ PMOD_EXPORT void f_map(INT32 args)
              }
              pop_stack();
            }
-
-           /* if arr->_sizeof && arr->`[]
-              array ret; ret[i]=arr[i];
-              ret=map(ret,fun,@extra); */
-
-           f = FIND_LFUN(o->prog->inherits[osub].prog,
-                         LFUN_INDEX) |
-             FIND_LFUN(o->prog->inherits[osub].prog,
-                       LFUN__SIZEOF);
-
-           if( f != -1 )
-           {
-             struct svalue tmp;
-             TYPEOF(tmp) = PIKE_T_INT;
-             SUBTYPEOF(tmp) = 0;
-             n=pike_sizeof(mysp-3);
-             push_array(d=allocate_array(n));
-             types = 0;
-             for (i=0; i<n; i++)
-             {
-               tmp.u.integer = i;
-               object_index_no_free(ITEM(d)+i, o, osub, &tmp );
-               types |= 1 << TYPEOF(ITEM(d)[i]);
-             }
-             d->type_field = types;
-             free_svalue(mysp-3);
-             mysp[-3]=*(--Pike_sp);
-             dmalloc_touch_svalue(Pike_sp);
-             f_map(args);
-             return;
-           }
 	 }
 
 	 SIMPLE_BAD_ARG_ERROR("map",1,
diff --git a/src/testsuite.in b/src/testsuite.in
index 4909375f86873b4dee5f54f0ceb40613b61e5772..d755ba308028d15d5fcd0ba9320407fed6217a34 100644
--- a/src/testsuite.in
+++ b/src/testsuite.in
@@ -4707,7 +4707,6 @@ test_any_equal(class A { constant a=1; constant b=2; }; return map(A, `+ ,1);, (
 test_any_equal(class A { protected mixed cast(string t) { if(t=="mapping") return (["a":1,"b":2]);}}; return map(A(), `+, 1);, (["a":2,"b":3]))
 test_any_equal(class A { protected mixed cast(string t) { if(t=="array") return ({1,2,3});}}; return map(A(), `+, 1);, ({2,3,4}))
 test_any_equal(class A { protected mixed cast(string t) { if(t=="multiset") return (<1,2,3>);}}; return map(A(), `+, 1);, (<2,3,4>))
-test_any_equal([[ class A { int a0=1,a1=2; protected int `[](int what) { return ::`[]("a"+what); } protected int _sizeof() { return 2; } }; return map(A(), `+, 1);]], ({2,3}))
 test_any_equal(array a = ({({1,0,0}),({1,1,0}),({0,1,1})}); return map(a,`[],1);,
                ({0,1,1}))
 test_any_equal(array a = ({({1,0,0}),({1,1,0}),({0,1,1})}); map(a,`[]=,1,0); return a;,