mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
VisibleInDerivedContracts() is now virtual()
- Plus an extra test for internal visibility in a base class variable
This commit is contained in:
parent
47177542f5
commit
7db2b6fbdb
7
AST.cpp
7
AST.cpp
@ -218,22 +218,21 @@ vector<ASTPointer<Declaration>> const& ContractDefinition::getInheritableMembers
|
||||
for (ContractDefinition const* contract: getLinearizedBaseContracts())
|
||||
{
|
||||
for (ASTPointer<FunctionDefinition> const& f: contract->getDefinedFunctions())
|
||||
if (f->isPublic() && !f->isConstructor() && !f->getName().empty()
|
||||
&& memberSeen.count(f->getName()) == 0 && f->isVisibleInDerivedContracts())
|
||||
if (memberSeen.count(f->getName()) == 0 && f->isVisibleInDerivedContracts())
|
||||
{
|
||||
memberSeen.insert(f->getName());
|
||||
m_inheritableMembers->push_back(f);
|
||||
}
|
||||
|
||||
for (ASTPointer<VariableDeclaration> const& v: contract->getStateVariables())
|
||||
if (v->isPublic() && memberSeen.count(v->getName()) == 0)
|
||||
if (memberSeen.count(v->getName()) == 0 && v->isVisibleInDerivedContracts())
|
||||
{
|
||||
memberSeen.insert(v->getName());
|
||||
m_inheritableMembers->push_back(v);
|
||||
}
|
||||
|
||||
for (ASTPointer<StructDefinition> const& s: contract->getDefinedStructs())
|
||||
if (s->isPublic() && memberSeen.count(s->getName()) == 0)
|
||||
if (memberSeen.count(s->getName()) == 0 && s->isVisibleInDerivedContracts())
|
||||
{
|
||||
memberSeen.insert(s->getName());
|
||||
m_inheritableMembers->push_back(s);
|
||||
|
7
AST.h
7
AST.h
@ -144,7 +144,7 @@ public:
|
||||
Visibility getVisibility() const { return m_visibility == Visibility::Default ? getDefaultVisibility() : m_visibility; }
|
||||
bool isPublic() const { return getVisibility() >= Visibility::Public; }
|
||||
bool isVisibleInContract() const { return getVisibility() != Visibility::External; }
|
||||
bool isVisibleInDerivedContracts() const { return isVisibleInContract() && getVisibility() >= Visibility::Internal; }
|
||||
virtual bool isVisibleInDerivedContracts() const { return isVisibleInContract() && getVisibility() >= Visibility::Internal; }
|
||||
|
||||
/// @returns the scope this declaration resides in. Can be nullptr if it is the global scope.
|
||||
/// Available only after name and type resolution step.
|
||||
@ -409,6 +409,11 @@ public:
|
||||
ASTPointer<ParameterList> const& getReturnParameterList() const { return m_returnParameters; }
|
||||
Block const& getBody() const { return *m_body; }
|
||||
|
||||
virtual bool isVisibleInDerivedContracts() const override
|
||||
{
|
||||
return !isConstructor() && !getName().empty() && isVisibleInContract() &&
|
||||
getVisibility() >= Visibility::Internal;
|
||||
}
|
||||
virtual TypePointer getType(ContractDefinition const*) const override;
|
||||
|
||||
/// Checks that all parameters have allowed types and calls checkTypeRequirements on the body.
|
||||
|
@ -628,8 +628,7 @@ MemberList const& ContractType::getMembers() const
|
||||
{
|
||||
for (ContractDefinition const* base: m_contract.getLinearizedBaseContracts())
|
||||
for (ASTPointer<FunctionDefinition> const& function: base->getDefinedFunctions())
|
||||
if (!function->isConstructor() && !function->getName().empty()&&
|
||||
function->isVisibleInDerivedContracts())
|
||||
if (function->isVisibleInDerivedContracts())
|
||||
members.push_back(make_pair(function->getName(), make_shared<FunctionType>(*function, true)));
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user