Use observe(func observe(_:options:changeHandler:) in performBackgroundTask gives weird result

Originator:hey.hgl
Number:rdar://32708841 Date Originated:June 12 2017
Status: Resolved:
Product:Core Data Product Version:
Classification: Reproducible:
 
If I use the new observe API in persistentContainer.performBackgroundTask, the closure will be called with very weird change value, and in the case I don't change the key path at all, the closure gets called too. Please see the provided test case.

Comments

The main part of the test case file contains this in application(_:didFinishLaunchingWithOptions:):

https://gist.github.com/anonymous/d933cd381a1fb2f7b2c78be4c4f1190a

Entity Foo contains a single attribute named "num" that is of the Double type


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!