func a() { }let å = alet b = å === å // Could not find an overload for === that accepts the supplIEd arguments
这里是Catterwauls如何处理这个:
MultiClosures & Equatable Closures
tests
Chris Lattner在开发者论坛上写道:This is a feature we intentionally do not want to support. There are
a varIEty of things that will cause pointer equality of functions (in
the swift type system sense,which includes several kinds of closures)
to fail or change depending on optimization. If “===” were defined on
functions,the compiler would not be allowed to merge IDentical method
bodIEs,share thunks,and perform certain capture optimizations in
closures. Further,equality of this sort would be extremely
surprising in some generics contexts,where you can get reabstraction
thunks that adjust the actual signature of a function to the one the
function type expects.
https://devforums.apple.com/message/1035180#1035180
这意味着你不应该尝试比较闭包的相等性,因为优化可能会影响结果。
总结以上是内存溢出为你收集整理的你如何测试函数和闭包的平等?全部内容,希望文章能够帮你解决你如何测试函数和闭包的平等?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)