[swift-users] Law of Exclusivity runtime false positive?

David Hart david at hartbit.com
Thu Jul 27 07:04:18 CDT 2017


Hello,

In Xcode 9 beta 4, Swift 4, I’m getting runtime errors popping up for Simultaneous accesses and I think they may be false negatives. Here’s a stripped down version of my code:

class MyButton: UIButton {
	fileprivate var imageRect: CGRect = .zero
	fileprivate var titleRect: CGRect = .zero

        func updateRects() {
            if imageBeforeTitle {
                layoutHorizontally(leftRect: &imageRect, rightRect: &titleRect)
            } else {
                layoutHorizontally(leftRect: &titleRect, rightRect: &imageRect)
            }
        }

        func layoutHorizontally(leftRect: inout CGRect, rightRect: inout CGRect) {
            leftRect.origin.x = padding
            rightRect.origin.x = leftRect.maxX + spacing
        }
}

While the layoutHorizontally method has two CGRect inout parameters, never in my code do I pass the same CGRect. Any ideas if this is a bug I should post on bugs.swift.org or if I’m missing something?

David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170727/460d75d2/attachment.html>


More information about the swift-users mailing list