Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List patterns: Slice value is assumed to be never null #57457

Merged
merged 19 commits into from
Jan 20, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,12 @@ private static void MakeCheckNotNull(
ArrayBuilder<Tests> tests)
{
// Add a null test if needed
if (input.Type.CanContainNull())
if (input.Type.CanContainNull() &&
// The slice value is assumed to be never null
input.Source is not BoundDagSliceEvaluation)
alrz marked this conversation as resolved.
Show resolved Hide resolved
{
tests.Add(new Tests.One(new BoundDagNonNullTest(syntax, isExplicitTest, input)));
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,12 @@ protected static void AssertEmpty(SymbolInfo info)
Assert.Equal(CandidateReason.None, info.CandidateReason);
}

protected static void VerifyDecisionDagDump<T>(Compilation comp, string expectedDecisionDag)
protected static void VerifyDecisionDagDump<T>(Compilation comp, string expectedDecisionDag, int index = 0)
where T : CSharpSyntaxNode
{
#if DEBUG
var tree = comp.SyntaxTrees.First();
var node = tree.GetRoot().DescendantNodes().OfType<T>().First();
var node = tree.GetRoot().DescendantNodes().OfType<T>().ElementAt(index);
var model = (CSharpSemanticModel)comp.GetSemanticModel(tree);
var binder = model.GetEnclosingBinder(node.SpanStart);
var decisionDag = node switch
Expand Down
Loading