未验证 提交 946a943d 编写于 作者: A Andrew Hall 提交者: GitHub

Add new ConversionKind to IsImplicitConversion test (#35095)

上级 55dac49f
......@@ -21,6 +21,7 @@ public static bool IsImplicitConversion(this ConversionKind conversionKind)
switch (conversionKind)
{
case ConversionKind.NoConversion:
case ConversionKind.UnsetConversionKind:
return false;
case ConversionKind.Identity:
......
......@@ -5916,5 +5916,36 @@ public void GetSpecialType_ThrowsOnGreaterThanCount()
Assert.True(exceptionThrown, $"{nameof(comp.GetSpecialType)} did not throw when it should have.");
}
[Fact]
[WorkItem(34984, "https://github.com/dotnet/roslyn/issues/34984")]
public void ConversionIsExplicit_UnsetConversionKind()
{
var source =
@"class C1
{
}
class C2
{
public void M()
{
var c = new C1();
foreach (string item in c.Items)
{
}
}";
var comp = CreateCompilation(source);
var tree = comp.SyntaxTrees.Single();
var model = comp.GetSemanticModel(tree);
var root = tree.GetRoot();
var foreachSyntaxNode = root.DescendantNodes().OfType<ForEachStatementSyntax>().Single();
var foreachSymbolInfo = model.GetForEachStatementInfo(foreachSyntaxNode);
Assert.Equal(Conversion.UnsetConversion, foreachSymbolInfo.CurrentConversion);
Assert.True(foreachSymbolInfo.CurrentConversion.Exists);
Assert.False(foreachSymbolInfo.CurrentConversion.IsImplicit);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册