Skip to content

Commit dc09eb1

Browse files
committed
fix private and protected
1 parent 7f78b11 commit dc09eb1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

EmmyLua/CodeAnalysis/Diagnostics/Checkers/VisibilityChecker.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public override void Check(DiagnosticContext context)
5555
var envElement = FindSourceOrClosure(indexExpr);
5656
if (declaration.IsPrivate)
5757
{
58-
if (envElement is LuaSourceSyntax || envElement.Parent is not LuaFuncStatSyntax luaFuncStat)
58+
if (envElement is LuaSourceSyntax)
5959
{
6060
context.Report(
6161
DiagnosticCode.AccessPrivateMember,
@@ -65,9 +65,8 @@ public override void Check(DiagnosticContext context)
6565

6666
continue;
6767
}
68-
6968
var parentType = context.SearchContext.Compilation.Db.QueryParentType(declaration.UniqueId);
70-
var parentTable = context.SearchContext.Infer(luaFuncStat.IndexExpr?.PrefixExpr);
69+
var parentTable = context.SearchContext.Infer(prefixExpr);
7170
if (!parentTable.Equals(parentType))
7271
{
7372
context.Report(
@@ -79,7 +78,7 @@ public override void Check(DiagnosticContext context)
7978
}
8079
else if (declaration.IsProtected)
8180
{
82-
if (envElement is LuaSourceSyntax || envElement.Parent is not LuaFuncStatSyntax luaFuncStat)
81+
if (envElement is LuaSourceSyntax)
8382
{
8483
context.Report(
8584
DiagnosticCode.AccessProtectedMember,
@@ -91,7 +90,7 @@ public override void Check(DiagnosticContext context)
9190
}
9291

9392
var parentType = context.SearchContext.Compilation.Db.QueryParentType(declaration.UniqueId);
94-
var parentTable = context.SearchContext.Infer(luaFuncStat.IndexExpr?.PrefixExpr);
93+
var parentTable = context.SearchContext.Infer(prefixExpr);
9594
if (!parentTable.SubTypeOf(parentType, context.SearchContext))
9695
{
9796
context.Report(

0 commit comments

Comments
 (0)