diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatterns.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatterns.cs index 858f8e6..d547959 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatterns.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatterns.cs @@ -16,9 +16,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// Await shapes that still decompile to code that does not compile are tracked as #4017 (type -// parameter with an interface constraint), #4018 (static dynamic call) and #4019 (with -// expression); they are absent here because they have no correct output to pin yet. +// An await shape that still decompiles to code that does not compile is tracked as #4019 (with +// expression); it is absent here because it has no correct output to pin yet. #pragma warning disable 1998 using System; @@ -539,6 +538,16 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.AsyncAwait await awaitable; } + public async Task TypeParameterWithInterfaceConstraint(T awaitable) where T : IAwaitable + { + await awaitable; + } + + public async Task TypeParameterArrayElementWithInterfaceConstraint(T[] awaitables) where T : IAwaitable + { + await awaitables[0]; + } + public async Task ConfiguredTaskAwaitable(Task task) { #if ROSLYN2 diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index 5655ce3..10cd9e4 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -4557,7 +4557,12 @@ namespace ICSharpCode.Decompiler.CSharp } } - var value = Translate(inst.Value, typeHint: expectedType); + var operand = inst.Value; + if (operand is LdObjIfRef ldObjIfRef) + { + operand = ldObjIfRef.Target; + } + var value = Translate(operand, typeHint: expectedType); if (value.Expression is DirectionExpression) { // we can deference the managed reference by stripping away the 'ref'