Skip to content

Commit c790896

Browse files
Fix a small bug in message origin for warnings from static field access on generic type (#3186)
The warning needs to be generated from the origin where the field reference comes from - so if it's a method body, then from the method body. This is because the instantiation is determined by that place, not the field itself (the field is defined on an open generic definition of the type). This syncs the relevants tests with a NativeAOT work-in-progress change, but in generately it adds a lot more cases and some better comments. Co-authored-by: Tlakaelel Axayakatl Ceja <tlakaelel.ceja@microsoft.com>
1 parent 4452038 commit c790896

File tree

2 files changed

+320
-22
lines changed

2 files changed

+320
-22
lines changed

src/linker/Linker.Steps/MarkStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ protected void MarkField (FieldReference reference, DependencyInfo reason, in Me
16101610
Debug.Assert (reason.Kind == DependencyKind.FieldAccess || reason.Kind == DependencyKind.Ldtoken);
16111611
// Blame the field reference (without actually marking) on the original reason.
16121612
Tracer.AddDirectDependency (reference, reason, marked: false);
1613-
MarkType (reference.DeclaringType, new DependencyInfo (DependencyKind.DeclaringType, reference), new MessageOrigin (Context.TryResolve (reference)));
1613+
MarkType (reference.DeclaringType, new DependencyInfo (DependencyKind.DeclaringType, reference));
16141614

16151615
// Blame the field definition that we will resolve on the field reference.
16161616
reason = new DependencyInfo (DependencyKind.FieldOnGenericInstance, reference);

0 commit comments

Comments
 (0)