Fix #4017: Look through LdObjIfRef on the operand of await

A constrained GetAwaiter call on a type parameter that is not known to be
a value type wraps its receiver in LdObjIfRef so the reference is read
before any further arguments. ExpressionBuilder has no translation for
LdObjIfRef, so the operand was dropped. GetAwaiter takes no further
arguments, so the operand can be translated from the address, as
CallBuilder already does for call receivers.
This commit is contained in:
dualfroz committed 2026-10-16 10:07:54 +02:00
1 parent 587f5c9583
commit 3f1ef717b6
2 files changed
+18 -4

No files matched your search

@@ -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'