mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix direct call to base class overloaded functions
This commit is contained in:
parent
00d81929b1
commit
371b37b660
@ -32,6 +32,7 @@ Bugfixes:
|
|||||||
* SMTChecker: SSA control-flow did not take into account state variables that were modified inside inlined functions that were called inside branches.
|
* SMTChecker: SSA control-flow did not take into account state variables that were modified inside inlined functions that were called inside branches.
|
||||||
* Type System: Use correct type name for contracts in event parameters when used in
|
* Type System: Use correct type name for contracts in event parameters when used in
|
||||||
libraries. This affected code generation.
|
libraries. This affected code generation.
|
||||||
|
* Type System: Allow direct call to base class functions that have overloads.
|
||||||
* Yul: Properly register functions and disallow shadowing between function variables and variables in the outside scope.
|
* Yul: Properly register functions and disallow shadowing between function variables and variables in the outside scope.
|
||||||
* Code Generator: Fix initialization routine of uninitialized internal function pointers in constructor context.
|
* Code Generator: Fix initialization routine of uninitialized internal function pointers in constructor context.
|
||||||
|
|
||||||
|
@ -215,16 +215,12 @@ vector<Declaration const*> const& ContractDefinition::inheritableMembers() const
|
|||||||
{
|
{
|
||||||
if (!m_inheritableMembers)
|
if (!m_inheritableMembers)
|
||||||
{
|
{
|
||||||
set<string> memberSeen;
|
|
||||||
m_inheritableMembers.reset(new vector<Declaration const*>());
|
m_inheritableMembers.reset(new vector<Declaration const*>());
|
||||||
auto addInheritableMember = [&](Declaration const* _decl)
|
auto addInheritableMember = [&](Declaration const* _decl)
|
||||||
{
|
{
|
||||||
solAssert(_decl, "addInheritableMember got a nullpointer.");
|
solAssert(_decl, "addInheritableMember got a nullpointer.");
|
||||||
if (memberSeen.count(_decl->name()) == 0 && _decl->isVisibleInDerivedContracts())
|
if (_decl->isVisibleInDerivedContracts())
|
||||||
{
|
|
||||||
memberSeen.insert(_decl->name());
|
|
||||||
m_inheritableMembers->push_back(_decl);
|
m_inheritableMembers->push_back(_decl);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (FunctionDefinition const* f: definedFunctions())
|
for (FunctionDefinition const* f: definedFunctions())
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
contract BaseBase {
|
||||||
|
uint public x;
|
||||||
|
uint public y;
|
||||||
|
function init(uint a, uint b) public {
|
||||||
|
x = b;
|
||||||
|
y = a;
|
||||||
|
}
|
||||||
|
function init(uint a) public {
|
||||||
|
x = a + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Base is BaseBase {
|
||||||
|
function init(uint a, uint b) public {
|
||||||
|
x = a;
|
||||||
|
y = b;
|
||||||
|
}
|
||||||
|
function init(uint a) public {
|
||||||
|
x = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Child is Base {
|
||||||
|
function cInit(uint c) public {
|
||||||
|
Base.init(c);
|
||||||
|
}
|
||||||
|
function cInit(uint c, uint d) public {
|
||||||
|
Base.init(c, d);
|
||||||
|
}
|
||||||
|
function bInit(uint c) public {
|
||||||
|
BaseBase.init(c);
|
||||||
|
}
|
||||||
|
function bInit(uint c, uint d) public {
|
||||||
|
BaseBase.init(c, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// x() -> 0
|
||||||
|
// y() -> 0
|
||||||
|
// cInit(uint256): 2 ->
|
||||||
|
// x() -> 2
|
||||||
|
// y() -> 0
|
||||||
|
// cInit(uint256,uint256): 3, 3 ->
|
||||||
|
// x() -> 3
|
||||||
|
// y() -> 3
|
||||||
|
// bInit(uint256): 4 ->
|
||||||
|
// x() -> 5
|
||||||
|
// bInit(uint256,uint256): 9, 10 ->
|
||||||
|
// x() -> 10
|
||||||
|
// y() -> 9
|
@ -0,0 +1,29 @@
|
|||||||
|
contract Base {
|
||||||
|
uint public x;
|
||||||
|
uint public y;
|
||||||
|
function init(uint a, uint b) public {
|
||||||
|
x = a;
|
||||||
|
y = b;
|
||||||
|
}
|
||||||
|
function init(uint a) public {
|
||||||
|
x = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract Child is Base {
|
||||||
|
function cInit(uint c) public {
|
||||||
|
Base.init(c);
|
||||||
|
}
|
||||||
|
function cInit(uint c, uint d) public {
|
||||||
|
Base.init(c, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// x() -> 0
|
||||||
|
// y() -> 0
|
||||||
|
// cInit(uint256): 2 ->
|
||||||
|
// x() -> 2
|
||||||
|
// y() -> 0
|
||||||
|
// cInit(uint256,uint256): 3, 3 ->
|
||||||
|
// x() -> 3
|
||||||
|
// y() -> 3
|
Loading…
Reference in New Issue
Block a user