Skip to content

Commit 1708426

Browse files
committed
Use same approach as IMethodSymbol
1 parent f4df385 commit 1708426

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Core/Compiling/CompilerUtils.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public static string FindCode(this MemberAccessExpressionSyntax syntax, IDocumen
9898
Compilation compilation = context.Compilation;
9999
SemanticModel semanticModel = compilation.GetSemanticModel(syntax.SyntaxTree);
100100
var symbolInfo = semanticModel.GetSymbolInfo(syntax);
101-
if (symbolInfo.Symbol is not IFieldSymbol fieldSymbol)
101+
var symbol = symbolInfo.Symbol ?? symbolInfo.CandidateSymbols.SingleOrDefault(s => s is IFieldSymbol);
102+
103+
if (symbol is not IFieldSymbol fieldSymbol)
102104
{
103105
context.Report(Diagnostic.Create(
104106
CompilationErrors.InvalidConstantReference,

0 commit comments

Comments
 (0)