Do not flag abstract functions in classes inside of interfaces
This commit is contained in:
parent
0b28dfa652
commit
6569468502
|
@ -32,9 +32,18 @@ class FunctionAttributeCheck : BaseAnalyzer
|
||||||
|
|
||||||
override void visit(const InterfaceDeclaration dec)
|
override void visit(const InterfaceDeclaration dec)
|
||||||
{
|
{
|
||||||
inInterface++;
|
auto t = inInterface;
|
||||||
|
inInterface = true;
|
||||||
dec.accept(this);
|
dec.accept(this);
|
||||||
inInterface--;
|
inInterface = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
override void visit(const ClassDeclaration dec)
|
||||||
|
{
|
||||||
|
auto t = inInterface;
|
||||||
|
inInterface = false;
|
||||||
|
dec.accept(this);
|
||||||
|
inInterface = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const AttributeDeclaration dec)
|
override void visit(const AttributeDeclaration dec)
|
||||||
|
@ -55,7 +64,7 @@ class FunctionAttributeCheck : BaseAnalyzer
|
||||||
{
|
{
|
||||||
if (attr.storageClass is null)
|
if (attr.storageClass is null)
|
||||||
continue;
|
continue;
|
||||||
if (attr.storageClass.token == tok!"abstract" && inInterface > 0)
|
if (attr.storageClass.token == tok!"abstract" && inInterface)
|
||||||
{
|
{
|
||||||
addErrorMessage(attr.storageClass.token.line,
|
addErrorMessage(attr.storageClass.token.line,
|
||||||
attr.storageClass.token.column, KEY, ABSTRACT_MESSAGE);
|
attr.storageClass.token.column, KEY, ABSTRACT_MESSAGE);
|
||||||
|
@ -78,7 +87,7 @@ class FunctionAttributeCheck : BaseAnalyzer
|
||||||
dec.accept(this);
|
dec.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int inInterface;
|
bool inInterface;
|
||||||
|
|
||||||
private enum ABSTRACT_MESSAGE = "'abstract' attribute is redundant in interface declarations";
|
private enum ABSTRACT_MESSAGE = "'abstract' attribute is redundant in interface declarations";
|
||||||
private enum KEY = "dscanner.confusing.function_attributes";
|
private enum KEY = "dscanner.confusing.function_attributes";
|
||||||
|
|
Loading…
Reference in New Issue