Permalink
Browse files

Added type hints (resolves #96).

  • Loading branch information...
1 parent 5e29545 commit 133a945da74cb2f78c5937b1e6a3e5327e4a3743 @ath ath committed Jan 7, 2012
Showing with 16 additions and 14 deletions.
  1. +1 −0 project.clj
  2. +1 −1 src/swank/commands/basic.clj
  3. +12 −11 src/swank/commands/inspector.clj
  4. +1 −1 src/swank/util/concurrent/thread.clj
  5. +1 −1 src/swank/util/io.clj
View
@@ -7,4 +7,5 @@
:dev-dependencies [[lein-multi "1.0.0"]]
:multi-deps {"1.3" [[org.clojure/clojure "1.3.0"]
[clj-stacktrace "0.2.4"]]}
+ :warn-on-reflection true
:shell-wrapper {:main swank.swank})
@@ -583,7 +583,7 @@ that symbols accessible in the current namespace go first."
(defn get-thread-list []
(let [#^ThreadGroup rg (get-root-group (.getThreadGroup (Thread/currentThread)))
- arr (make-array Thread (.activeCount rg))]
+ #^"[Ljava.lang.Thread;" arr (make-array Thread (.activeCount rg))]
(.enumerate rg arr true) ;needs type hint
(seq arr)))
@@ -1,6 +1,7 @@
(ns swank.commands.inspector
(:use (swank util core commands)
- (swank.core connection)))
+ (swank.core connection))
+ (:import (java.lang.reflect Field)))
;;;; Inspector for basic clojure data structures
@@ -110,7 +111,7 @@
(iterate inc 0)
obj)))
-(defmethod emacs-inspect :array [obj]
+(defmethod emacs-inspect :array [#^"[Ljava.lang.Object;" obj]
(concat
(label-value-line*
("Class" (class obj))
@@ -149,15 +150,15 @@
obj)))
(defmethod emacs-inspect :default [obj]
- (let [fields (. (class obj) getDeclaredFields)
- names (map (memfn getName) fields)
- get (fn [f]
- (try (.setAccessible f true)
- (catch java.lang.SecurityException e))
- (try (.get f obj)
- (catch java.lang.IllegalAccessException e
- "Access denied.")))
- vals (map get fields)]
+ (let [#^"[Ljava.lang.reflect.Field;" fields (. (class obj) getDeclaredFields)
+ names (map #(.getName #^Field %) fields)
+ get (fn [#^Field f]
+ (try (.setAccessible f true)
+ (catch java.lang.SecurityException e))
+ (try (.get f obj)
+ (catch java.lang.IllegalAccessException e
+ "Access denied.")))
+ vals (map get fields)]
(concat
`("Type: " (:value ~(class obj)) (:newline)
"Value: " (:value ~obj) (:newline)
@@ -11,7 +11,7 @@
"Starts a thread that run the given function f"
([#^Runnable f]
(let [t (if *new-thread-group*
- (Thread. *new-thread-group* f)
+ (Thread. #^ThreadGroup *new-thread-group* f)
(Thread. f))]
(.start t)
t)))
View
@@ -7,7 +7,7 @@
(defn read-chars
([rdr n] (read-chars rdr n false))
([#^Reader rdr n throw-exception]
- (let [cbuf (make-array Character/TYPE n)]
+ (let [#^"[C" cbuf (make-array Character/TYPE n)]
(loop [i 0]
(let [size (.read rdr cbuf i (- n i))]
(cond

0 comments on commit 133a945

Please sign in to comment.