@@ -274,7 +274,16 @@ BoundExpression rewriteAssignment(BoundExpression leftRead, BoundExpression righ
274274 Debug . Assert ( rewrittenReceiver . Type is { } ) ;
275275 var variableRepresentsLocation = rewrittenReceiver . Type . IsValueType || rewrittenReceiver . Type . Kind == SymbolKind . TypeParameter ;
276276
277- var receiverTemp = _factory . StoreToTemp ( rewrittenReceiver , out assignmentToTemp , refKind : variableRepresentsLocation ? RefKind . Ref : RefKind . None ) ;
277+ var receiverTemp = _factory . StoreToTemp (
278+ rewrittenReceiver ,
279+ out assignmentToTemp ,
280+ refKind : variableRepresentsLocation ? RefKind . Ref : RefKind . None ,
281+ isKnownToReferToTempIfReferenceType : ! variableRepresentsLocation || rewrittenReceiver . Type . IsValueType ||
282+ ! CodeGenerator . HasHome ( rewrittenReceiver ,
283+ CodeGenerator . AddressKind . Constrained ,
284+ _factory . CurrentFunction ,
285+ peVerifyCompatEnabled : false ,
286+ stackLocalsOpt : null ) ) ;
278287 temps . Add ( receiverTemp . LocalSymbol ) ;
279288
280289 if ( ! isRegularCompoundAssignment &&
@@ -476,7 +485,6 @@ private BoundIndexerAccess TransformIndexerAccessContinued(
476485
477486 private BoundExpression TransformImplicitIndexerAccess (
478487 BoundImplicitIndexerAccess indexerAccess ,
479- bool isRegularCompoundAssignment ,
480488 ArrayBuilder < BoundExpression > stores ,
481489 ArrayBuilder < LocalSymbol > temps ,
482490 bool isDynamicAssignment )
@@ -486,19 +494,19 @@ private BoundExpression TransformImplicitIndexerAccess(
486494 _compilation . GetWellKnownType ( WellKnownType . System_Index ) ,
487495 TypeCompareKind . ConsiderEverything ) )
488496 {
489- return TransformIndexPatternIndexerAccess ( indexerAccess , isRegularCompoundAssignment , stores , temps , isDynamicAssignment ) ;
497+ return TransformIndexPatternIndexerAccess ( indexerAccess , stores , temps , isDynamicAssignment ) ;
490498 }
491499
492500 throw ExceptionUtilities . UnexpectedValue ( indexerAccess . Argument . Type ) ;
493501 }
494502
495- private BoundExpression TransformIndexPatternIndexerAccess ( BoundImplicitIndexerAccess implicitIndexerAccess , bool isRegularCompoundAssignment , ArrayBuilder < BoundExpression > stores , ArrayBuilder < LocalSymbol > temps , bool isDynamicAssignment )
503+ private BoundExpression TransformIndexPatternIndexerAccess ( BoundImplicitIndexerAccess implicitIndexerAccess , ArrayBuilder < BoundExpression > stores , ArrayBuilder < LocalSymbol > temps , bool isDynamicAssignment )
496504 {
497505 Debug . Assert ( implicitIndexerAccess . IndexerOrSliceAccess . GetRefKind ( ) == RefKind . None ) ;
498506 var access = GetUnderlyingIndexerOrSliceAccess (
499507 implicitIndexerAccess ,
500508 isLeftOfAssignment : true ,
501- isRegularAssignmentOrRegularCompoundAssignment : isRegularCompoundAssignment ,
509+ isRegularAssignment : false ,
502510 cacheAllArgumentsOnly : false ,
503511 stores , temps ) ;
504512
@@ -696,7 +704,7 @@ private BoundExpression TransformCompoundAssignmentLHS(BoundExpression originalL
696704
697705 if ( implicitIndexerAccess . GetRefKind ( ) == RefKind . None )
698706 {
699- return TransformImplicitIndexerAccess ( implicitIndexerAccess , isRegularCompoundAssignment , stores , temps , isDynamicAssignment ) ;
707+ return TransformImplicitIndexerAccess ( implicitIndexerAccess , stores , temps , isDynamicAssignment ) ;
700708 }
701709 }
702710 break ;
@@ -796,6 +804,7 @@ private BoundExpression TransformCompoundAssignmentLHS(BoundExpression originalL
796804
797805 if ( eventAccess . EventSymbol . IsWindowsRuntimeEvent )
798806 {
807+ Debug . Assert ( ! isRegularCompoundAssignment ) ;
799808 // This is a temporary object that will be rewritten away before the lowering completes.
800809 return eventAccess . Update ( TransformPropertyOrEventReceiver ( eventAccess . EventSymbol , eventAccess . ReceiverOpt ,
801810 isRegularCompoundAssignment , stores , temps ) ,
0 commit comments