Mark expressions that are called directly in the annotations

This commit is contained in:
Mathias Baumann
2020-11-30 18:52:50 +01:00
parent f9f9f6251d
commit c3da529a18
2 changed files with 18 additions and 1 deletions
+9 -1
View File
@@ -2303,11 +2303,19 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
functionType = dynamic_cast<FunctionType const*>(expressionType);
funcCallAnno.kind = FunctionCallKind::FunctionCall;
if (auto memberAccess = dynamic_cast<MemberAccess const*>(&_functionCall.expression()))
{
if (dynamic_cast<FunctionDefinition const*>(memberAccess->annotation().referencedDeclaration))
_functionCall.expression().annotation().calledDirectly = true;
}
else if (auto identifier = dynamic_cast<Identifier const*>(&_functionCall.expression()))
if (dynamic_cast<FunctionDefinition const*>(identifier->annotation().referencedDeclaration))
_functionCall.expression().annotation().calledDirectly = true;
// Purity for function calls also depends upon the callee and its FunctionType
funcCallAnno.isPure =
argumentsArePure &&
*_functionCall.expression().annotation().isPure &&
functionType &&
functionType->isPure();
if (