mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move if-condition to function for re-use
This commit is contained in:
parent
5434ba025e
commit
f4c40080c4
@ -33,6 +33,18 @@ using namespace dev;
|
|||||||
using namespace langutil;
|
using namespace langutil;
|
||||||
using namespace dev::solidity;
|
using namespace dev::solidity;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool hasEqualNameAndParameters(T const& _a, T const& _b)
|
||||||
|
{
|
||||||
|
return _a.name() == _b.name() &&
|
||||||
|
FunctionType(_a).asCallableFunction(false)->hasEqualParameterTypes(
|
||||||
|
*FunctionType(_b).asCallableFunction(false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool ContractLevelChecker::check(ContractDefinition const& _contract)
|
bool ContractLevelChecker::check(ContractDefinition const& _contract)
|
||||||
{
|
{
|
||||||
@ -111,9 +123,7 @@ void ContractLevelChecker::findDuplicateDefinitions(map<string, vector<T>> const
|
|||||||
SecondarySourceLocation ssl;
|
SecondarySourceLocation ssl;
|
||||||
|
|
||||||
for (size_t j = i + 1; j < overloads.size(); ++j)
|
for (size_t j = i + 1; j < overloads.size(); ++j)
|
||||||
if (FunctionType(*overloads[i]).asCallableFunction(false)->hasEqualParameterTypes(
|
if (hasEqualNameAndParameters(*overloads[i], *overloads[j]))
|
||||||
*FunctionType(*overloads[j]).asCallableFunction(false))
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ssl.append("Other declaration is here:", overloads[j]->location());
|
ssl.append("Other declaration is here:", overloads[j]->location());
|
||||||
reported.insert(j);
|
reported.insert(j);
|
||||||
|
Loading…
Reference in New Issue
Block a user