summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs54
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj17
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs
new file mode 100644
index 0000000000..be0f46b226
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs
@@ -0,0 +1,54 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.CompilerServices;
+
+public class GitHub_24657
+{
+ struct Wrapper<T>
+ {
+ public T Val { get; set; }
+
+ public static implicit operator Wrapper<T>(T val) => new Wrapper<T> { Val = val };
+ }
+
+ struct TestStruct
+ {
+ public Wrapper<int> Field1;
+ public Wrapper<short> Field2;
+ public Wrapper<short> Field3;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public TestStruct(int field1)
+ {
+ this.Field1 = field1;
+ this.Field2 = 0;
+ this.Field3 = 0;
+ }
+ }
+
+ public static int Main(string[] args)
+ {
+ int returnVal = 100;
+ var array = new [] { new TestStruct(123), new TestStruct(456) };
+ if (array[1].Field1.Val != 456)
+ {
+ Console.WriteLine("Failed to set value correctly.");
+ returnVal = -1;
+ }
+
+ array[0].Field3 = 100;
+
+ if (array[1].Field1.Val != 456)
+ {
+ Console.WriteLine("Value is corrupted.");
+ returnVal = -1;
+ }
+
+ System.Console.WriteLine(returnVal == 100 ? "Pass" : "Fail");
+ return returnVal;
+ }
+}
+
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj
new file mode 100644
index 0000000000..c24f74b865
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <OutputType>Exe</OutputType>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>