Skip to content

Commit f0a32d1

Browse files
committed
[cxx-interop] Prevent protocol conformance table from being prematurely populated
We've started seeing build failures where the conformance of a `std::vector` instantiation to `CxxVector` is missing. This was because the LifetimeDependenceInfoRequest triggers the protocol conformance table for the instantiation to be built before the synthesized conformance gets added. This works around the issue by preventing LifetimeDependenceInfoRequest from running for the synthesized default argument generator function, which was the culprit of this particular failure. rdar://155977071
1 parent 90f9fce commit f0a32d1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/ClangImporter/SwiftDeclSynthesizer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/AST/ParameterList.h"
2222
#include "swift/AST/Pattern.h"
2323
#include "swift/AST/Stmt.h"
24+
#include "swift/AST/TypeCheckRequests.h"
2425
#include "swift/Basic/Assertions.h"
2526
#include "clang/AST/Mangle.h"
2627
#include "clang/Sema/DelayedDiagnostic.h"
@@ -2532,6 +2533,11 @@ SwiftDeclSynthesizer::makeDefaultArgument(const clang::ParmVarDecl *param,
25322533
funcDecl->setAccess(AccessLevel::Public);
25332534
funcDecl->getAttrs().add(new (ctx)
25342535
AlwaysEmitIntoClientAttr(/*IsImplicit=*/true));
2536+
// At this point, the parameter/return types of funcDecl might not be imported
2537+
// into Swift completely, meaning that their protocol conformances might not
2538+
// be populated yet. Prevent LifetimeDependenceInfoRequest from prematurely
2539+
// populating the conformance table for the types involved.
2540+
ctx.evaluator.cacheOutput(LifetimeDependenceInfoRequest{funcDecl}, {});
25352541

25362542
ImporterImpl.defaultArgGenerators[param] = funcDecl;
25372543

0 commit comments

Comments
 (0)