mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1240 from ethereum/1151
ast: super contract type does not contain native members
This commit is contained in:
commit
cb1fcaf6f6
@ -12,6 +12,7 @@ Bugfixes:
|
||||
* Optimizer: fix related to stale knowledge about SHA3 operations
|
||||
* Disallow unknown options in ``solc``.
|
||||
* Proper type checking for bound functions.
|
||||
* Type Checker: ``super.x`` does not look up ``x`` in the current contract.
|
||||
* Code Generator: expect zero stack increase after `super` as an expression.
|
||||
* Allow inheritance of ``enum`` definitions.
|
||||
* Inline assembly: support the ``address`` opcode.
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <libsolidity/ast/Types.h>
|
||||
#include <limits>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include <boost/range/adaptor/sliced.hpp>
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <libdevcore/CommonData.h>
|
||||
#include <libdevcore/SHA3.h>
|
||||
@ -1324,7 +1325,10 @@ MemberList::MemberMap ContractType::nativeMembers(ContractDefinition const*) con
|
||||
if (m_super)
|
||||
{
|
||||
// add the most derived of all functions which are visible in derived contracts
|
||||
for (ContractDefinition const* base: m_contract.annotation().linearizedBaseContracts)
|
||||
auto bases = m_contract.annotation().linearizedBaseContracts;
|
||||
solAssert(bases.size() >= 1, "linearizedBaseContracts should at least contain the most derived contract.");
|
||||
// `sliced(1, ...)` ignores the most derived contract, which should not be searchable from `super`.
|
||||
for (ContractDefinition const* base: bases | boost::adaptors::sliced(1, bases.size()))
|
||||
for (FunctionDefinition const* function: base->definedFunctions())
|
||||
{
|
||||
if (!function->isVisibleInDerivedContracts())
|
||||
|
@ -854,6 +854,23 @@ BOOST_AUTO_TEST_CASE(implicit_base_to_derived_conversion)
|
||||
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(super_excludes_current_contract)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract A {
|
||||
function b() {}
|
||||
}
|
||||
|
||||
contract B is A {
|
||||
function f() {
|
||||
super.f();
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_modifier_invocation)
|
||||
{
|
||||
char const* text = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user