mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[cxx-interop] Do not import C++23 deducing this
We don't currently support C++23 deducing this parameters. Until we do, let's not expose incorrect function signatures to Swift. rdar://161345481
This commit is contained in:
@@ -1538,6 +1538,10 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
|
||||
if (!swift3OrLaterName && isa<clang::CXXMethodDecl>(D)) {
|
||||
return ImportedName();
|
||||
}
|
||||
// If this function uses C++23 deducing this, bail.
|
||||
if (auto functionDecl = dyn_cast<clang::FunctionDecl>(D))
|
||||
if (functionDecl->hasCXXExplicitFunctionObjectParameter())
|
||||
return {};
|
||||
|
||||
// Dig out the definition, if there is one.
|
||||
if (auto def = getDefinitionForClangTypeDecl(D)) {
|
||||
|
||||
4
test/Interop/Cxx/class/method/Inputs/deducing-this.h
Normal file
4
test/Interop/Cxx/class/method/Inputs/deducing-this.h
Normal file
@@ -0,0 +1,4 @@
|
||||
struct HasDeducingThis {
|
||||
int value;
|
||||
int deducingRef(this HasDeducingThis &self) { return self.value; }
|
||||
};
|
||||
@@ -1,3 +1,8 @@
|
||||
module DeducingThis {
|
||||
header "deducing-this.h"
|
||||
requires cplusplus23
|
||||
}
|
||||
|
||||
module Methods {
|
||||
header "methods.h"
|
||||
requires cplusplus
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=DeducingThis -I %S/Inputs -source-filename=x -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++23 | %FileCheck %s
|
||||
|
||||
// This mostly ensures that we don't import deducing this method with an incorrect signature.
|
||||
|
||||
// CHECK: struct HasDeducingThis {
|
||||
// CHECK-NOT: deducingRef
|
||||
Reference in New Issue
Block a user