     (doseq [[params & body] methods]
       (let [env (assoc env
                   :params (take-while before-rest params)
-                  :restarg (second (drop-while before-rest params)))]
+                  :restarg (second (drop-while before-rest params))
+                  :arglists arglists)]
         (gen-body cw env body)))
     (gen-applier cw thistype arglists)
     (gen-handle cw thistype arglists)))

    (cons 'lambda (sanitize-method env params body))))

(defn sanitize-case-lambda
  [env [_ methods :as form]]
  (cons 'case-lambda
        (for [[params & body] (validate-arities methods)]
          (sanitize-method env params body))))

          (list 'let (list (list res (explode-invocation call)))
                res))))

(defn arity-match?
  [{:keys [restarg params arglists] :as env} args]
  (if restarg
    (>= (count args) (min-variadic-arity arglists))
    (= (count args) (count params))))

(defn emit-tail-call
  [{:keys [recur-sym restarg top-label params locals] :as env} ^GeneratorAdapter gen [fun & args :as call]]
  (if (and (= fun recur-sym)
           (arity-match? env args))
                                        ; Self call, becomes loop
    (do
      (debug "emitting self tail-call: " call)
                                        ; emit all new values
      (dotimes [n (count params)]
        (emit env :context/expression gen (nth args n)))
      (when restarg
        (emit-list-from-array gen
                              #(let [extra (drop (count params) args)]
                                 (AsmUtil/pushInt gen (count extra))
                                 (. gen newArray object-type)
                                 (dotimes [n (count extra)]
                                   (. gen dup)
                                   (AsmUtil/pushInt gen n)
                                   (emit env :context/expression gen (nth extra n))
                                   (. gen arrayStore object-type))))
        (. gen storeLocal (get locals restarg)))
                                        ; store them in reverse order from stack
      (dotimes [n (count params)]
        (. gen storeArg (- (count params) n 1)))
      (. gen goTo top-label))
                                        ; Calls another fn, return continuation thunk
    (do
