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

Kyle Murray kyle_murray at apple.com
Thu Jul 27 14:33:11 CDT 2017


Hi David,

Are padding or spacing computed properties that access either rectangle? They aren't defined in your stripped down code. For example:

var spacing: CGFloat {
    return imageRect.maxX
}

Without doing something like that, I don't see the same access conflicts that you're seeing.

-Kyle

> On Jul 27, 2017, at 5:04 AM, David Hart via swift-users <swift-users at swift.org> wrote:
> 
> 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 <http://bugs.swift.org/> or if I’m missing something?
> 
> David.
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

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


More information about the swift-users mailing list