From 3c1f656e6f85bf90f5edb4c66af8139f2c5b0bca Mon Sep 17 00:00:00 2001 From: Neal Gafter Date: Mon, 18 Mar 2019 18:09:55 -0700 Subject: [PATCH] Unskip a test Fixes #31881 --- .../NullableReferenceTypesVsPatterns.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs index 61af125865a83..322e899ec1776 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs @@ -1207,5 +1207,41 @@ void M8(object o, bool b) // _ = o switch // 3 not exhaustive Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithLocation(63, 15)); } + + [Fact, WorkItem(31881, "https://github.com/dotnet/roslyn/issues/31881")] + public void NullableVsPattern_31881() + { + var source = @" +using System; +#nullable enable + +public class C +{ + public object? AProperty { get; set; } + public void M(C? input, int i) + { + if (input?.AProperty is string str) + { + Console.WriteLine(str.ToString()); + + switch (i) + { + case 1: + Console.WriteLine(input?.AProperty.ToString()); + break; + case 2: + Console.WriteLine(input.AProperty.ToString()); + break; + case 3: + Console.WriteLine(input.ToString()); + break; + } + } + } +} +"; + var comp = CreateCompilation(source); + comp.VerifyDiagnostics(); + } } }