Browse Source

HandleCallInstruction: Do not add casts to anonymous types in arguments.

pull/728/merge
Siegfried Pammer 9 years ago
parent
commit
054f6a1154
  1. 6
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

6
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -1034,7 +1034,11 @@ namespace ICSharpCode.Decompiler.CSharp @@ -1034,7 +1034,11 @@ namespace ICSharpCode.Decompiler.CSharp
Debug.Assert(inst.Arguments.Count == firstParamIndex + inst.Method.Parameters.Count);
for (int i = 0; i < arguments.Length; i++) {
var parameter = method.Parameters[i];
arguments[i] = Translate(inst.Arguments[firstParamIndex + i]).ConvertTo(parameter.Type, this);
arguments[i] = Translate(inst.Arguments[firstParamIndex + i]);
// HACK : do not add casts to anonymous types, in order to avoid compile errors.
// Ideally we should be able to remove casts to any type, if not explicitly required.
if (!parameter.Type.ContainsAnonymousType())
arguments[i] = arguments[i].ConvertTo(parameter.Type, this);
if (parameter.IsOut && arguments[i].Expression is DirectionExpression) {
((DirectionExpression)arguments[i].Expression).FieldDirection = FieldDirection.Out;

Loading…
Cancel
Save