未验证 提交 4e88ffa6 编写于 作者: R Rikki Gibson 提交者: GitHub

Fix LookupStaticMembers(int) in incomplete code (#41560)

上级 d3e3d07b
......@@ -2257,7 +2257,8 @@ internal override Symbol RemapSymbolIfNecessaryCore(Symbol symbol)
return symbol;
}
var memberModel = GetMemberModel(symbol.Locations[0].SourceSpan.Start);
var position = CheckAndAdjustPosition(symbol.Locations[0].SourceSpan.Start);
var memberModel = GetMemberModel(position);
return memberModel?.RemapSymbolIfNecessaryCore(symbol) ?? symbol;
}
}
......
......@@ -5178,6 +5178,35 @@ static void M()
Assert.Contains(symbols, s => s.Name == "Local");
}
[Fact]
public void TestLookupStaticMembers_PositionNeedsAdjustment()
{
var source = @"
#nullable enable
class Program
{
static void Main(string[] args)
{
void local1() { }
b
local1();
}
}
";
var comp = CreateCompilation(source);
var tree = comp.SyntaxTrees.Single();
var model = comp.GetSemanticModel(tree);
var node = tree.GetRoot().DescendantNodes().Single(node => node is IdentifierNameSyntax { Identifier: { ValueText: "b" } });
var symbols = model.LookupStaticMembers(node.SpanStart);
Assert.Contains(symbols, s => s.Name == "local1");
}
[Fact]
public void InvalidParameterWithDefaultValue_Method()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册