提交 1f240e9f 编写于 作者: D Dustin Campbell

Fix C# cast simplification issue where removal of a cast can break an implicitly-typed array

上级 39160123
......@@ -4819,6 +4819,46 @@ class C
}
}
]]>
</code>
Await TestAsync(input, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Simplification)>
<WorkItem(6966, "https://github.com/dotnet/roslyn/issues/6966")>
Public Async Function TestCSharp_DontRemove_NecessaryCastToNullInImplicitlyTypedArray() As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document><![CDATA[
class C
{
object M()
{
return new
{
Something = new[] { {|Simplify:(object)null|}, null, null, null }
};
}
}
]]>
</Document>
</Project>
</Workspace>
Dim expected =
<code><![CDATA[
class C
{
object M()
{
return new
{
Something = new[] { (object)null, null, null, null }
};
}
}
]]>
</code>
Await TestAsync(input, expected)
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册