Skip to content

Commit b375aee

Browse files
Merge remote-tracking branch 'upstream/main' into parserBlowup
2 parents c731f14 + c2a1ed2 commit b375aee

File tree

4 files changed

+497
-123
lines changed

4 files changed

+497
-123
lines changed

src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,17 +677,23 @@ private ImmutableArray<BoundExpression> VisitArgumentsAndCaptureReceiverIfNeeded
677677
}
678678
else
679679
{
680-
refKind = rewrittenReceiver.GetRefKind();
681-
682-
if (refKind == RefKind.None &&
683-
!rewrittenReceiver.Type.IsReferenceType &&
684-
Binder.HasHome(rewrittenReceiver,
685-
Binder.AddressKind.Constrained,
686-
_factory.CurrentFunction,
687-
peVerifyCompatEnabled: false,
688-
stackLocalsOpt: null))
680+
if (rewrittenReceiver.Type.IsReferenceType)
689681
{
690-
refKind = RefKind.Ref;
682+
refKind = RefKind.None;
683+
}
684+
else
685+
{
686+
refKind = rewrittenReceiver.GetRefKind();
687+
688+
if (refKind == RefKind.None &&
689+
Binder.HasHome(rewrittenReceiver,
690+
Binder.AddressKind.Constrained,
691+
_factory.CurrentFunction,
692+
peVerifyCompatEnabled: false,
693+
stackLocalsOpt: null))
694+
{
695+
refKind = RefKind.Ref;
696+
}
691697
}
692698
}
693699

src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenCallTests.cs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,36 +2137,32 @@ public DummyHandler(int literalLength, int formattedCount, IMoveable logger)
21372137
verifier.VerifyIL("Program.Call1<T>",
21382138
@"
21392139
{
2140-
// Code size 70 (0x46)
2140+
// Code size 61 (0x3d)
21412141
.maxstack 6
2142-
.locals init (T& V_0,
2143-
T V_1,
2144-
DummyHandler V_2)
2142+
.locals init (T V_0,
2143+
DummyHandler V_1)
21452144
IL_0000: ldarg.0
21462145
IL_0001: ldobj ""T""
2147-
IL_0006: stloc.1
2148-
IL_0007: ldloca.s V_1
2149-
IL_0009: stloc.0
2150-
IL_000a: ldloc.0
2151-
IL_000b: ldarg.0
2152-
IL_000c: call ""int Program.GetOffset<T>(ref T)""
2153-
IL_0011: ldloca.s V_2
2154-
IL_0013: ldc.i4.4
2155-
IL_0014: ldc.i4.1
2156-
IL_0015: ldloc.0
2157-
IL_0016: ldobj ""T""
2158-
IL_001b: box ""T""
2159-
IL_0020: call ""DummyHandler..ctor(int, int, IMoveable)""
2160-
IL_0025: ldloca.s V_2
2161-
IL_0027: ldstr ""log:""
2162-
IL_002c: call ""void DummyHandler.AppendLiteral(string)""
2163-
IL_0031: ldloca.s V_2
2164-
IL_0033: ldc.i4.0
2165-
IL_0034: call ""void DummyHandler.AppendFormatted<int>(int)""
2166-
IL_0039: ldloc.2
2167-
IL_003a: constrained. ""T""
2168-
IL_0040: callvirt ""void IMoveable.GetName(int, DummyHandler)""
2169-
IL_0045: ret
2146+
IL_0006: stloc.0
2147+
IL_0007: ldloc.0
2148+
IL_0008: box ""T""
2149+
IL_000d: ldarg.0
2150+
IL_000e: call ""int Program.GetOffset<T>(ref T)""
2151+
IL_0013: ldloca.s V_1
2152+
IL_0015: ldc.i4.4
2153+
IL_0016: ldc.i4.1
2154+
IL_0017: ldloc.0
2155+
IL_0018: box ""T""
2156+
IL_001d: call ""DummyHandler..ctor(int, int, IMoveable)""
2157+
IL_0022: ldloca.s V_1
2158+
IL_0024: ldstr ""log:""
2159+
IL_0029: call ""void DummyHandler.AppendLiteral(string)""
2160+
IL_002e: ldloca.s V_1
2161+
IL_0030: ldc.i4.0
2162+
IL_0031: call ""void DummyHandler.AppendFormatted<int>(int)""
2163+
IL_0036: ldloc.1
2164+
IL_0037: callvirt ""void IMoveable.GetName(int, DummyHandler)""
2165+
IL_003c: ret
21702166
}
21712167
");
21722168

0 commit comments

Comments
 (0)