Upstream icsharpcode/ILSpy state of the touched files before c5f455e56b
This commit is contained in:
1 parent
999d3b48fa
commit
587f5c9583
2 files changed
+724
-5
No files matched your search
@@ -3793,7 +3793,7 @@ namespace ICSharpCode.Decompiler.CSharp
|
||||
{
|
||||
var property = (IProperty)lastElement.Member;
|
||||
Debug.Assert(property.Parameters.Count == indices);
|
||||
Debug.Assert(property.Setter != null, $"Indexer property {property} has no setter");
|
||||
DecompilerAssert.That(property.Setter != null, $"Indexer property {property} has no setter");
|
||||
elementsStack.Peek().Add(
|
||||
new CallBuilder(this, typeSystem, settings)
|
||||
.BuildDictionaryInitializerExpression(lastElement.OpCode, property.Setter, initObjRR, GetIndices(lastElement.Indices, indexVariables).ToList(), info.Values!.Single())
|
||||
@@ -4060,13 +4060,22 @@ namespace ICSharpCode.Decompiler.CSharp
|
||||
|
||||
TranslatedExpression TranslateWithInitializer(Block block)
|
||||
{
|
||||
var stloc = block.Instructions.FirstOrDefault() as StLoc;
|
||||
var final = block.FinalInstruction as LdLoc;
|
||||
if (stloc == null || final == null || stloc.Variable != final.Variable || stloc.Variable.Kind != VariableKind.InitializerTarget)
|
||||
if (block.Instructions.FirstOrDefault() is not StLoc stloc
|
||||
|| block.FinalInstruction is not LdLoc final
|
||||
|| stloc.Variable != final.Variable || stloc.Variable.Kind != VariableKind.InitializerTarget)
|
||||
{
|
||||
throw new ArgumentException("given Block is invalid!");
|
||||
}
|
||||
ILInstruction oldValue = stloc.Value;
|
||||
if (stloc.Variable.Type.IsReferenceType == true)
|
||||
{
|
||||
// reference types must involve a <Clone>$() call
|
||||
Debug.Assert(TransformCollectionAndObjectInitializers.IsRecordCloneMethodCall((CallInstruction)stloc.Value));
|
||||
oldValue = ((CallInstruction)stloc.Value).Arguments.Single();
|
||||
}
|
||||
|
||||
WithInitializerExpression withInitializerExpression = new WithInitializerExpression();
|
||||
withInitializerExpression.Expression = Translate(stloc.Value, stloc.Variable.Type);
|
||||
withInitializerExpression.Expression = Translate(oldValue, stloc.Variable.Type);
|
||||
withInitializerExpression.Initializer = BuildArrayInitializerExpression(block, new InitializedObjectResolveResult(stloc.Variable.Type));
|
||||
|
||||
return withInitializerExpression.WithILInstruction(block)
|
||||
|
||||
Reference in new issue
Block a user