Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public bool InterproceduralAnalyze()
return succeeded;
}

// Delegate types with default parameter values produce operation blocks whose
// OwningSymbol is the delegate INamedTypeSymbol. These blocks contain only
// simple constant initializers with no interesting dataflow, so skip them.
if (Context.OwningSymbol is INamedTypeSymbol { TypeKind: TypeKind.Delegate })
return succeeded;

Debug.Assert(Context.OwningSymbol is not IMethodSymbol methodSymbol ||
methodSymbol.MethodKind is not (MethodKind.LambdaMethod or MethodKind.LocalFunction));
var startMethod = new MethodBodyValue(Context.OwningSymbol, Context.GetControlFlowGraph(OperationBlock));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,11 @@ class DelegateCreation

static event Action<Type> Event;

// Delegate with a default parameter value.
// The default parameter generates an operation block whose OwningSymbol
// is the delegate type (INamedTypeSymbol), not a method.
delegate void DelegateWithDefaultParameter(Type type = null);

static void TestField()
{
var d = new UnannotatedDelegate(field);
Expand Down
Loading