       case bootstrapped?(Enum) do
         true ->
           quote do
-            def __struct__(kv) do
-              {map, keys} =
-                Enum.reduce(kv, {__struct__(), @enforce_keys}, fn {key, val}, {map, keys} ->
-                  {Map.replace!(map, key, val), List.delete(keys, key)}
-                end)
-              case keys do
-                [] -> map
-                _  -> raise ArgumentError, "the following keys must also be given when building " <>
-                                           "struct #{inspect __MODULE__}: #{inspect keys}"
-              end
+            case @enforce_keys do
+              [] ->
+                def __struct__(kv) do
+                  Enum.reduce(kv, @struct, fn {key, val}, map ->
+                    Map.replace!(map, key, val)
+                  end)
+                end
+              _ ->
+                def __struct__(kv) do
+                  {map, keys} =
+                    Enum.reduce(kv, {@struct, @enforce_keys}, fn {key, val}, {map, keys} ->
+                      {Map.replace!(map, key, val), List.delete(keys, key)}
+                    end)
+                  case keys do
+                    [] -> map
+                    _  -> raise ArgumentError, "the following keys must also be given when building " <>
+                        "struct #{inspect __MODULE__}: #{inspect keys}"
+                  end
+                end
             end
           end
         false ->

  """
  @spec struct(module | struct, Enum.t) :: struct
  def struct(struct, fields \\ []) do
    struct(struct, fields, fn {key, val}, acc ->
      case Map.has_key?(acc, key) and key != :__struct__ do
        true  -> Map.put(acc, key, val)
        false -> acc
      end
    end)
  end



  # We need this check only for bootstrap purposes.
  # Once Kernel is loaded and we recompile, it is a no-op.
  @compile {:inline, bootstrapped?: 1}
  case :code.ensure_loaded(Kernel) do
    {:module, _} ->
      defp bootstrapped?(_), do: true
