Skip to content
Browse files

fixed bug in disambiguating when looking at forms in the original ns

  • Loading branch information...
1 parent cc22fa4 commit a5c6b41956dea61eb0c6aeb4954d1bb9b4de6abd @AlexBaranosky AlexBaranosky committed
Showing with 13 additions and 8 deletions.
  1. +8 −6 src/slam/hound/regrow.clj
  2. +5 −2 test/slam/hound_test.clj
View
14 src/slam/hound/regrow.clj
@@ -102,16 +102,18 @@
(defn- referred-to-in-originals-pred [type originals]
(if-not (= type :require-refer)
(constantly false)
- (fn [[ns1 _ [alias1]]]
- (some (fn [[[ns2 _ [alias2]]]]
- (and (= alias1 alias2) (= ns1 ns2)))
- originals))))
+ (fn [[ns1 _ [alias1] :as x]]
+ (->> originals
+ (filter sequential?)
+ (filter #(contains? #{:only :refer} (second %)))
+ (some (fn [[ns2 _ [alias2]]]
+ (and (= alias1 alias2) (= ns1 ns2))))))))
(defn- disambiguate [candidates missing ns-map type]
;; TODO: prefer things in src/classes to jars
(debug :disambiguating missing :in candidates)
- (let [orig-clauses (map #(get (:old ns-map) %)
- (new-type-to-old-types type))]
+ (let [orig-clauses (mapcat #(get (:old ns-map) %)
+ (new-type-to-old-types type))]
(->> candidates
(sort-by (juxt (complement (in-originals-pred orig-clauses))
(complement (referred-to-in-originals-pred
View
7 test/slam/hound_test.clj
@@ -72,8 +72,11 @@
"
(reconstruct (StringReader.
(str '(ns foo.bar
- (:require [clojure.string :only [join]]
- [clojure.set :refer [union]]))
+ (:use [clojure.string]
+ clojure.string)
+ (:require [clojure.string :as str]
+ [clojure.string :only [join lowercase]]
+ [clojure.set :refer [union difference]]))
'(do
(defn f [xs]
(join "," xs))

0 comments on commit a5c6b41

Please sign in to comment.
Something went wrong with that request. Please try again.