diff --git a/src/EditorFeatures/Test2/Simplification/CastSimplificationTests.vb b/src/EditorFeatures/Test2/Simplification/CastSimplificationTests.vb index aee5cc23cb5f9bd74b11802f67725f5d4dd541d0..a581d78c0d0c6fc40d4c7d5a750a41cdfede155d 100644 --- a/src/EditorFeatures/Test2/Simplification/CastSimplificationTests.vb +++ b/src/EditorFeatures/Test2/Simplification/CastSimplificationTests.vb @@ -4819,6 +4819,46 @@ class C } } ]]> + + + Await TestAsync(input, expected) + End Function + + + + Public Async Function TestCSharp_DontRemove_NecessaryCastToNullInImplicitlyTypedArray() As Task + Dim input = + + + + + + + + Dim expected = + Await TestAsync(input, expected) diff --git a/src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs b/src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs index a4a54fded53b9f63503597d664777bcfcd2b43a1..4cb398bbc7de68ee330d060817611db9e1ad8906 100644 --- a/src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs +++ b/src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs @@ -426,6 +426,10 @@ protected override bool ReplacementChangesSemanticsForNodeLanguageSpecific(Synta { return ReplacementBreaksInterpolation((InterpolationSyntax)currentOriginalNode, (InterpolationSyntax)currentReplacedNode); } + else if (currentOriginalNode.Kind() == SyntaxKind.ImplicitArrayCreationExpression) + { + return !TypesAreCompatible((ImplicitArrayCreationExpressionSyntax)currentOriginalNode, (ImplicitArrayCreationExpressionSyntax)currentReplacedNode); + } return false; }