diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp index ba5ca1345..c67cd7279 100644 --- a/NameAndTypeResolver.cpp +++ b/NameAndTypeResolver.cpp @@ -111,7 +111,7 @@ void NameAndTypeResolver::linearizeBaseContracts(ContractDefinition& _contract) { // order in the lists is from derived to base // list of lists to linearize, the last element is the list of direct bases - list> input(1, {&_contract}); + list> input(1, {}); for (ASTPointer const& baseSpecifier: _contract.getBaseContracts()) { ASTPointer baseName = baseSpecifier->getName(); @@ -119,14 +119,15 @@ void NameAndTypeResolver::linearizeBaseContracts(ContractDefinition& _contract) baseName->getReferencedDeclaration()); if (!base) BOOST_THROW_EXCEPTION(baseName->createTypeError("Contract expected.")); - // "push_back" has the effect that bases mentioned earlier can overwrite members of bases - // mentioned later - input.back().push_back(base); + // "push_front" has the effect that bases mentioned later can overwrite members of bases + // mentioned earlier + input.back().push_front(base); vector const& basesBases = base->getLinearizedBaseContracts(); if (basesBases.empty()) BOOST_THROW_EXCEPTION(baseName->createTypeError("Definition of base has to precede definition of derived contract")); input.push_front(list(basesBases.begin(), basesBases.end())); } + input.back().push_front(&_contract); vector result = cThreeMerge(input); if (result.empty()) BOOST_THROW_EXCEPTION(_contract.createTypeError("Linearization of inheritance graph impossible"));