File tree Expand file tree Collapse file tree 3 files changed +35
-6
lines changed
test/Interop/Cxx/operators Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -2116,6 +2116,15 @@ namespace {
21162116 continue ;
21172117 }
21182118
2119+ if (auto friendDecl = dyn_cast<clang::FriendDecl>(m)) {
2120+ if (friendDecl->getFriendDecl ()) {
2121+ m = friendDecl->getFriendDecl ();
2122+ auto lookupTable = Impl.findLookupTable (m->getOwningModule ());
2123+ addEntryToLookupTable (*lookupTable, friendDecl->getFriendDecl (),
2124+ Impl.getNameImporter ());
2125+ }
2126+ }
2127+
21192128 auto nd = dyn_cast<clang::NamedDecl>(m);
21202129 if (!nd) {
21212130 // We couldn't import the member, so we can't reference it in Swift.
@@ -2145,6 +2154,7 @@ namespace {
21452154 }
21462155
21472156 Decl *member = Impl.importDecl (nd, getActiveSwiftVersion ());
2157+
21482158 if (!member) {
21492159 if (!isa<clang::TypeDecl>(nd) && !isa<clang::FunctionDecl>(nd)) {
21502160 // We don't know what this member is.
@@ -4764,12 +4774,6 @@ namespace {
47644774 return nullptr ;
47654775 }
47664776
4767- Decl *VisitFriendDecl (const clang::FriendDecl *decl) {
4768- // Friends are not imported; Swift has a different access control
4769- // mechanism.
4770- return nullptr ;
4771- }
4772-
47734777 Decl *VisitFriendTemplateDecl (const clang::FriendTemplateDecl *decl) {
47744778 // Friends are not imported; Swift has a different access control
47754779 // mechanism.
Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ struct LoadableIntWrapper {
2121 value++;
2222 return *this ;
2323 }
24+
25+ // Friend functions
26+ friend bool operator ==(const LoadableIntWrapper lhs,
27+ const LoadableIntWrapper &rhs) {
28+ return lhs.value == rhs.value ;
29+ }
30+
31+ friend LoadableIntWrapper operator -(const LoadableIntWrapper& obj) {
32+ return LoadableIntWrapper{.value = -obj.value };
33+ }
2434};
2535
2636struct LoadableBoolWrapper {
Original file line number Diff line number Diff line change @@ -30,6 +30,21 @@ OperatorsTestSuite.test("AddressOnlyIntWrapper.minus") {
3030}
3131#endif
3232
33+ OperatorsTestSuite . test ( " LoadableIntWrapper.equal (inline) " ) {
34+ let lhs = LoadableIntWrapper ( value: 42 )
35+ let rhs = LoadableIntWrapper ( value: 42 )
36+
37+ let result = lhs == rhs
38+
39+ expectTrue ( result)
40+ }
41+
42+ OperatorsTestSuite . test ( " LoadableIntWrapper.unaryMinus (inline) " ) {
43+ let lhs = LoadableIntWrapper ( value: 42 )
44+ let inverseLhs = - lhs;
45+ expectEqual ( - 42 , inverseLhs. value)
46+ }
47+
3348OperatorsTestSuite . test ( " LoadableIntWrapper.call (inline) " ) {
3449 var wrapper = LoadableIntWrapper ( value: 42 )
3550
You can’t perform that action at this time.
0 commit comments