提交 3845057c 编写于 作者: N nmgafter

Add test for semantic model in base clauses in error scenarios (changeset 1384579)

上级 ade83e7b
......@@ -1878,5 +1878,28 @@ public class C { }
Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using static A<int>.B;").WithLocation(1, 1)
);
}
[Fact]
public void BindBases()
{
// Ensure good semantic model data even in error scenarios
var text =
@"
class B {
public B(long x) {}
}
class D : B {
extern D(int x) : base(y) {}
static int y;
}";
var comp = CreateCompilationWithMscorlib45(text);
var tree = comp.SyntaxTrees[0];
var model = comp.GetSemanticModel(tree);
var baseY = tree.GetRoot().DescendantNodes().Where(n => n.ToString() == "y").OfType<ExpressionSyntax>().First();
var typeInfo = model.GetTypeInfo(baseY);
Assert.Equal(SpecialType.System_Int32, typeInfo.Type.SpecialType);
Assert.Equal(SpecialType.System_Int64, typeInfo.ConvertedType.SpecialType);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册