Skip to content

Commit b98351e

Browse files
anmonteirodnolen
authored andcommitted
CLJS-1569: IndexedSeq doesn't implement IWithMeta / IMeta
1 parent ce25dce commit b98351e

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,11 +1087,11 @@
10871087

10881088
(array? coll)
10891089
(when-not (zero? (alength coll))
1090-
(IndexedSeq. coll 0))
1090+
(IndexedSeq. coll 0 nil))
10911091

10921092
(string? coll)
10931093
(when-not (zero? (alength coll))
1094-
(IndexedSeq. coll 0))
1094+
(IndexedSeq. coll 0 nil))
10951095

10961096
(native-satisfies? ISeqable coll)
10971097
(-seq coll)
@@ -1424,7 +1424,7 @@ reduces them without incurring seq initialization"
14241424
(set! i (inc i))
14251425
ret)))
14261426

1427-
(deftype IndexedSeq [arr i]
1427+
(deftype IndexedSeq [arr i meta]
14281428
Object
14291429
(toString [coll]
14301430
(pr-str* coll))
@@ -1440,23 +1440,29 @@ reduces them without incurring seq initialization"
14401440
(-lastIndexOf coll x start))
14411441

14421442
ICloneable
1443-
(-clone [_] (IndexedSeq. arr i))
1443+
(-clone [_] (IndexedSeq. arr i meta))
14441444

14451445
ISeqable
14461446
(-seq [this]
14471447
(when (< i (alength arr))
14481448
this))
14491449

1450+
IMeta
1451+
(-meta [coll] meta)
1452+
IWithMeta
1453+
(-with-meta [coll new-meta]
1454+
(IndexedSeq. arr i new-meta))
1455+
14501456
ASeq
14511457
ISeq
14521458
(-first [_] (aget arr i))
14531459
(-rest [_] (if (< (inc i) (alength arr))
1454-
(IndexedSeq. arr (inc i))
1460+
(IndexedSeq. arr (inc i) nil)
14551461
(list)))
14561462

14571463
INext
14581464
(-next [_] (if (< (inc i) (alength arr))
1459-
(IndexedSeq. arr (inc i))
1465+
(IndexedSeq. arr (inc i) nil)
14601466
nil))
14611467

14621468
ICounted
@@ -1511,7 +1517,7 @@ reduces them without incurring seq initialization"
15111517
(prim-seq prim 0))
15121518
([prim i]
15131519
(when (< i (alength prim))
1514-
(IndexedSeq. prim i))))
1520+
(IndexedSeq. prim i nil))))
15151521

15161522
(defn array-seq
15171523
"Create a seq from a JavaScript array."
@@ -4935,7 +4941,7 @@ reduces them without incurring seq initialization"
49354941
(-seq [coll]
49364942
(cond
49374943
(zero? cnt) nil
4938-
(<= cnt 32) (IndexedSeq. tail 0)
4944+
(<= cnt 32) (IndexedSeq. tail 0 nil)
49394945
:else (chunked-seq coll (first-array-for-longvec coll) 0 0)))
49404946

49414947
ICounted

src/main/clojure/cljs/core.cljc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,7 +2735,7 @@
27352735
(copy-arguments args#)
27362736
(let [argseq# (when (< ~c-1 (alength args#))
27372737
(new ^::ana/no-resolve cljs.core/IndexedSeq
2738-
(.slice args# ~c-1) 0))]
2738+
(.slice args# ~c-1) 0 nil))]
27392739
(. ~rname
27402740
(~'cljs$core$IFn$_invoke$arity$variadic ~@(dest-args c-1) argseq#))))))
27412741
~(variadic-fn* rname method)))))
@@ -2792,7 +2792,7 @@
27922792
~@(mapcat #(fixed-arity rname %) sigs)
27932793
~(if variadic
27942794
`(let [argseq# (new ^::ana/no-resolve cljs.core/IndexedSeq
2795-
(.slice ~args-sym ~maxfa) 0)]
2795+
(.slice ~args-sym ~maxfa) 0 nil)]
27962796
(. ~rname
27972797
(~'cljs$core$IFn$_invoke$arity$variadic
27982798
~@(dest-args maxfa)

src/test/cljs/cljs/core_test.cljs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,8 +3037,8 @@
30373037
([x0 & xs] [x0 xs]))
30383038

30393039
(deftest test-cljs-1284
3040-
(let [xs (IndexedSeq. #js [] 0)
3041-
ys (IndexedSeq. #js [1] 3)]
3040+
(let [xs (IndexedSeq. #js [] 0 nil)
3041+
ys (IndexedSeq. #js [1] 3 nil)]
30423042
(is (nil? (first xs)))
30433043
(is (nil? (seq xs)))
30443044
(is (= (rest xs) ()))
@@ -3106,6 +3106,10 @@
31063106
(is (not (== (hash x0) (hash x1) (hash x2) (hash x3) (hash x4)
31073107
(hash x5) (hash x6) (hash x7))))))
31083108

3109+
(deftest test-cljs-1569
3110+
(is (= (meta (with-meta (seq [1 2 3]) {:a 1})) {:a 1})))
3111+
3112+
31093113
(comment
31103114
;; ObjMap
31113115
;; (let [ks (map (partial str "foo") (range 500))

0 commit comments

Comments
 (0)