Skip to content

Commit 03d8971

Browse files
authored
Merge pull request #62118 from apple/egorzhdan/cxx-sequence-side-effects
[cxx-interop] Avoid side-effects in member lookup when conforming types to `CxxSequence`
2 parents 8c36500 + 904938a commit 03d8971

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

lib/ClangImporter/ClangDerivedConformances.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ lookupDirectWithoutExtensions(NominalTypeDecl *decl, Identifier id) {
2727
decl->getASTContext().evaluator, ClangRecordMemberLookup({decl, id}), {});
2828

2929
// Check if there are any synthesized Swift members that match the name.
30-
for (auto member : decl->getMembers()) {
30+
for (auto member : decl->getCurrentMembersWithoutLoading()) {
3131
if (auto namedMember = dyn_cast<ValueDecl>(member)) {
3232
if (namedMember->hasName() && !namedMember->getName().isSpecial() &&
3333
namedMember->getName().getBaseIdentifier().is(id.str()) &&

test/Interop/Cxx/stdlib/overlay/custom-iterator-module-interface.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
// RUN: %target-swift-ide-test -print-module -module-to-print=CustomSequence -source-filename=x -I %S/Inputs -enable-experimental-cxx-interop -module-cache-path %t | %FileCheck %s
1+
// RUN: %target-swift-ide-test -print-module -module-to-print=CustomSequence -source-filename=x -I %S/Inputs -enable-experimental-cxx-interop | %FileCheck %s
22

33
// CHECK: struct ConstIterator : UnsafeCxxInputIterator {
44
// CHECK: var pointee: Int32 { get }
55
// CHECK: func successor() -> ConstIterator
6-
// CHECK: static func == (lhs: ConstIterator, other: ConstIterator) -> Bool
76
// CHECK: typealias Pointee = Int32
7+
// CHECK: static func == (lhs: ConstIterator, other: ConstIterator) -> Bool
88
// CHECK: }
99

1010
// CHECK: struct ConstRACIterator : UnsafeCxxRandomAccessIterator, UnsafeCxxInputIterator {
1111
// CHECK: var pointee: Int32 { get }
1212
// CHECK: func successor() -> ConstRACIterator
13+
// CHECK: typealias Pointee = Int32
14+
// CHECK: typealias Distance = Int32
1315
// CHECK: static func += (lhs: inout ConstRACIterator, v: ConstRACIterator.difference_type)
1416
// CHECK: static func - (lhs: ConstRACIterator, other: ConstRACIterator) -> Int32
1517
// CHECK: static func == (lhs: ConstRACIterator, other: ConstRACIterator) -> Bool
16-
// CHECK: typealias Pointee = Int32
17-
// CHECK: typealias Distance = Int32
1818
// CHECK: }
1919

2020
// CHECK: struct ConstRACIteratorRefPlusEq : UnsafeCxxRandomAccessIterator, UnsafeCxxInputIterator {
2121
// CHECK: var pointee: Int32 { get }
2222
// CHECK: func successor() -> ConstRACIterator
23+
// CHECK: typealias Pointee = Int32
24+
// CHECK: typealias Distance = Int32
2325
// CHECK: static func += (lhs: inout ConstRACIteratorRefPlusEq, v: ConstRACIteratorRefPlusEq.difference_type)
2426
// CHECK: static func - (lhs: ConstRACIteratorRefPlusEq, other: ConstRACIteratorRefPlusEq) -> Int32
2527
// CHECK: static func == (lhs: ConstRACIteratorRefPlusEq, other: ConstRACIteratorRefPlusEq) -> Bool
26-
// CHECK: typealias Pointee = Int32
27-
// CHECK: typealias Distance = Int32
2828
// CHECK: }
2929

3030
// CHECK: struct ConstIteratorOutOfLineEq : UnsafeCxxInputIterator {
@@ -36,46 +36,46 @@
3636
// CHECK: struct MinimalIterator : UnsafeCxxInputIterator {
3737
// CHECK: var pointee: Int32 { get }
3838
// CHECK: func successor() -> MinimalIterator
39-
// CHECK: static func == (lhs: MinimalIterator, other: MinimalIterator) -> Bool
4039
// CHECK: typealias Pointee = Int32
40+
// CHECK: static func == (lhs: MinimalIterator, other: MinimalIterator) -> Bool
4141
// CHECK: }
4242

4343
// CHECK: struct ForwardIterator : UnsafeCxxInputIterator {
4444
// CHECK: var pointee: Int32 { get }
4545
// CHECK: func successor() -> ForwardIterator
46-
// CHECK: static func == (lhs: ForwardIterator, other: ForwardIterator) -> Bool
4746
// CHECK: typealias Pointee = Int32
47+
// CHECK: static func == (lhs: ForwardIterator, other: ForwardIterator) -> Bool
4848
// CHECK: }
4949

5050
// CHECK: struct HasCustomIteratorTag : UnsafeCxxInputIterator {
5151
// CHECK: var pointee: Int32 { get }
5252
// CHECK: func successor() -> HasCustomIteratorTag
53-
// CHECK: static func == (lhs: HasCustomIteratorTag, other: HasCustomIteratorTag) -> Bool
5453
// CHECK: typealias Pointee = Int32
54+
// CHECK: static func == (lhs: HasCustomIteratorTag, other: HasCustomIteratorTag) -> Bool
5555
// CHECK: }
5656

5757
// CHECK: struct HasCustomRACIteratorTag : UnsafeCxxRandomAccessIterator, UnsafeCxxInputIterator {
5858
// CHECK: var pointee: Int32 { get }
5959
// CHECK: func successor() -> HasCustomRACIteratorTag
60+
// CHECK: typealias Pointee = Int32
61+
// CHECK: typealias Distance = Int32
6062
// CHECK: static func += (lhs: inout HasCustomRACIteratorTag, x: Int32)
6163
// CHECK: static func - (lhs: HasCustomRACIteratorTag, x: HasCustomRACIteratorTag) -> Int32
6264
// CHECK: static func == (lhs: HasCustomRACIteratorTag, other: HasCustomRACIteratorTag) -> Bool
63-
// CHECK: typealias Pointee = Int32
64-
// CHECK: typealias Distance = Int32
6565
// CHECK: }
6666

6767
// CHECK: struct HasCustomIteratorTagInline : UnsafeCxxInputIterator {
6868
// CHECK: var pointee: Int32 { get }
6969
// CHECK: func successor() -> HasCustomIteratorTagInline
70-
// CHECK: static func == (lhs: HasCustomIteratorTagInline, other: HasCustomIteratorTagInline) -> Bool
7170
// CHECK: typealias Pointee = Int32
71+
// CHECK: static func == (lhs: HasCustomIteratorTagInline, other: HasCustomIteratorTagInline) -> Bool
7272
// CHECK: }
7373

7474
// CHECK: struct HasTypedefIteratorTag : UnsafeCxxInputIterator {
7575
// CHECK: var pointee: Int32 { get }
7676
// CHECK: func successor() -> HasTypedefIteratorTag
77-
// CHECK: static func == (lhs: HasTypedefIteratorTag, other: HasTypedefIteratorTag) -> Bool
7877
// CHECK: typealias Pointee = Int32
78+
// CHECK: static func == (lhs: HasTypedefIteratorTag, other: HasTypedefIteratorTag) -> Bool
7979
// CHECK: }
8080

8181
// CHECK-NOT: struct HasNoIteratorCategory : UnsafeCxxInputIterator

0 commit comments

Comments
 (0)