mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix dependency tracking for abstract contracts
This commit is contained in:
parent
a384e14bcc
commit
e991465336
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
* SMTChecker: Fix lack of reporting potential violations when using only the CHC engine.
|
* SMTChecker: Fix lack of reporting potential violations when using only the CHC engine.
|
||||||
|
* Code generator: Fix missing creation dependency tracking for abstract contracts.
|
||||||
|
|
||||||
|
|
||||||
### 0.7.4 (2020-10-19)
|
### 0.7.4 (2020-10-19)
|
||||||
|
@ -1160,11 +1160,15 @@ void CompilerStack::compileContract(
|
|||||||
if (m_hasError)
|
if (m_hasError)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Called compile with errors."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Called compile with errors."));
|
||||||
|
|
||||||
if (_otherCompilers.count(&_contract) || !_contract.canBeDeployed())
|
if (_otherCompilers.count(&_contract))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto const* dependency: _contract.annotation().contractDependencies)
|
for (auto const* dependency: _contract.annotation().contractDependencies)
|
||||||
compileContract(*dependency, _otherCompilers);
|
compileContract(*dependency, _otherCompilers);
|
||||||
|
|
||||||
|
if (!_contract.canBeDeployed())
|
||||||
|
return;
|
||||||
|
|
||||||
Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
|
Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
|
||||||
|
|
||||||
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_revertStrings, m_optimiserSettings);
|
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_revertStrings, m_optimiserSettings);
|
||||||
|
@ -1505,6 +1505,46 @@ BOOST_AUTO_TEST_CASE(stopAfter_ast_output)
|
|||||||
BOOST_CHECK(result["sources"]["a.sol"]["ast"].isObject());
|
BOOST_CHECK(result["sources"]["a.sol"]["ast"].isObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(dependency_tracking_of_abstract_contract)
|
||||||
|
{
|
||||||
|
char const* input = R"(
|
||||||
|
{
|
||||||
|
"language": "Solidity",
|
||||||
|
"sources": {
|
||||||
|
"BlockRewardAuRaBase.sol": {
|
||||||
|
"content": " contract Sacrifice { constructor() payable {} } abstract contract BlockRewardAuRaBase { function _transferNativeReward() internal { new Sacrifice(); } function _distributeTokenRewards() internal virtual; } "
|
||||||
|
},
|
||||||
|
"BlockRewardAuRaCoins.sol": {
|
||||||
|
"content": " import \"./BlockRewardAuRaBase.sol\"; contract BlockRewardAuRaCoins is BlockRewardAuRaBase { function transferReward() public { _transferNativeReward(); } function _distributeTokenRewards() internal override {} } "
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"outputSelection": {
|
||||||
|
"BlockRewardAuRaCoins.sol": {
|
||||||
|
"BlockRewardAuRaCoins": ["evm.bytecode.sourceMap"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
Json::Value parsedInput;
|
||||||
|
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
|
||||||
|
|
||||||
|
solidity::frontend::StandardCompiler compiler;
|
||||||
|
Json::Value result = compiler.compile(parsedInput);
|
||||||
|
|
||||||
|
BOOST_REQUIRE(result["contracts"].isObject());
|
||||||
|
BOOST_REQUIRE(result["contracts"].size() == 1);
|
||||||
|
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"].isObject());
|
||||||
|
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"].size() == 1);
|
||||||
|
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"].isObject());
|
||||||
|
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"].isObject());
|
||||||
|
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"]["bytecode"].isObject());
|
||||||
|
BOOST_REQUIRE(result["sources"].isObject());
|
||||||
|
BOOST_REQUIRE(result["sources"].size() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
} // end namespaces
|
} // end namespaces
|
||||||
|
Loading…
Reference in New Issue
Block a user