346
346
" Throws a ClassCastException if x is not a c, else returns x."
347
347
{:added " 1.0"
348
348
:static true }
349
- [^Type c x] ; ;; changed Class to Type
349
+ [^Type c ^Object x] ; ;; changed Class to Type
350
350
(if (clojure.lang.Util/identical x nil ) nil (if (. c (IsInstanceOfType x)) x (throw (InvalidCastException. (.ToString (.GetType x))))))) ; ;; original (. c (cast x)))
351
351
352
352
(defn vector
826
826
compares numbers and collections in a type-independent manner. x
827
827
must implement Comparable"
828
828
{
829
- :inline (fn [x y] `(. clojure.lang.Util compare ~x ~y))
829
+ :inline (fn [^Object x ^Object y] `(clojure.lang.Util/ compare ~x ~y))
830
830
:added " 1.0" }
831
- [x y] (. clojure.lang.Util ( compare x y) ))
831
+ [^Object x ^Object y] (clojure.lang.Util/ compare x y))
832
832
833
833
(defmacro and
834
834
" Evaluates exprs one at a time, from left to right. If a form
1766
1766
(defmacro defmethod
1767
1767
" Creates and installs a new method of multimethod associated with dispatch-value. "
1768
1768
{:added " 1.0" }
1769
- [multifn dispatch-val & fn-tail]
1769
+ [^clojure.lang.MultiFn multifn dispatch-val & fn-tail]
1770
1770
`(. ~(with-meta multifn {:tag 'clojure.lang.MultiFn}) addMethod ~dispatch-val (fn ~@fn-tail)))
1771
1771
1772
1772
(defn remove-all-methods
1780
1780
" Removes the method of multimethod associated with dispatch-value."
1781
1781
{:added " 1.0"
1782
1782
:static true }
1783
- [multifn dispatch-val]
1783
+ [^clojure.lang.MultiFn multifn dispatch-val]
1784
1784
(. multifn removeMethod dispatch-val))
1785
1785
1786
1786
(defn prefer-method
1787
1787
" Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y
1788
1788
when there is a conflict"
1789
1789
{:added " 1.0"
1790
1790
:static true }
1791
- [multifn dispatch-val-x dispatch-val-y]
1791
+ [^clojure.lang.MultiFn multifn dispatch-val-x dispatch-val-y]
1792
1792
(. multifn preferMethod dispatch-val-x dispatch-val-y))
1793
1793
1794
1794
(defn methods
2438
2438
{:added " 1.1"
2439
2439
:static true }
2440
2440
([^clojure.lang.Ref ref]
2441
- (.getMinHistory ref))
2441
+ (.MinHistory ref))
2442
2442
([^clojure.lang.Ref ref n]
2443
2443
(.setMinHistory ref n)))
2444
2444
2447
2447
{:added " 1.1"
2448
2448
:static true }
2449
2449
([^clojure.lang.Ref ref]
2450
- (.getMaxHistory ref))
2450
+ (.MaxHistory ref))
2451
2451
([^clojure.lang.Ref ref n]
2452
2452
(.setMaxHistory ref n)))
2453
2453
3598
3598
(instance? clojure.lang.BigInt x) x
3599
3599
(instance? BigInteger x) (clojure.lang.BigInt/fromBigInteger x)
3600
3600
(decimal? x) (bigint (.ToBigInteger ^BigDecimal x))
3601
- (float? x) (bigint (BigDecimal/Create (double x))) ; ;; (. BigDecimal valueOf (double x))
3601
+ (float? x) (bigint (clojure.lang. BigDecimal/Create (double x))) ; ;; (. BigDecimal valueOf (double x))
3602
3602
(ratio? x) (bigint (.BigIntegerValue ^clojure.lang.Ratio x))
3603
- (number? x) (clojure.lang.BigInt/valueOf (long x)) (string? x) (bigint (BigInteger/Parse ^String x)) ; ; DM: Added string clause
3604
- :else (bigint (BigInteger. x))))
3603
+ (number? x) (clojure.lang.BigInt/valueOf (long x)) (string? x) (bigint (clojure.lang. BigInteger/Parse ^String x)) ; ; DM: Added string clause
3604
+ :else (bigint (clojure.lang. BigInteger. x))))
3605
3605
3606
3606
(defn biginteger
3607
3607
" Coerce to BigInteger"
3612
3612
(instance? BigInteger x) x
3613
3613
(instance? clojure.lang.BigInt x) (.toBigInteger ^clojure.lang.BigInt x)
3614
3614
(decimal? x) (.ToBigInteger ^BigDecimal x) ; ;; toBigInteger
3615
- (float? x) (.ToBigInteger (BigDecimal/Create (double x))) ; ;; (.toBigInteger (. BigDecimal valueOf (double x)))
3615
+ (float? x) (.ToBigInteger (clojure.lang. BigDecimal/Create (double x))) ; ;; (.toBigInteger (. BigDecimal valueOf (double x)))
3616
3616
(ratio? x) (.BigIntegerValue ^clojure.lang.Ratio x)
3617
- (number? x) (BigInteger/Create (long x)) (string? x) (bigint (BigInteger/Parse ^String x)) ; ;;(BigInteger/valueOf (long x)) DM: Added string clause
3618
- :else (BigInteger. x)))
3617
+ (number? x) (clojure.lang.BigInteger/Create (long x))
3618
+ (string? x) (bigint (clojure.lang.BigInteger/Parse ^String x)) ; ;;(BigInteger/valueOf (long x)) DM: Added string clause
3619
+ :else (clojure.lang.BigInteger. x)))
3619
3620
3620
3621
(defn bigdec
3621
3622
" Coerce to BigDecimal"
3624
3625
:static true }
3625
3626
[x] (cond
3626
3627
(decimal? x) x
3627
- (float? x) (BigDecimal/Create (double x)) ; ;; (. BigDecimal valueOf (double x))
3628
- (ratio? x) (/ (BigDecimal/Create (.numerator ^clojure.lang.Ratio x)) (.denominator ^clojure.lang.Ratio x)) ; ;; (/ (BigDecimal. (.numerator ^clojure.lang.Ratio x)) (.denominator ^clojure.lang.Ratio x))
3628
+ (float? x) (clojure.lang. BigDecimal/Create (double x)) ; ;; (. BigDecimal valueOf (double x))
3629
+ (ratio? x) (/ (clojure.lang. BigDecimal/Create (.numerator ^clojure.lang.Ratio x)) (.denominator ^clojure.lang.Ratio x)) ; ;; (/ (BigDecimal. (.numerator ^clojure.lang.Ratio x)) (.denominator ^clojure.lang.Ratio x))
3629
3630
(instance? clojure.lang.BigInt x) (.ToBigDecimal ^clojure.lang.BigInt x) ; ;; .ToBigDecimal
3630
- (instance? BigInteger x) (BigDecimal/Create ^BigInteger x) ; ;; (BigDecimal. ^BigInteger x)
3631
- (number? x) (BigDecimal/Create (long x)) ; ;; (BigDecimal/valueOf (long x))
3632
- :else (BigDecimal/Create x))) ; ;; (BigDecimal. x)))
3631
+ (instance? BigInteger x) (clojure.lang.BigDecimal/Create ^BigInteger x) ; ;; (BigDecimal. ^BigInteger x)
3632
+ (number? x) (clojure.lang.BigDecimal/Create (long x)) ; ;; (BigDecimal/valueOf (long x))
3633
+ :else (throw (InvalidCastException. (str " Cannot cast " (type x) " to BigDecimal." )))
3634
+ )) ; ;; (BigDecimal. x)))
3633
3635
3634
3636
(def ^:dynamic ^{:private true } print-initialized false )
3635
3637
@@ -3857,25 +3859,25 @@ Note that read can execute code (controlled by *read-eval*),
3857
3859
(defn aget
3858
3860
" Returns the value at the index/indices. Works on Java arrays of all
3859
3861
types."
3860
- {:inline (fn [a i] `(. clojure.lang.RT (aget ~a (int ~i))))
3862
+ {:inline (fn [^Array a i] `(. clojure.lang.RT (aget ~a (int ~i))))
3861
3863
:inline-arities #{2 }
3862
3864
:added " 1.0" }
3863
- ([array idx]
3864
- (clojure.lang.Reflector/prepRet (.GetElementType (class array)) (. array (GetValue idx)))) ; ;; was .getComponentType (. Array (get array idx)))
3865
- ([array idx & idxs]
3866
- (apply aget (aget array idx) idxs)))
3865
+ ([^Array array idx]
3866
+ (clojure.lang.Reflector/prepRet (.GetElementType (class array)) (. array (GetValue ( int idx) )))) ; ;; was .getComponentType (. Array (get array idx)))
3867
+ ([^Array array idx & idxs]
3868
+ (apply aget (aget array ( int idx) ) idxs)))
3867
3869
3868
3870
(defn aset
3869
3871
" Sets the value at the index/indices. Works on Java arrays of
3870
3872
reference types. Returns val."
3871
3873
{:inline (fn [a i v] `(. clojure.lang.RT (aset ~a (int ~i) ~v)))
3872
3874
:inline-arities #{3 }
3873
3875
:added " 1.0" }
3874
- ([array idx val]
3875
- (. array (SetValue val idx)) ; ;; was (. Array (set array idx val))
3876
+ ([^Array array idx ^Object val]
3877
+ (. array (SetValue val ( int idx) )) ; ;; was (. Array (set array idx val))
3876
3878
val)
3877
- ([array idx idx2 & idxv]
3878
- (apply aset (aget array idx) idx2 idxv)))
3879
+ ([^Array array idx idx2 & idxv]
3880
+ (apply aset (aget array ( int idx) ) idx2 idxv)))
3879
3881
3880
3882
(defmacro
3881
3883
^{:private true }
@@ -3885,8 +3887,8 @@ Note that read can execute code (controlled by *read-eval*),
3885
3887
([array# idx# val#]
3886
3888
(. clojure.lang.ArrayHelper (~method array# idx# (~coerce val#))) ; ;; Array -> ArrayHelper so we can provide the overloads below.
3887
3889
val#)
3888
- ([array# idx# idx2# & idxv#]
3889
- (apply ~name (aget array# idx#) idx2# idxv#))))
3890
+ ([^Array array# idx# idx2# & idxv#]
3891
+ (apply ~name (aget array# ( int idx#) ) idx2# idxv#))))
3890
3892
3891
3893
(def-aset
3892
3894
^{:doc " Sets the value at the index/indices. Works on arrays of int. Returns val."
@@ -3937,12 +3939,12 @@ Note that read can execute code (controlled by *read-eval*),
3937
3939
{:added " 1.0"
3938
3940
:static true }
3939
3941
([^Type type len] ; ;; ^Class
3940
- (. Array ( CreateInstance type (int len) ))) ; ;; newInstance
3942
+ (Array/ CreateInstance type (int len))) ; ;; newInstance
3941
3943
([^Type type dim & more-dims] ; ;; ^Class
3942
- (let [ a ( . Array ( CreateInstance Array (int dim) ))] ; ;; [dims (cons dim more-dims)
3944
+ (let [^Array a ( System. Array/CreateInstance ( .MakeArrayType type) (int dim))] ; ;; [dims (cons dim more-dims)
3943
3945
; ;; ^"[I" dimarray (make-array (. Integer TYPE) (count dims))]
3944
3946
(dotimes [i dim] ; ;; (dotimes [i (alength dimarray)]
3945
- (aset a i (apply make-array type more-dims))) ; ;; (aset-int dimarray i (nth dims i)))
3947
+ (aset a ( int i) (apply make-array type more-dims))) ; ;; (aset-int dimarray i (nth dims i)))
3946
3948
a))) ; ;; (. Array (newInstance type dimarray)))))
3947
3949
3948
3950
(defn to-array-2d
@@ -3953,10 +3955,10 @@ Note that read can execute code (controlled by *read-eval*),
3953
3955
:added " 1.0"
3954
3956
:static true }
3955
3957
[^System.Collections.ICollection coll] ; ;; ^java.util.Collection
3956
- (let [ret (make-array Object (.Count coll))] ; ;; NEED BETTER TYPING HERE (make-array (. Class (forName "[Ljava.lang.Object;")) (. coll (size)))]
3958
+ (let [^Array ret (make-array Object (.Count coll))] ; ;; NEED BETTER TYPING HERE (make-array (. Class (forName "[Ljava.lang.Object;")) (. coll (size)))]
3957
3959
(loop [i 0 xs (seq coll)]
3958
3960
(when xs
3959
- (aset ret i (to-array (first xs)))
3961
+ (aset ret ( int i) (to-array (first xs)))
3960
3962
(recur (inc i) (next xs))))
3961
3963
ret))
3962
3964
@@ -4138,8 +4140,8 @@ Note that read can execute code (controlled by *read-eval*),
4138
4140
[ns ]
4139
4141
(let [ns (the-ns ns )]
4140
4142
(filter-key val (fn [ v] (and (instance? clojure.lang.Var v) ; ;; removed the tag on v: ^clojure.lang.Var
4141
- (= ns (.ns v))
4142
- (.isPublic v)))
4143
+ (= ns (.ns ^clojure.lang.Var v))
4144
+ (.isPublic ^clojure.lang.Var v)))
4143
4145
(ns-map ns ))))
4144
4146
4145
4147
(defn ns-imports
@@ -4693,9 +4695,9 @@ Note that read can execute code (controlled by *read-eval*),
4693
4695
" Create an instance of ExceptionInfo, a RuntimeException subclass
4694
4696
that carries a map of additional data."
4695
4697
{:added " 1.4" }
4696
- ([msg map]
4698
+ ([^String msg ^clojure.lang.IPersistentMap map]
4697
4699
(ExceptionInfo. msg map))
4698
- ([msg map cause]
4700
+ ([^String msg ^clojure.lang.IPersistentMap map ^Exception cause]
4699
4701
(ExceptionInfo. msg map cause)))
4700
4702
4701
4703
(defn ex-data
@@ -4975,7 +4977,7 @@ Note that read can execute code (controlled by *read-eval*),
4975
4977
{:private true }
4976
4978
[^clojure.lang.Sorted sc test key]
4977
4979
(fn [e]
4978
- (test (.. sc comparator (compare (. sc entryKey e) key)) 0 )))
4980
+ (test (.. sc comparator (Compare (. sc entryKey e) key)) 0 )))
4979
4981
4980
4982
(defn subseq
4981
4983
" sc must be a sorted collection, test(s) one of <, <=, > or
@@ -7651,4 +7653,4 @@ clojure.lang.IKVReduce
7651
7653
(load-data-readers )
7652
7654
(catch Exception t ; ;; Throwable
7653
7655
(System.Console/WriteLine (.StackTrace t)) ; ;; .printStackTrace
7654
- (throw t)))
7656
+ (throw t)))
0 commit comments