Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8648,15 +8648,11 @@ bool CEEInfo::resolveVirtualMethodHelper(CORINFO_DEVIRTUALIZATION_INFO * info)
{
_ASSERTE(pObjMT->IsArray());

// We cannot devirtualize unless we know the exact array element type
//
TypeHandle elemType = pObjMT->GetArrayElementTypeHandle();
if (elemType.IsCanonicalSubtype())
{
info->detail = CORINFO_DEVIRTUALIZATION_FAILED_LOOKUP;
return false;
}
pDevirtMD = GetActualImplementationForArrayGenericIListOrIReadOnlyListMethod(pBaseMD, elemType);
// The instantiation we want is based on the interface element type, not the
// array element type.
TypeHandle resultElemType = pBaseMT->GetInstantiation()[0];
_ASSERTE(!resultElemType.IsCanonicalSubtype());
pDevirtMD = GetActualImplementationForArrayGenericIListOrIReadOnlyListMethod(pBaseMD, resultElemType);
}
else if (pObjMT->IsSharedByGenericInstantiations() || pBaseMT->IsSharedByGenericInstantiations())
{
Expand Down
36 changes: 36 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_120270/Runtime_120270.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Linq;
using Xunit;

public class Runtime_120270
{
[Fact]
public static int TestEntryPoint()
{
int i = 0;
bool failed = false;
try
{
while (i < 100_000)
{
i++;
var values = new[] { DayOfWeek.Saturday }.Cast<int>();
foreach (var value in values)
{
}
}
}
catch (Exception ex)
{
Console.WriteLine(i);
Console.WriteLine(ex);
failed = true;
}

return failed ? -1 : 100;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading