diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_ListPatterns.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_ListPatterns.cs index 438621cf156c..9724df2d6cd3 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_ListPatterns.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_ListPatterns.cs @@ -5626,6 +5626,36 @@ public void Subsumption_Slice_03() ); } + [Fact] + public void Subsumption_Slice_04() + { + var source = @" +#nullable enable +class C +{ + public int Length => 3; + public int this[int i] => 0; + public int[]? Slice(int i, int j) => null; + + public static void Main() + { + switch (new C()) + { + case [.. {}]: + break; + case [.. null]: + break; + } + } +} +"; + var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe); + compilation.VerifyEmitDiagnostics( + // (15,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match. + // case [.. null]: + Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[.. null]").WithLocation(15, 18)); + } + [Fact] public void Exhaustiveness_01() {