Skip to content

Move all "Should method be marked in the current analysis state" logic to one place #3090

Open
@jtschuster

Description

@jtschuster

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions