Skip to content

Commit fd025ab

Browse files
committed
[cxx-interop] Don't synthesize conformance to invalid protocols.
1 parent 665d3e1 commit fd025ab

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,13 @@ void ClangImporter::Implementation::addSynthesizedProtocolAttrs(
429429
auto &ctx = nominal->getASTContext();
430430

431431
for (auto kind : synthesizedProtocolAttrs) {
432-
nominal->getAttrs().add(
433-
new (ctx) SynthesizedProtocolAttr(ctx.getProtocol(kind), this, isUnchecked));
432+
// This is unfortunately not an error because some test use mock protocols.
433+
// If those tests were updated, we could assert that
434+
// ctx.getProtocol(kind) != nulltpr which would be nice.
435+
if (auto proto = ctx.getProtocol(kind))
436+
nominal->getAttrs().add(
437+
new (ctx) SynthesizedProtocolAttr(ctx.getProtocol(kind), this,
438+
isUnchecked));
434439
}
435440
}
436441

0 commit comments

Comments
 (0)