swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.6k stars 10.37k forks source link

[SR-5268] Swift type encoding of properties should include class names #47843

Open swift-ci opened 7 years ago

swift-ci commented 7 years ago
Previous ID SR-5268
Radar None
Original Reporter flovilmart (JIRA User)
Type Bug
Environment Swift 3.1, Swift 3.2, Swift 4
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, IRGen | |Assignee | None | |Priority | Medium | md5: 0a210a9676dd780ea82e37b9d324abfb

Issue Description:

While migrating from Swift 2 to Swift 3.1, for the Parse iOS SDK, we encountered the following issue:

PFRelation\< ObjectType: PFObject*> is defined in Objective-C as a lightweight generic.

When reading the `property_getAttributes` in a PFObject subclass in objective-c, the type encoding is property set to: `@"PFRelation\` therefore our codepath is correct as per the test suite here

when defining it in a swift subclass however, the type encoding looses the PFRelation specialization and is rendered as an `@` which is inconsistent with the behaviour with the objective-c runtime.

ex:

class MyObject: PFObject, PFSubclassing {
  @NSManaged var relation: PFRelation<PFObject>
}

We expect the behaviour to be consistent and the swift compiler to produce the right type encoding, in conformance with the objective-c compiler.

Note: observed as well on Swift 4

belkadan commented 7 years ago

This doesn't have anything to do with generics, and isn't a regression. You're just saying Swift should try to emit property attributes with class names.

swift-ci commented 7 years ago

Comment by Florent Vilmart (JIRA)

yes, but in other cases, it looks ok (NSObject subclasses defined in obj-c)