未验证 提交 14b76e25 编写于 作者: D dotnet-automerge-bot 提交者: GitHub

Merge pull request #34034 from dotnet/merges/master-to-master-vs-deps

Merge master to master-vs-deps
......@@ -5667,6 +5667,14 @@ protected override void VisitCatchBlock(BoundCatchBlock node, ref LocalState fin
base.VisitCatchBlock(node, ref finallyState);
}
public override BoundNode VisitLockStatement(BoundLockStatement node)
{
VisitRvalue(node.Argument);
CheckPossibleNullReceiver(node.Argument);
VisitStatement(node.Body);
return null;
}
protected override string Dump(LocalState state)
{
if (!state.Reachable)
......
......@@ -243,6 +243,46 @@ static void M<T>(int i, Missing m, string s, T t)
);
}
[Fact, WorkItem(26810, "https://github.com/dotnet/roslyn/issues/26810")]
public void LockStatement()
{
var comp = CreateCompilation(@"
class C
{
void F(object? maybeNull, object nonNull, Missing? annotatedMissing, Missing unannotatedMissing)
{
lock (maybeNull) { }
lock (nonNull) { }
lock (annotatedMissing) { }
lock (unannotatedMissing) { }
}
#nullable disable
void F(object oblivious, Missing obliviousMissing)
#nullable enable
{
lock (oblivious) { }
lock (obliviousMissing) { }
}
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (4,47): error CS0246: The type or namespace name 'Missing' could not be found (are you missing a using directive or an assembly reference?)
// void F(object? maybeNull, object nonNull, Missing? annotatedMissing, Missing unannotatedMissing)
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "Missing").WithArguments("Missing").WithLocation(4, 47),
// (4,74): error CS0246: The type or namespace name 'Missing' could not be found (are you missing a using directive or an assembly reference?)
// void F(object? maybeNull, object nonNull, Missing? annotatedMissing, Missing unannotatedMissing)
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "Missing").WithArguments("Missing").WithLocation(4, 74),
// (6,15): warning CS8602: Possible dereference of a null reference.
// lock (maybeNull) { }
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "maybeNull").WithLocation(6, 15),
// (8,15): error CS0185: 'Missing?' is not a reference type as required by the lock statement
// lock (annotatedMissing) { }
Diagnostic(ErrorCode.ERR_LockNeedsReference, "annotatedMissing").WithArguments("Missing?").WithLocation(8, 15),
// (12,30): error CS0246: The type or namespace name 'Missing' could not be found (are you missing a using directive or an assembly reference?)
// void F(object oblivious, Missing obliviousMissing)
Diagnostic(ErrorCode.ERR_SingleTypeNameNotFound, "Missing").WithArguments("Missing").WithLocation(12, 30)
);
}
[Fact, WorkItem(33537, "https://github.com/dotnet/roslyn/issues/33537")]
public void SuppressOnNullLiteralInAs()
{
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册