     (when (and merlin-completion-dwim (not labels) (not entries))
       (setq data (merlin-send-command `(expand prefix ,ident at ,pos)))
       (setq entries (cdr (assoc 'entries data)))
+      (setq-local dwimed t)
       (setq prefix ""))
     ; Concat results
     (let ((result (append labels entries)))

    (popup-make-item
      ; Note: ac refuses to display an item if merlin-ac-ac-prefix is not a
      ; prefix the item. So "dwim" completion won't work with ac.
      (merlin--completion-full-entry-name merlin-ac-ac-prefix merlin-ac-prefix data)
      :summary (when (and merlin-completion-types merlin-ac-use-summary) typ)
      :symbol (format "%c" (elt (cdr (assoc 'kind data)) 0))
      :document (if (and merlin-completion-types merlin-ac-use-document) typ))))

  "Compute the prefix of IDENT.  The prefix of `Foo.bar' is `Foo.' and the prefix of `bar' is `'."
  (car (merlin--completion-split-ident ident)))

(defvar-local dwimed nil
  "Remember if we used dwim for the current completion or not")

(defun merlin--completion-full-entry-name (compl-prefix entry)
  (let ((entry-name (cdr (assoc 'name entry))))
    (if dwimed entry-name (concat compl-prefix entry-name))))

(defun merlin--completion-prepare-labels (labels suffix)
  ; Remove non-matching entry, adjusting optional labels if needed
