@@ -2684,30 +2684,31 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
2684
2684
if (!expected->hasName ())
2685
2685
continue ;
2686
2686
for (auto *var : vars) {
2687
- if (var->hasName () && var->getName () == expected->getName ()) {
2688
- SILValue value = VarLocs[var].value ;
2689
- SILType type = value->getType ();
2690
-
2691
- // If we have an address-only type, initialize the temporary
2692
- // allocation. We're not going to pass the address as a block
2693
- // argument.
2694
- if (type.isAddressOnly (M)) {
2695
- emission.emitAddressOnlyInitialization (expected, value);
2696
- break ;
2697
- }
2687
+ if (!var->hasName () || var->getName () != expected->getName ())
2688
+ continue ;
2698
2689
2699
- // If we have a loadable address, perform a load [copy].
2700
- if (type.isAddress ()) {
2701
- value = B.emitLoadValueOperation (CurrentSILLoc, value,
2702
- LoadOwnershipQualifier::Copy);
2703
- args.push_back (value);
2704
- break ;
2705
- }
2690
+ SILValue value = VarLocs[var].value ;
2691
+ SILType type = value->getType ();
2706
2692
2707
- value = B.emitCopyValueOperation (CurrentSILLoc, value);
2693
+ // If we have an address-only type, initialize the temporary
2694
+ // allocation. We're not going to pass the address as a block
2695
+ // argument.
2696
+ if (type.isAddressOnly (M)) {
2697
+ emission.emitAddressOnlyInitialization (expected, value);
2698
+ break ;
2699
+ }
2700
+
2701
+ // If we have a loadable address, perform a load [copy].
2702
+ if (type.isAddress ()) {
2703
+ value = B.emitLoadValueOperation (CurrentSILLoc, value,
2704
+ LoadOwnershipQualifier::Copy);
2708
2705
args.push_back (value);
2709
2706
break ;
2710
2707
}
2708
+
2709
+ value = B.emitCopyValueOperation (CurrentSILLoc, value);
2710
+ args.push_back (value);
2711
+ break ;
2711
2712
}
2712
2713
}
2713
2714
0 commit comments