Skip to content

Commit 6bfd88c

Browse files
committed
Misc.
1 parent 8cff50f commit 6bfd88c

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,22 +3318,27 @@ class Program
33183318
static void Main()
33193319
{
33203320
int i = 1;
3321-
ReadAndDiscard(ref i);
3321+
ReadAndDiscard1(ref i);
33223322
ReadAndDiscardNoArg<int>();
3323+
ReadAndDiscard2(new S<int>(ref i));
33233324
}
3324-
static void ReadAndDiscard<T>(ref T t)
3325+
static void ReadAndDiscard1<T>(ref T t)
33253326
{
33263327
_ = new S<T>(ref t).F;
33273328
}
33283329
static void ReadAndDiscardNoArg<T>()
33293330
{
33303331
_ = new S<T>().F;
33313332
}
3333+
static void ReadAndDiscard2<T>(in S<T> s)
3334+
{
3335+
_ = s.F;
3336+
}
33323337
}";
33333338
// PROTOTYPE: The dereference of `new S<T>(...).F` should not be elided
33343339
// since the behavior may be observable as a NullReferenceException.
33353340
var verifier = CompileAndVerify(source, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput(""));
3336-
verifier.VerifyIL("Program.ReadAndDiscard<T>",
3341+
verifier.VerifyIL("Program.ReadAndDiscard1<T>",
33373342
@"{
33383343
// Code size 8 (0x8)
33393344
.maxstack 1
@@ -3347,6 +3352,12 @@ .maxstack 1
33473352
// Code size 1 (0x1)
33483353
.maxstack 0
33493354
IL_0000: ret
3355+
}");
3356+
verifier.VerifyIL("Program.ReadAndDiscard2<T>",
3357+
@"{
3358+
// Code size 1 (0x1)
3359+
.maxstack 0
3360+
IL_0000: ret
33503361
}");
33513362
}
33523363

src/Compilers/Test/Core/CompilationVerifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public void VerifyILMultiple(params string[] qualifiedMethodNamesAndExpectedIL)
443443
var names = ArrayBuilder<string>.GetInstance();
444444
var expected = ArrayBuilder<string>.GetInstance();
445445
var actual = ArrayBuilder<string>.GetInstance();
446-
for (int i = 0; i < qualifiedMethodNamesAndExpectedIL.Length; )
446+
for (int i = 0; i < qualifiedMethodNamesAndExpectedIL.Length;)
447447
{
448448
var qualifiedName = qualifiedMethodNamesAndExpectedIL[i++];
449449
names.Add(qualifiedName);

0 commit comments

Comments
 (0)