AffineTransform() and NSAffineTransform() initializers are not semantically equivalent
Originator: | prachi | ||
Number: | rdar://27793851 | Date Originated: | 10-Aug-2016 |
Status: | Open | Resolved: | |
Product: | OS X SDK | Product Version: | Xcode 8.0 beta 5 (8S193k), OS X 10.11.6 (15G31) |
Classification: | Serious Bug | Reproducible: | Always |
Summary: The AffineTransform() and NSAffineTransform() initializers do not produce the same backing transformation matrices. This breaks automatic migration of NSAffineTransform to AffineTransform, as behavior differs. AffineTransform() => {m11:0.0, m12:0.0, m21:0.0, m22:0.0, tX:0.0, tY:0.0} NSAffineTransform() => {m11:1.0, m12:0.0, m21:0.0, m22:1.0, tX:0.0, tY:0.0} Steps to Reproduce: 1. Create an NSAffineTransform using NSAffineTransform() 2. Create an AffineTransform using AffineTransform() 3. Check if the AffineTransform is equal to the NSAffineTransform’s transformStruct. Expected Results: The equality check should return true. Actual Results: The equality check returns false. Version: Xcode 8.0 beta 5 (8S193k) OS X 10.11.6 (15G31) Notes: A workaround is to use AffineTransform.identity instead of AffineTransform(). Still, this is unexpected. See attached playground. import Cocoa func compare(transformStruct: AffineTransform, transformObject: NSAffineTransform) -> Bool { if transformStruct == transformObject.transformStruct { print("Equal!") return true } else { print("Not equal!") print("AffineTransform = \(transformStruct)") print("NSAffineTransform = \(transformObject.transformStruct)") return false } } // Returns false compare(transformStruct: AffineTransform(), transformObject: NSAffineTransform()) // Returns true compare(transformStruct: AffineTransform.identity, transformObject: NSAffineTransform())
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!