File tree Expand file tree Collapse file tree
CSharp/Test/Semantic/Semantics Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments