swiftlang / swift

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

[SR-15535] Wrong suggested Swift rename with deprecated API from another module #57838

Open NachoSoto opened 2 years ago

NachoSoto commented 2 years ago
Previous ID SR-15535
Radar rdar://problem/85876855
Original Reporter @NachoSoto
Type Bug
Environment Apple Swift version 5.5.1 (swiftlang-1300.0.31.4 clang-1300.0.29.6) Target: arm64-apple-macosx12.0 Xcode 13.1 (13A1030d)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 1 | |Component/s | | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 799848e09653cfedd88874379605bd43

Issue Description:

See also https://github.com/RevenueCat/purchases-ios/issues/1008.

Consider this code in a framework (all Swift):

@available(iOS, obsoleted: 1, renamed: "New")
@available(tvOS, obsoleted: 1, renamed: "New")
@available(watchOS, obsoleted: 1, renamed: "New")
@available(macOS, obsoleted: 1, renamed: "New")
@objc(RCOld) public class Old: NSObject { }

@objc(RCNew)
public class New: NSObject {}

Using `Old` from the same module produces the correct diagnostic and fix-it (albeit duplicated for some reason):

// 'Old' has been renamed to 'New'
// Replace 'Old' with 'New'
private let old = Old()

However, the same line of code from outside the module is wrong, and produces no fix-it.

// 'Old' is unavailable in iOS: 'Old' has been renamed to 'RCNew'
private let old = Old()
jckarter commented 2 years ago

@swift-ci create