Skip to content

Commit 79ed26f

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 b9853c2 commit 79ed26f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/ClangImporter/ImportDecl.cpp

+1-1
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

+2
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

+6
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ func testRenamedTopLevel() {
3333
// CHECK-DIAGS-4: 'accept(_:)'
3434
// CHECK-DIAGS-3: 'acceptPointer(_:)'
3535
// CHECK-DIAGS: note: 'acceptDoublePointer' was obsoleted in Swift 3
36+
37+
oldAcceptDoublePointer(&value)
38+
// CHECK-DIAGS: versioned.swift:[[@LINE-1]]:3: error: 'oldAcceptDoublePointer' has been renamed to
39+
// CHECK-DIAGS-4: 'accept(_:)'
40+
// CHECK-DIAGS-3: 'acceptPointer(_:)'
41+
// CHECK-DIAGS: note: 'oldAcceptDoublePointer' has been explicitly marked unavailable here
3642
}

0 commit comments

Comments
 (0)