;; Clojure 1.5.0-master-SNAPSHOT ;; at 94842f17680db1238694500ab6608b5e7ebd7427 (defprotocol MutableX (set-x [this v])) ;; OK: (deftype Foo1 [^:unsynchronized-mutable x] MutableX (set-x [this v] (set! x v))) ;; OK: (deftype Foo2 [^:unsynchronized-mutable x] MutableX (set-x [this v] (try (set! x v)))) ;; Not OK: (deftype Foo3 [^:unsynchronized-mutable x] MutableX (set-x [this v] (try (set! x v)) v)) ;; CompilerException java.lang.IllegalArgumentException: ;; Cannot assign to non-mutable: x ;; This matters because `locking` expands to a try/finally. ;; OK: (deftype Foo4 [^:unsynchronized-mutable x] MutableX (set-x [this v] (locking this (set! x v)))) ;; Not OK: (deftype Foo5 [^:unsynchronized-mutable x] MutableX (set-x [this v] (locking this (set! x v)) v)) ;; CompilerException java.lang.IllegalArgumentException: ;; Cannot assign to non-mutable: x