Browse Source

Add structs to inheritable members

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
f2fdeb3599
  1. 7
      libsolidity/AST.cpp
  2. 2
      libsolidity/Types.cpp
  3. 4
      test/SolidityNameAndTypeResolution.cpp

7
libsolidity/AST.cpp

@ -231,6 +231,13 @@ vector<ASTPointer<Declaration>> const& ContractDefinition::getInheritableMembers
memberSeen.insert(v->getName());
m_inheritableMembers->push_back(v);
}
for (ASTPointer<StructDefinition> const& s: contract->getDefinedStructs())
if (s->isPublic() && memberSeen.count(s->getName()) == 0)
{
memberSeen.insert(s->getName());
m_inheritableMembers->push_back(s);
}
}
}
return *m_inheritableMembers;

2
libsolidity/Types.cpp

@ -1024,7 +1024,7 @@ MemberList const& TypeType::getMembers() const
vector<ContractDefinition const*> currentBases = m_currentContract->getLinearizedBaseContracts();
if (find(currentBases.begin(), currentBases.end(), &contract) != currentBases.end())
// We are accessing the type of a base contract, so add all public and protected
// functions. Note that this does not add inherited functions on purpose.
// members. Note that this does not add inherited functions on purpose.
for (ASTPointer<Declaration> const& decl: contract.getInheritableMembers())
members.push_back(make_pair(decl->getName(), decl->getType()));
}

4
test/SolidityNameAndTypeResolution.cpp

@ -726,8 +726,8 @@ BOOST_AUTO_TEST_CASE(base_class_state_variable_accessor)
char const* text = "contract Parent {\n"
" uint256 public m_aMember;\n"
"}\n"
"contract Child {\n"
" function foo() returns (uint256) { return Parent.m_aMember(); }\n"
"contract Child is Parent{\n"
" function foo() returns (uint256) { return Parent.m_aMember; }\n"
"}\n";
BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text));
}

Loading…
Cancel
Save