23:11 $ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-RC3"} org.clojure/test.check {:mvn/version "0.10.0-alpha2"}}}'
Clojure 1.10.0-RC3
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (require '[clojure.spec.test.alpha :as st])
nil
user=> (defmulti foo identity)
#'user/foo
user=> (s/fdef foo :args (s/cat :wat string?))
user/foo
user=> (defmethod foo :bar [lol])
#object[clojure.lang.MultiFn 0x57ac5227 "clojure.lang.MultiFn@57ac5227"]
user=> (st/instrument)
[user/foo]
user=> (defmethod foo :baz [lol])
执行错误(类转换异常)在 user/eval150 (REPL:1).
clojure.spec.test.alpha$spec_checking_fn$fn__3026 不能转换为 clojure.lang.MultiFn
user=> *e
{
:cause "clojure.spec.test.alpha$spec_checking_fn$fn__3026 不能转换为 clojure.lang.MultiFn"
:via
[
{:type java.lang.ClassCastException
:message "clojure.spec.test.alpha$spec_checking_fn$fn__3026 不能转换为 clojure.lang.MultiFn"
:at [user$eval150 invokeStatic "NO_SOURCE_FILE" 1]}]
:trace
[[user$eval150 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval150 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7176]
[clojure.lang.Compiler eval "Compiler.java" 7131]
[clojure.core$eval invokeStatic "core.clj" 3214]
[clojure.core$eval invoke "core.clj" 3210]
[clojure.main$repl$read_eval_print__9068$fn__9071 invoke "main.clj" 414]
[clojure.main$repl$read_eval_print__9068 invoke "main.clj" 414]
[clojure.main$repl$fn__9077 invoke "main.clj" 435]
[clojure.main$repl invokeStatic "main.clj" 435]
[clojure.main$repl_opt invokeStatic "main.clj" 499]
[clojure.main$main invokeStatic "main.clj" 598]
[clojure.main$main doInvoke "main.clj" 561]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 37]]}
我本以为这不会抛出异常