Skip to content

Commit be4ea19

Browse files
committed
Don't use use polymorphic coersion on macro return values
1 parent a546283 commit be4ea19

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/promesa/core.cljc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@
552552
[& exprs]
553553
(condp = (count exprs)
554554
0 `(impl/resolved nil)
555-
1 `(pt/-promise ~(first exprs))
555+
1 `(impl/coerce ~(first exprs))
556556
(reduce (fn [acc e]
557-
`(pt/-mcat (pt/-promise ~e) (fn [_#] ~acc)))
558-
`(pt/-promise ~(last exprs))
557+
`(pt/-mcat (impl/coerce ~e) (fn [_#] ~acc)))
558+
`(impl/coerce ~(last exprs))
559559
(reverse (butlast exprs)))))
560560

561561
(defmacro do
@@ -564,7 +564,7 @@
564564
expression."
565565
[& exprs]
566566
`(pt/-mcat
567-
(pt/-promise nil)
567+
(impl/resolved nil)
568568
(fn [_#]
569569
(promesa.core/do* ~@exprs))))
570570

@@ -580,7 +580,7 @@
580580
(assert (even? (count bindings)) (str "Uneven binding vector: " bindings))
581581
(c/->> (reverse (partition 2 bindings))
582582
(reduce (fn [acc [l r]]
583-
`(pt/-mcat (pt/-promise ~r) (fn [~l] ~acc)))
583+
`(pt/-mcat (impl/coerce ~r) (fn [~l] ~acc)))
584584
`(do* ~@body))))
585585

586586
(defmacro let
@@ -589,7 +589,7 @@
589589
[bindings & body]
590590
(if (seq bindings)
591591
`(pt/-mcat
592-
(pt/-promise nil)
592+
(impl/resolved nil)
593593
(fn [_#] (promesa.core/let* ~bindings ~@body)))
594594
`(promesa.core/do ~@body)))
595595

@@ -599,7 +599,7 @@
599599
[bindings & body]
600600
(assert (even? (count bindings)) (str "Uneven binding vector: " bindings))
601601
`(pt/-mcat
602-
(pt/-promise nil)
602+
(impl/resolved nil)
603603
(fn [_#]
604604
~(c/let [bindings (partition 2 bindings)]
605605
`(c/-> (all ~(mapv second bindings))

src/promesa/impl.cljc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
(.completeExceptionally ^CompletableFuture p v)
5555
p)))
5656

57-
#?(:cljs
58-
(defn coerce
59-
"Coerce a thenable to built-in promise impl type."
60-
[v]
61-
(impl/coerce v)))
57+
(defn coerce
58+
[v]
59+
(if (promise? v)
60+
v
61+
(resolved v)))
6262

6363
(defn all
6464
[promises]

0 commit comments

Comments
 (0)