Skip to content

Commit 9c8b804

Browse files
jkotasMichalStrehovsky
andauthoredJan 21, 2022
ILVerify: Handle readonly references in ldfld (#64077)
* ILVerify: Handle readonly references in ldfld Fixes #63953 * Fix test name Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
1 parent 0240828 commit 9c8b804

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎src/coreclr/tools/ILVerification/ILImporter.Verify.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2060,7 +2060,7 @@ void ImportLoadField(int token, bool isStatic)
20602060
actualThis = StackValue.CreateByRef(actualThis.Type);
20612061

20622062
var declaredThis = owningType.IsValueType ?
2063-
StackValue.CreateByRef(owningType) : StackValue.CreateObjRef(owningType);
2063+
StackValue.CreateByRef(owningType, readOnly : true) : StackValue.CreateObjRef(owningType);
20642064

20652065
CheckIsAssignable(actualThis, declaredThis);
20662066

‎src/tests/ilverify/ILTests/ValueTypeTests.il

+13
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,16 @@
2626
}
2727
}
2828

29+
.class public sequential ansi sealed beforefieldinit ValueTypeFieldTests
30+
extends [System.Runtime]System.ValueType
31+
{
32+
.field public int32 InstanceField
33+
34+
.method public static int32 ValueType.UnboxLdfld_Valid(object o) cil managed
35+
{
36+
ldarg.0
37+
unbox ValueTypeFieldTests
38+
ldfld int32 ValueTypeFieldTests::InstanceField
39+
ret
40+
}
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.