@@ -178,12 +178,20 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
178178 }
179179 }
180180
181- if (ctx.LangOpts .hasFeature (Feature::BitwiseCopyable)) {
182- auto *bitwiseCopyableProtocol =
183- ctx.getProtocol (KnownProtocolKind::BitwiseCopyable);
184- if (bitwiseCopyableProtocol && mod->checkConformance (type, bitwiseCopyableProtocol)) {
185- diags.diagnose (loc, diag::lifetime_dependence_on_bitwise_copyable);
186- return true ;
181+ // Diagnose when we have lifetime dependence on a type that is
182+ // BitwiseCopyable & Escapable.
183+ // ~Escapable types are non-trivial in SIL and we should not raise this
184+ // error.
185+ // TODO: Diagnose ~Escapable types are always non-trivial in SIL.
186+ if (type->isEscapable ()) {
187+ if (ctx.LangOpts .hasFeature (Feature::BitwiseCopyable)) {
188+ auto *bitwiseCopyableProtocol =
189+ ctx.getProtocol (KnownProtocolKind::BitwiseCopyable);
190+ if (bitwiseCopyableProtocol &&
191+ mod->checkConformance (type, bitwiseCopyableProtocol)) {
192+ diags.diagnose (loc, diag::lifetime_dependence_on_bitwise_copyable);
193+ return true ;
194+ }
187195 }
188196 }
189197
@@ -379,7 +387,7 @@ LifetimeDependenceInfo::infer(AbstractFunctionDecl *afd, Type resultType) {
379387 // TODO: rdar://123555720: Remove this check after another round of
380388 // surveying builtins
381389 if (auto *fd = dyn_cast<FuncDecl>(afd)) {
382- if (fd->isImplicit ()) {
390+ if (fd->isImplicit () && fd-> getModuleContext ()-> isBuiltinModule () ) {
383391 return std::nullopt ;
384392 }
385393 }
0 commit comments