Browse Source

Allow implicit conversions in return statements.

pull/844/head
Siegfried Pammer 9 years ago
parent
commit
efca6babbd
  1. 2
      ICSharpCode.Decompiler.Tests/CustomAttributes/S_CustomAttributeSamples.cs
  2. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
  3. 2
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

2
ICSharpCode.Decompiler.Tests/CustomAttributes/S_CustomAttributeSamples.cs

@ -264,7 +264,7 @@ namespace NamedInitializerPropertyType
{ {
get get
{ {
return (Type)null; return null;
} }
set set
{ {

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs

@ -73,13 +73,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private int[,] Array() private int[,] Array()
{ {
return (int[,])null; return null;
} }
private unsafe int* GetPointer() private unsafe int* GetPointer()
{ {
// return null; return null;
return (int*)0u;
} }
public int GetIndex() public int GetIndex()

2
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -183,7 +183,7 @@ namespace ICSharpCode.Decompiler.CSharp
protected internal override Statement VisitReturn(Return inst) protected internal override Statement VisitReturn(Return inst)
{ {
IType targetType = currentFunction.IsAsync ? currentFunction.AsyncReturnType : currentMethod.ReturnType; IType targetType = currentFunction.IsAsync ? currentFunction.AsyncReturnType : currentMethod.ReturnType;
return new ReturnStatement(exprBuilder.Translate(inst.Value).ConvertTo(targetType, exprBuilder)); return new ReturnStatement(exprBuilder.Translate(inst.Value).ConvertTo(targetType, exprBuilder, allowImplicitConversion: true));
} }
protected internal override Statement VisitYieldReturn(YieldReturn inst) protected internal override Statement VisitYieldReturn(YieldReturn inst)

Loading…
Cancel
Save