File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -499,9 +499,16 @@ bool SILDeclRef::isFragile() const {
499
499
DeclContext *dc;
500
500
if (auto closure = getAbstractClosureExpr ())
501
501
dc = closure->getLocalContext ();
502
- else
502
+ else {
503
503
dc = getDecl ()->getInnermostDeclContext ();
504
504
505
+ // Enum case constructors are serialized if the enum is @_versioned
506
+ // or public.
507
+ if (isEnumElement ())
508
+ if (cast<EnumDecl>(dc)->getEffectiveAccess () >= Accessibility::Public)
509
+ return true ;
510
+ }
511
+
505
512
// This is stupid
506
513
return (dc->getResilienceExpansion () == ResilienceExpansion::Minimal);
507
514
}
Original file line number Diff line number Diff line change @@ -24,3 +24,15 @@ public class MyCls {
24
24
// CHECK-LABEL: sil [fragile] @_T020inlineable_attribute5MyClsCfD : $@convention(method) (@owned MyCls) -> ()
25
25
@_inlineable deinit { }
26
26
}
27
+
28
+ // Make sure enum case constructors for public and versioned enums are
29
+ // [fragile].
30
+ @_versioned enum MyEnum {
31
+ case c( MySt )
32
+ }
33
+
34
+ // CHECK-LABEL: sil shared [transparent] [fragile] [thunk] @_T020inlineable_attribute6MyEnumO1cAcA0C2StVcACmFTc : $@convention(thin) (@thin MyEnum.Type) -> @owned @callee_owned (MySt) -> MyEnum
35
+
36
+ @_inlineable public func referencesMyEnum( ) {
37
+ _ = MyEnum . c
38
+ }
You can’t perform that action at this time.
0 commit comments