Skip to content

Commit 83fd92b

Browse files
committed
[ClangImporter] Use the correct name for replacement decls.
When a C declaration is marked unavailable with a replacement, we look for the replacement to see how it would be imported into Swift. Make sure we do that with respect to the active language version.
1 parent c297e64 commit 83fd92b

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6516,7 +6516,7 @@ getSwiftNameFromClangName(StringRef replacement) {
65166516
if (!clangDecl)
65176517
return "";
65186518

6519-
auto importedName = importFullName(clangDecl, ImportNameVersion::Swift3);
6519+
auto importedName = importFullName(clangDecl, CurrentVersion);
65206520
if (!importedName)
65216521
return "";
65226522

test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ void jumpToLocation(double x, double y, double z);
22

33
void acceptDoublePointer(double* _Nonnull ptr) __attribute__((swift_name("accept(_:)")));
44

5+
void oldAcceptDoublePointer(double* _Nonnull ptr) __attribute__((availability(swift, unavailable, replacement="acceptDoublePointer")));
6+
57
#ifdef __OBJC__
68

79
__attribute__((objc_root_class))

test/APINotes/versioned.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ func testRenamedTopLevel() {
3939
// CHECK-DIAGS-4: 'accept(_:)'
4040
// CHECK-DIAGS-3: 'acceptPointer(_:)'
4141
// CHECK-DIAGS: note: 'acceptDoublePointer' was obsoleted in Swift 3
42+
43+
oldAcceptDoublePointer(&value)
44+
// CHECK-DIAGS: versioned.swift:[[@LINE-1]]:3: error: 'oldAcceptDoublePointer' has been renamed to
45+
// CHECK-DIAGS-4: 'accept(_:)'
46+
// CHECK-DIAGS-3: 'acceptPointer(_:)'
47+
// CHECK-DIAGS: note: 'oldAcceptDoublePointer' has been explicitly marked unavailable here
4248
}

0 commit comments

Comments
 (0)