Description
In #3073, we coalesced a lot of logic around "Should this method be marked because it's needed by a (non-interface) base method" into one method, and enumerated the state that influences if a method is marked (i.e. the method's type is marked, the method's type is instantiated, etc.) so that we can make sure the method is called whenever the relevant state changes. We should expand the scope of that method so that we can call a single method any time the relevant state for the method changes. This will hopefully help us reason about what's going on and help debugging, but also will enable us to use the DependencyAnalysisFramework once we know everything that influences if a method should be marked.
My initial thought is that the highest level function (ex. ShouldMethodBeMarked()) would take a method and all the state information that influences whether a method is marked, with default null values. Then the caller provides only the state information that has changed and ShouldMethodBeMarked will only call the other methods representing reasons why a method would be marked (i.e. ShouldBeMarkedForBaseMethod, ShouldBeMarkedForInterfaceMethod, ShouldBeMarkedDueToX) if they depend on the state provided by the caller. For example:
public ShouldMethodBeMarked(
MethodDefinition method,
bool? declaringTypeIsMarkedInstatiated = null,
bool? declaringTypeIsMarkedRelevantToVariantCasting = null,
InterfaceImplementation? newlyMarkedInterfaceImplementationOnDeclaringType = null,
MethodDefinition? newlyMarkedBaseType = null
...)
{
if (newlyMarkedBaseType is not null) {
if (ShouldMarkOverrideDueToBaseType(method, newlyMarkedBaseType) {
MarkMethod (method, reason);
}
}
...
}
Tasks:
- Move marking methods needed by interfaces into IsMethodNeededByBaseMethod.