From 2100d53faafc15793825f9d16951893e3604eb27 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 6 Sep 2026 10:51:07 +0200 Subject: [PATCH] Take the span type from the array conversion's return type MatchArrayInitializerFinal selects the operator by its return type, so the block's result type is that return type. The declaring type only happens to be the same one for the two array-to-span operators; Span also declares the conversion to ReadOnlySpan. Assisted-by: Claude:claude-opus-5:Claude Code --- ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index 2ac0847ee..d9b1ab982 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -3966,8 +3966,8 @@ namespace ICSharpCode.Decompiler.CSharp var initializer = expr.WithILInstruction(block).WithRR(rr); if (arrayToSpan != null) { - var arrayToSpanRR = new ConversionResolveResult(arrayToSpan.DeclaringType, rr, Conversion.ImplicitSpanConversion); - initializer = new CastExpression(ConvertType(arrayToSpan.DeclaringType), expr).WithoutILInstruction().WithRR(arrayToSpanRR); + var arrayToSpanRR = new ConversionResolveResult(arrayToSpan.ReturnType, rr, Conversion.ImplicitSpanConversion); + initializer = new CastExpression(ConvertType(arrayToSpan.ReturnType), expr).WithoutILInstruction().WithRR(arrayToSpanRR); } return initializer; }