评论由:sohta发表
这可能超出了这个工单的范围,但协议方法冲突可能导致一些其他类型的错误
`
user=> (defprotocol P1 (finalize [this]))
P1
user=> (defrecord R1 [] P1 (finalize [this]))
CompilerException java.lang.VerifyError: (class: user/R1, method: finalize signature: ()Ljava/lang/Object;) Unable to pop operand off an empty stack, compiling: ...
user=> (defprotocol P2 (wait [this]))
P2
user=> (defrecord R2 [] P2 (wait [this]))
user.R2
user=> (def r (->R2))
'user/r
user=> (wait r)
CompilerException java.lang_IllegalArgumentException: No single method: wait of interface: user.P2 found for function: wait of protocol: P2, compiling: ...
user=>
`
在我看来,如果 defprotocol 能够用更详细的信息警告方法冲突会更好。