File tree Expand file tree Collapse file tree
tests/JIT/Regression/JitBlue/Runtime_120270 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8613,18 +8613,18 @@ bool CEEInfo::resolveVirtualMethodHelper(CORINFO_DEVIRTUALIZATION_INFO * info)
86138613
86148614 if (pObjMT->IsArray ())
86158615 {
8616+ if (pBaseMT->IsSharedByGenericInstantiations ())
8617+ {
8618+ info->detail = CORINFO_DEVIRTUALIZATION_FAILED_CANON;
8619+ return false ;
8620+ }
8621+
86168622 // Does the array implicitly implement this interface?
86178623 //
86188624 isArrayImplicitInterface = pBaseMT->HasInstantiation () && IsImplicitInterfaceOfSZArray (pBaseMT);
86198625
86208626 if (!isArrayImplicitInterface)
86218627 {
8622- if (pBaseMT->IsSharedByGenericInstantiations ())
8623- {
8624- info->detail = CORINFO_DEVIRTUALIZATION_FAILED_CANON;
8625- return false ;
8626- }
8627-
86288628 // Ensure we can cast the array to the interface type
86298629 //
86308630 if (!TypeHandle (pObjMT).CanCastTo (TypeHandle (pBaseMT)))
@@ -8653,6 +8653,7 @@ bool CEEInfo::resolveVirtualMethodHelper(CORINFO_DEVIRTUALIZATION_INFO * info)
86538653 // The instantiation we want is based on the interface element type, not the
86548654 // array element type.
86558655 TypeHandle resultElemType = pBaseMT->GetInstantiation ()[0 ];
8656+ // We should have ruled this out above.
86568657 _ASSERTE (!resultElemType.IsCanonicalSubtype ());
86578658 pDevirtMD = GetActualImplementationForArrayGenericIListOrIReadOnlyListMethod (pBaseMD, resultElemType);
86588659 }
Original file line number Diff line number Diff line change 33
44using System ;
55using System . Linq ;
6+ using System . Runtime . CompilerServices ;
67using Xunit ;
78
9+ class Base { }
10+ class Derived : Base { }
11+
812public class Runtime_120270
913{
1014 [ Fact ]
@@ -32,5 +36,35 @@ public static int TestEntryPoint()
3236
3337 return failed ? - 1 : 100 ;
3438 }
39+
40+ [ Fact ]
41+ public static int TestEntryPoint2 ( )
42+ {
43+ bool failed = false ;
44+ try
45+ {
46+ Foo < Base > ( [ new Derived ( ) ] ) ;
47+ }
48+ catch ( Exception ex )
49+ {
50+ Console . WriteLine ( ex ) ;
51+ failed = true ;
52+ }
53+ return failed ? - 1 : 100 ;
54+ }
55+
56+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
57+ static void Foo < T > ( object [ ] x )
58+ {
59+ int i = 0 ;
60+ while ( i < 100_000 )
61+ {
62+ i ++ ;
63+ var values = x . Cast < T > ( ) ;
64+ foreach ( var value in values )
65+ {
66+ }
67+ }
68+ }
3569}
3670
You can’t perform that action at this time.
0 commit comments