mirror of
https://github.com/apple/swift.git
synced 2026-10-12 14:50:47 +02:00
Importing a friend constructor decl causes an assertion failure because
we eagerly add constructors as members, but the decl context of the
friend decl is different from the context we are adding it to.
That causes us to hit the following assertion:
void IterableDeclContext::addMember(Decl *member, Decl *hint, bool insertAtHead) {
...
assert(member->getDeclContext() == static_cast<DeclContext *>(nominal) &&
"Added member to the wrong context");
...
}
This patch continues to import friend decls (in case we rely on any side
effects from doing so) but bypasses any logic in VisitRecordDecl that
might cause a friend decl to be added as a member.
rdar://174353241
21 lines
374 B
C
21 lines
374 B
C
#pragma once
|
|
|
|
struct A {
|
|
A();
|
|
void memberInA(int x) const;
|
|
};
|
|
|
|
struct B {
|
|
// These should not get imported as members of B, because friendship means
|
|
// nothing in Swift
|
|
friend A::A();
|
|
friend void A::memberInA(int) const;
|
|
|
|
void memberInB() const;
|
|
};
|
|
|
|
// C should not mistakenly "inherit" the friend declarations in B
|
|
struct C : B {
|
|
void memberInC() const;
|
|
};
|