@@ -1354,31 +1354,14 @@ bool ASTBoogieExpressionConverter::visit(MemberAccess const& _node)
13541354 return false ;
13551355 }
13561356
1357- // Enums
1358- if (_node.annotation ().type ->category () == Type::Category::Enum)
1357+ // Reaching for enum, e.g. Enum.A
1358+ if (type-> category () == Type::Category::TypeType && _node.annotation ().type ->category () == Type::Category::Enum)
13591359 {
1360- // Try to get the enum definition
1361- EnumDefinition const * enumDef = nullptr ;
1362- if (auto exprId = dynamic_cast <Identifier const *>(&_node.expression ()))
1363- enumDef = dynamic_cast <EnumDefinition const *>(exprId->annotation ().referencedDeclaration );
1364- if (auto exprMemAcc = dynamic_cast <MemberAccess const *>(&_node.expression ()))
1365- enumDef = dynamic_cast <EnumDefinition const *>(exprMemAcc->annotation ().referencedDeclaration );
1366-
1367- if (enumDef)
1368- {
1369- // TODO: better way to get index?
1370- for (size_t i = 0 ; i < enumDef->members ().size (); ++i)
1371- {
1372- if (enumDef->members ()[i]->name () == _node.memberName ())
1373- {
1374- m_currentExpr = m_context.intLit (i, 256 );
1375- return false ;
1376- }
1377- }
1378- solAssert (false , " Enum member not found" );
1379- }
1380- else
1381- solAssert (false , " Enum definition not found" );
1360+ // If it's a member of the enum, just return the value
1361+ EnumType const * enumType = dynamic_cast <EnumType const *>(_node.annotation ().type );
1362+ unsigned i = enumType->memberValue (_node.memberName ());
1363+ m_currentExpr = m_context.intLit (i, 256 );
1364+ return false ;
13821365 }
13831366
13841367 // Non-special member access: 'referencedDeclaration' should point to the
0 commit comments