{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift/issues/6413","repository_url":"https://api.github.com/repos/apple/swift","labels_url":"https://api.github.com/repos/apple/swift/issues/6413/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift/issues/6413/comments","events_url":"https://api.github.com/repos/apple/swift/issues/6413/events","html_url":"https://github.com/apple/swift/pull/6413","id":196737609,"number":6413,"title":"Fix load of NSString to retain its source","user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars.githubusercontent.com/u/1136864?v=3","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-12-20T17:53:39Z","updated_at":"2016-12-20T19:51:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/6413","html_url":"https://github.com/apple/swift/pull/6413","diff_url":"https://github.com/apple/swift/pull/6413.diff","patch_url":"https://github.com/apple/swift/pull/6413.patch"},"body":"[DO NOT MERGE: NEEDS TEST]\r\n\r\nFixes rdar://21782689: \"Swift over-releases NSString when bridging\".\r\n\r\nThe NSString -> String bridging function takes its input at +1 (`@owned`),\r\nbut the compiler seemed to be assuming it should be +0. The solution is\r\nto make the compiler do a proper copy, rather than a borrow.\r\n\r\nI have a test case whipped up, but it involves a .h and .m file, and I'm not sure how to integrate that into the lit infra."},"comment":{"url":"https://api.github.com/repos/apple/swift/issues/comments/268340985","html_url":"https://github.com/apple/swift/pull/6413#issuecomment-268340985","issue_url":"https://api.github.com/repos/apple/swift/issues/6413","id":268340985,"user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars.githubusercontent.com/u/1136864?v=3","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"created_at":"2016-12-20T19:51:08Z","updated_at":"2016-12-20T19:51:08Z","body":"@jrose-apple convinced me to do this as a SILGen test, which I've pushed up. For posterity, here's the \"missing\" .mm file, if anyone ever wants to reproduce the actual runtime behaviour:\r\n\r\n```objc\r\n#import \"Globals.h\"\r\n\r\n__strong NSString *globalString;\r\n__strong NSObject *globalObject;\r\n__strong id globalId;\r\n__strong NSArray *const globalConstArray = @[@\"a\", @\"b\"];\r\n__strong NSArray *globalArray;\r\n\r\n@implementation Globals\r\n\r\nstatic id sharedInstance;\r\n\r\n+ (instancetype)sharedInstance {\r\n    static dispatch_once_t onceToken;\r\n\r\n    dispatch_once(&onceToken, ^{\r\n        sharedInstance = [[self alloc] init];\r\n    });\r\n    \r\n    return sharedInstance;\r\n}\r\n\r\n- (instancetype)init {\r\n    self = [super init];\r\n    \r\n    if (nil != self) {\r\n        globalString = [NSString stringWithFormat:@\"I am a global NSString\"];\r\n        globalObject = [NSString stringWithFormat:@\"I am a global NSString\"];\r\n        globalId = [NSString stringWithFormat:@\"I am a global NSString\"];\r\n        globalArray = @[@\"a\", @\"b\"];\r\n    }\r\n    \r\n    return self;\r\n}\r\n@end\r\n```"}}
{"actor":{"display_login":"Gankro"}}