@@ -2684,30 +2684,31 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
26842684 if (!expected->hasName ())
26852685 continue ;
26862686 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 ;
26982689
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 ();
27062692
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);
27082705 args.push_back (value);
27092706 break ;
27102707 }
2708+
2709+ value = B.emitCopyValueOperation (CurrentSILLoc, value);
2710+ args.push_back (value);
2711+ break ;
27112712 }
27122713 }
27132714
0 commit comments