aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-03-01 01:30:33 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-03-02 18:51:13 +0800
commitbbaa9fef6c8272c567af49ecea4f68c59c335778 (patch)
tree35c0a09ec87b456a69359906a7866233b108993b /AST.cpp
parentefe8f9f8a054a7a7489db44e236e5424becf9db7 (diff)
downloaddexon-solidity-bbaa9fef6c8272c567af49ecea4f68c59c335778.tar.gz
dexon-solidity-bbaa9fef6c8272c567af49ecea4f68c59c335778.tar.zst
dexon-solidity-bbaa9fef6c8272c567af49ecea4f68c59c335778.zip
getInheritableMembers() does not look at BaseContracts
- Also adding tests for improper accessing members of other contracts.
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/AST.cpp b/AST.cpp
index 24a94a79..e5aef4cb 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -215,26 +215,23 @@ vector<ASTPointer<Declaration>> const& ContractDefinition::getInheritableMembers
{
set<string> memberSeen;
m_inheritableMembers.reset(new vector<ASTPointer<Declaration>>());
- for (ContractDefinition const* contract: getLinearizedBaseContracts())
+ auto addInheritableMember = [&](ASTPointer<Declaration> const& _decl)
{
- auto addInheritableMember = [&](ASTPointer<Declaration> const& _decl)
+ if (memberSeen.count(_decl->getName()) == 0 && _decl->isVisibleInDerivedContracts())
{
- if (memberSeen.count(_decl->getName()) == 0 && _decl->isVisibleInDerivedContracts())
- {
- memberSeen.insert(_decl->getName());
- m_inheritableMembers->push_back(_decl);
- }
- };
+ memberSeen.insert(_decl->getName());
+ m_inheritableMembers->push_back(_decl);
+ }
+ };
- for (ASTPointer<FunctionDefinition> const& f: contract->getDefinedFunctions())
- addInheritableMember(f);
+ for (ASTPointer<FunctionDefinition> const& f: getDefinedFunctions())
+ addInheritableMember(f);
- for (ASTPointer<VariableDeclaration> const& v: contract->getStateVariables())
- addInheritableMember(v);
+ for (ASTPointer<VariableDeclaration> const& v: getStateVariables())
+ addInheritableMember(v);
- for (ASTPointer<StructDefinition> const& s: contract->getDefinedStructs())
- addInheritableMember(s);
- }
+ for (ASTPointer<StructDefinition> const& s: getDefinedStructs())
+ addInheritableMember(s);
}
return *m_inheritableMembers;
}