File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
src/tests/Loader/classloader/generics/ByRefLike Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 237
237
ret
238
238
}
239
239
240
+ .method public hidebysig
241
+ instance bool BoxIsinstUnboxAny_Mismatch(!T) cil managed
242
+ {
243
+ ldarg.1
244
+ // Begin sequence
245
+ box !T
246
+ isinst ByRefLikeType2
247
+ unbox.any ByRefLikeType2
248
+ // End sequence
249
+ pop
250
+ ldc.i4.0
251
+ ret
252
+ }
253
+
240
254
.method public hidebysig
241
255
instance bool BoxIsinstBranch(!T) cil managed
242
256
{
443
457
)
444
458
}
445
459
460
+ .class public sequential ansi sealed beforefieldinit ByRefLikeType2
461
+ extends [System.Runtime]System.ValueType
462
+ {
463
+ .custom instance void [System.Runtime]System.Runtime.CompilerServices.IsByRefLikeAttribute::.ctor() = (
464
+ 01 00 00 00
465
+ )
466
+ }
467
+
446
468
.class interface public auto ansi abstract InvalidCSharp.EmptyInterface
447
469
{
448
470
}
755
777
ret
756
778
}
757
779
780
+ .method public hidebysig static
781
+ bool BoxIsinstUnboxAny_Mismatch() cil managed
782
+ {
783
+ .locals init (
784
+ [0] valuetype InvalidCSharp.GenericByRefLike_Over`1<valuetype ByRefLikeType>
785
+ )
786
+
787
+ ldloca.s 0
788
+ initobj valuetype InvalidCSharp.GenericByRefLike_Over`1<valuetype ByRefLikeType>
789
+ ldloca.s 0
790
+ ldloc 0
791
+ ldfld !0 valuetype InvalidCSharp.GenericByRefLike_Over`1<valuetype ByRefLikeType>::Field
792
+ call instance bool valuetype InvalidCSharp.GenericByRefLike_Over`1<valuetype ByRefLikeType>::BoxIsinstUnboxAny_Mismatch(!0)
793
+ ret
794
+ }
795
+
758
796
.method public hidebysig static
759
797
bool BoxIsinstBranch() cil managed
760
798
{
Original file line number Diff line number Diff line change @@ -67,6 +67,16 @@ public static void Validate_RecognizedOpCodeSequences_Scenarios()
67
67
Assert . True ( Exec . BoxIsinstBranch ( ) ) ;
68
68
}
69
69
70
+ [ Fact ]
71
+ public static void Validate_RecognizedOpCodeSequences_Mismatch ( )
72
+ {
73
+ Console . WriteLine ( $ "{ nameof ( Validate_RecognizedOpCodeSequences_Mismatch ) } ...") ;
74
+
75
+ // box !T ; isinst S ; unbox.any S should always be guarded by a box !T ; isinst S;
76
+ // brtrue/brfalse branch, so if it's ever executed and the types aren't equal that's invalid
77
+ Assert . Throws < InvalidProgramException > ( ( ) => { Exec . BoxIsinstUnboxAny_Mismatch ( ) ; } ) ;
78
+ }
79
+
70
80
[ Fact ]
71
81
public static void Validate_InvalidOpCode_Scenarios ( )
72
82
{
@@ -81,6 +91,7 @@ public static void Validate_InvalidOpCode_Scenarios()
81
91
82
92
// Test that explicitly tries to box a ByRefLike type.
83
93
Assert . Throws < InvalidProgramException > ( ( ) => { Exec . BoxAsObject ( ) ; } ) ;
94
+
84
95
}
85
96
86
97
[ Fact ]
@@ -116,4 +127,4 @@ public static void Validate_MemberDiscoveryViaReflection_ForSpanReadOnlySpan()
116
127
// Assert.NotNull(m);
117
128
// }
118
129
}
119
- }
130
+ }
You can’t perform that action at this time.
0 commit comments