@@ -3932,8 +3932,6 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
3932
3932
3933
3933
// Find the set of enum elements for the type so we can verify
3934
3934
// exhaustiveness.
3935
- // FIXME: We also need to consider if the enum is resilient, in which case
3936
- // we're never guaranteed to be exhaustive.
3937
3935
llvm::DenseSet<EnumElementDecl*> unswitchedElts;
3938
3936
uDecl->getAllElements (unswitchedElts);
3939
3937
@@ -4019,8 +4017,6 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
4019
4017
4020
4018
// Find the set of enum elements for the type so we can verify
4021
4019
// exhaustiveness.
4022
- // FIXME: We also need to consider if the enum is resilient, in which case
4023
- // we're never guaranteed to be exhaustive.
4024
4020
llvm::DenseSet<EnumElementDecl*> unswitchedElts;
4025
4021
uDecl->getAllElements (unswitchedElts);
4026
4022
@@ -4044,9 +4040,12 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
4044
4040
}
4045
4041
4046
4042
// If the switch is non-exhaustive, we require a default.
4047
- require (unswitchedElts.empty () || SOI->hasDefault (),
4048
- " nonexhaustive switch_enum_addr must have a default "
4049
- " destination" );
4043
+ bool isExhaustive =
4044
+ uDecl->isEffectivelyExhaustive (F.getModule ().getSwiftModule (),
4045
+ F.getResilienceExpansion ());
4046
+ require ((isExhaustive && unswitchedElts.empty ()) || SOI->hasDefault (),
4047
+ " nonexhaustive switch_enum_addr must have a default destination" );
4048
+
4050
4049
if (SOI->hasDefault ())
4051
4050
require (SOI->getDefaultBB ()->args_empty (),
4052
4051
" switch_enum_addr default destination must take "
0 commit comments