Permalink
Browse files

* src/clj/cljs/compiler.clj: CLJS-274: type-hint seq, rest, next

  • Loading branch information...
1 parent 0e0aa7f commit af3ec4b3acbd020979f70ed473014c0bcdd8cd99 David Nolen committed May 28, 2012
Showing with 5 additions and 5 deletions.
  1. +1 −1 src/clj/cljs/compiler.clj
  2. +4 −4 src/cljs/cljs/core.cljs
@@ -421,7 +421,7 @@
(defn safe-test? [e]
(let [tag (infer-tag e)]
- (or (= tag 'boolean)
+ (or (#{'boolean 'seq} tag)
(when (= (:op e) :constant)
(let [form (:form e)]
(not (or (and (string? form) (= form ""))
View
@@ -570,12 +570,12 @@ reduces them without incurring seq initialization"
IHash
(-hash [coll] (hash-coll coll)))
-(defn seq
+(defn ^seq seq
"Returns a seq on the collection. If the collection is
empty, returns nil. (seq nil) returns nil. seq also works on
Strings."
[coll]
- (if-not (nil? coll)
+ (when-not (nil? coll)
(if (satisfies? ASeq coll)
coll
(-seq coll))))
@@ -591,7 +591,7 @@ reduces them without incurring seq initialization"
(when-not (nil? s)
(-first s))))))
-(defn rest
+(defn ^seq rest
"Returns a possibly empty seq of the items after the first. Calls seq on its
argument."
[coll]
@@ -604,7 +604,7 @@ reduces them without incurring seq initialization"
())))
()))
-(defn next
+(defn ^seq next
"Returns a seq of the items after the first. Calls seq on its
argument. If there are no more items, returns nil"
[coll]

0 comments on commit af3ec4b

Please sign in to comment.