diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 69a22f2fc5a92..ccb81b71a245e 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -5481,6 +5481,13 @@ cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) { (fn->getClangDecl() && isa(fn->getClangDecl()))) return nullptr; + if (auto cxxMethod = + dyn_cast_or_null(fn->getClangDecl())) { + // FIXME: if this function has rvalue this, we won't be able to synthesize + // the accessor correctly (https://github.com/apple/swift/issues/69745). + if (cxxMethod->getRefQualifier() == clang::RefQualifierKind::RQ_RValue) + return nullptr; + } ASTContext &context = decl->getASTContext(); auto out = FuncDecl::createImplicit( diff --git a/test/Interop/Cxx/class/inheritance/Inputs/functions.h b/test/Interop/Cxx/class/inheritance/Inputs/functions.h index 98093678f71be..eb49d60398819 100644 --- a/test/Interop/Cxx/class/inheritance/Inputs/functions.h +++ b/test/Interop/Cxx/class/inheritance/Inputs/functions.h @@ -22,6 +22,10 @@ struct Base { __attribute__((swift_attr("import_unsafe"))) { return "Base::constInBase"; } + inline const char *rvalueThisInBase() const&& + __attribute__((swift_attr("import_unsafe"))) { + return "Base::rvalueThisInBase"; + } // TODO: if these are unnamed we hit an (unrelated) SILGen bug. Same for // subscripts. inline const char *takesArgsInBase(int a, int b, int c) const diff --git a/test/Interop/Cxx/class/inheritance/functions-module-interface.swift b/test/Interop/Cxx/class/inheritance/functions-module-interface.swift index ec2bcab27de1f..e834042adcfba 100644 --- a/test/Interop/Cxx/class/inheritance/functions-module-interface.swift +++ b/test/Interop/Cxx/class/inheritance/functions-module-interface.swift @@ -15,6 +15,8 @@ // CHECK-NEXT: @discardableResult // CHECK-NEXT: func constInBase() -> UnsafePointer! // CHECK-NEXT: @discardableResult +// CHECK-NEXT: func rvalueThisInBase() -> UnsafePointer! +// CHECK-NEXT: @discardableResult // CHECK-NEXT: func takesArgsInBase(_ a: Int32, _ b: Int32, _ c: Int32) -> UnsafePointer! // CHECK-NEXT: @discardableResult // CHECK-NEXT: func takesNonTrivialInBase(_ a: NonTrivial) -> UnsafePointer! diff --git a/test/Interop/Cxx/class/inheritance/functions-typechecker.swift b/test/Interop/Cxx/class/inheritance/functions-typechecker.swift index 2f9462ca370e3..d4e97a4d3c24c 100644 --- a/test/Interop/Cxx/class/inheritance/functions-typechecker.swift +++ b/test/Interop/Cxx/class/inheritance/functions-typechecker.swift @@ -17,3 +17,6 @@ Derived().sameMethodNameSameSignature() Derived().sameMethodDifferentSignature(1) // ok, this is the base class method. Derived().sameMethodDifferentSignature() + +// FIXME: we should import this (https://github.com/apple/swift/issues/69745): +Derived().rvalueThisInBase() // expected-error {{value of type 'Derived' has no member 'rvalueThisInBase'}}