> On Sep 7, 2016, at 12:52 AM, David Hart via swift-evolution 
> <[email protected]> wrote:
> 
> I’’ve been migrating a project to Swift 3 and a the piece of code below did 
> not require any modification but had wildly different results:
> 
> let myView = viewController.view
> superview.addConstraints([
>     NSLayoutConstraint(
>         item: myView, attribute: .left,
>         relatedBy: .equal,
>         toItem: superview, attribute: .left,
>         multiplier: 1, constant: 0)
> ])
> 
> UIViewController’s view property is typed as UIView! so myView’s type is 
> inferred to UIView? in Swift 3 (previous inferred as UIView! in Swift 2). 
> This will crash in Swift 3 (not in Swift 2), because I think that myView’s 
> optional value is not bridged to the wrapped value in Objective-C when passed 
> to NSLayoutConstraint. Can somebody confirm that this proposal fixes this 
> issue?

The correct behavior would end up falling out with this proposal, yeah, though 
it would still arguably be more correct for us to force-unwrap IUOs before 
sticking them in a non-optional Any, instead of putting the wrapped Optional 
into the Any.

-Joe
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to