Skip to content

Commit 4fccfcc

Browse files
committed
[Clang importer] Don't insert members found via lookup into the wrong context.
Discovered while investigating rdar://85840928.
1 parent 7e375f7 commit 4fccfcc

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9780,7 +9780,8 @@ static void loadAllMembersOfRecordDecl(StructDecl *recordDecl) {
97809780
continue;
97819781

97829782
for (auto found : recordDecl->lookupDirect(name)) {
9783-
if (addedMembers.insert(found).second)
9783+
if (addedMembers.insert(found).second &&
9784+
found->getDeclContext() == recordDecl)
97849785
recordDecl->addMember(found);
97859786
}
97869787
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -import-objc-header %S/Inputs/0212-header.h -emit-sil %s
2+
3+
extension MyPoint {
4+
var x: Int { Int(y) }
5+
}
6+
7+
public func printIt(point: MyPoint) {
8+
print(point)
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
typedef struct {
2+
double x, y;
3+
} MyPoint;

0 commit comments

Comments
 (0)