File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -414,19 +414,22 @@ void ConstantEvaluator::endVisit(MemberAccess const& _memberAccess)
414
414
{
415
415
if (auto const * parentIdentifier = dynamic_cast <Identifier const *>(&_memberAccess.expression ()))
416
416
{
417
- if (auto const * contract = dynamic_cast <ContractDefinition const *>(parentIdentifier->annotation ().referencedDeclaration ))
417
+ Declaration const * referencedDeclaration = parentIdentifier->annotation ().referencedDeclaration ;
418
+ std::vector<VariableDeclaration const *> candidateVariables;
419
+ if (auto const * contract = dynamic_cast <ContractDefinition const *>(referencedDeclaration))
420
+ candidateVariables = contract->stateVariables ();
421
+ else if (auto const * import = dynamic_cast <ImportDirective const *>(referencedDeclaration))
418
422
{
419
- auto contractVariables = contract->stateVariables ();
420
- auto variable = ranges::find_if (
421
- contractVariables,
422
- [&](VariableDeclaration const * _variable) { return _variable->name () == _memberAccess.memberName (); }
423
- );
424
-
425
- if (
426
- variable != ranges::end (contractVariables) &&
427
- (*variable)->isConstant ()
428
- )
429
- m_values[&_memberAccess] = evaluate (**variable);
423
+ if (SourceUnit const * sourceUnit = import ->annotation ().sourceUnit )
424
+ candidateVariables = ASTNode::filteredNodes<VariableDeclaration>(sourceUnit->nodes ());
430
425
}
426
+
427
+ auto variable = ranges::find_if (
428
+ candidateVariables,
429
+ [&](VariableDeclaration const * _variable) { return _variable->name () == _memberAccess.memberName (); }
430
+ );
431
+
432
+ if (variable != ranges::end (candidateVariables) && (*variable)->isConstant ())
433
+ m_values[&_memberAccess] = evaluate (**variable);
431
434
}
432
435
}
You can’t perform that action at this time.
0 commit comments