From 00cbbe8c3028a7c8ebf31676088e4e0f57c2c2ec Mon Sep 17 00:00:00 2001 From: Pavel Yaskevich Date: Thu, 8 Jun 2023 12:12:49 -0700 Subject: [PATCH] [Sema] InitAccessors: Don't synthesize default memberwise arg for init accessor initializations Default arguments for `init accessors` are not fully supported at the moment, so we shouldn't attempt to synthesize them in Sema just to crash during linking. (cherry picked from commit 8c54d3d5604ac5c5d57ef7eceb4bfe61ee5a7216) --- lib/Sema/CodeSynthesis.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index 647d907eb3451..1054c2a55ada6 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -144,6 +144,12 @@ static void maybeAddMemberwiseDefaultArg(ParamDecl *arg, VarDecl *var, if (!var->getParentPattern()->getSingleVar()) return; + // FIXME: Don't attempt to synthesize default arguments for init + // accessor properties because there could be multiple properties + // with default values they are going to initialize. + if (var->getAccessor(AccessorKind::Init)) + return; + // Whether we have explicit initialization. bool isExplicitlyInitialized = false; if (auto pbd = var->getParentPatternBinding()) {