|
|
|
@ -535,6 +535,17 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -535,6 +535,17 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
.ConvertTo(targetType, expressionBuilder, checkForOverflow, allowImplicitConversion); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (type.Kind == TypeKind.Dynamic && targetType.IsReferenceType == true && !targetType.IsKnownType(KnownTypeCode.Object)) |
|
|
|
|
{ |
|
|
|
|
// "static" conversion between dynamic and a reference type requires us to add a cast to object,
|
|
|
|
|
// otherwise recompilation would produce a dynamic cast.
|
|
|
|
|
// (T)dynamicExpression is a "dynamic" cast
|
|
|
|
|
// (T)(object)dynamicExpression is a "static" cast
|
|
|
|
|
// as "dynamic" casts are handled differently by ExpressionBuilder.VisitDynamicConvertInstruction
|
|
|
|
|
// we can always insert the cast to object, if we encounter a conversion from any reference type to dynamic.
|
|
|
|
|
return this.ConvertTo(compilation.FindType(KnownTypeCode.Object), expressionBuilder) |
|
|
|
|
.ConvertTo(targetType, expressionBuilder, checkForOverflow, allowImplicitConversion); |
|
|
|
|
} |
|
|
|
|
if (targetType.Kind.IsAnyPointer() && (0.Equals(ResolveResult.ConstantValue) || 0u.Equals(ResolveResult.ConstantValue))) |
|
|
|
|
{ |
|
|
|
|
if (allowImplicitConversion) |
|
|
|
|