Fix RT 48985
[gitmo/Class-MOP.git] / xs / Package.xs
index 362c407..675e894 100644 (file)
@@ -34,7 +34,15 @@ mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stas
 
         method_slot = *hv_fetch(map, method_name, method_name_len, TRUE);
         if ( SvOK(method_slot) ) {
-            SV *const body = mop_call0(aTHX_ method_slot, KEY_FOR(body)); /* $method_object->body() */
+            SV *body;
+
+            if ( sv_isobject(method_slot) ) {
+                body = mop_call0(aTHX_ method_slot, KEY_FOR(body)); /* $method_object->body() */
+            }
+            else {
+                body = method_slot;
+            }
+
             if ( SvROK(body) && ((CV *) SvRV(body)) == cv ) {
                 continue;
             }