Linker error with NSManagedObject implementing a protocol in Swift

Originator:neocool2
Number:rdar://19570127 Date Originated:22-Jan-2015 11:53 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Version 6.1.1 (6A2008a)
Classification:Serious Bug Reproducible:Always
 
Summary:

An NSManagedObject subclass written in Swift which implements a protocol leads to linker errors if a property from the protocol is also @NSManaged.

Steps to Reproduce:

Consider the following Swift program:

import CoreData
 
@objc protocol Foo {
  var bar: String { get set }
}
 
class Bar: NSManagedObject, Foo {
  @NSManaged var bar: String
}
 
let b = Bar()

and compile it using `xcrun swiftc main.swift`

Expected Results:

Ideally, the program compiles and links successfully. Another option would be that it is rejected by the compiler in some fashion, because this case is unsupported on purpose.

Actual Results:

Linker errror:

$ xcrun swiftc nsmanaged.swift 
Undefined symbols for architecture x86_64:
  "__TFC9nsmanaged3Barg3barSS", referenced from:
      __TFC9nsmanaged3Barm3barSS in nsmanaged-9a8736.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: linker command failed with exit code 1 (use -v to see invocation)

Regression:

This has been possible in Objective-C

Notes: -

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!