string_of_int n2
        )
     | C.MutCase (uri,n1,ty,te,patterns) ->
+       let needs_obj_magic =
+        match ty with
+           Cic.Lambda (_,_,t) -> not (DoubleTypeInference.does_not_occur 1 t)
+         | _ -> assert false
+       in
        let paramsno =
         match fst(CicEnvironment.get_obj CicUniv.empty_ugraph uri) with
            C.InductiveDefinition (_,_,paramsno,_) -> paramsno
                          x ^ (if sargs = "" then "" else "(" ^ sargs^ ")"),
                           body
                       in
-                       pattern ^ " -> " ^ body
+                       pattern ^ " -> " ^
+                        if needs_obj_magic then
+                         "Obj.magic (" ^ body ^ ")"
+                        else
+                         body
                    ) connames_and_argsno_and_patterns)) ^
                  ")\n"))
     | C.Fix (no, funs) ->