diff options
author | chriseth <chris@ethereum.org> | 2018-11-30 01:32:06 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-11-30 23:30:19 +0800 |
commit | 6d1644e55c03850341e6bfcc4ae46f8de264a039 (patch) | |
tree | ba5f90d16bd45555d25f3e5e56a78d80bb3f09a1 /libsolidity/analysis/ContractLevelChecker.cpp | |
parent | 4f4f623273052de6ede71bae2696f2388f1aa713 (diff) | |
download | dexon-solidity-6d1644e55c03850341e6bfcc4ae46f8de264a039.tar dexon-solidity-6d1644e55c03850341e6bfcc4ae46f8de264a039.tar.gz dexon-solidity-6d1644e55c03850341e6bfcc4ae46f8de264a039.tar.bz2 dexon-solidity-6d1644e55c03850341e6bfcc4ae46f8de264a039.tar.lz dexon-solidity-6d1644e55c03850341e6bfcc4ae46f8de264a039.tar.xz dexon-solidity-6d1644e55c03850341e6bfcc4ae46f8de264a039.tar.zst dexon-solidity-6d1644e55c03850341e6bfcc4ae46f8de264a039.zip |
Move external type clash check.
Diffstat (limited to 'libsolidity/analysis/ContractLevelChecker.cpp')
-rw-r--r-- | libsolidity/analysis/ContractLevelChecker.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index dd08e181..e2208f3f 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -42,6 +42,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract) checkBaseConstructorArguments(_contract); checkConstructor(_contract); checkFallbackFunction(_contract); + checkExternalTypeClashes(_contract); return Error::containsOnlyWarnings(m_errorReporter.errors()); } @@ -383,3 +384,39 @@ void ContractLevelChecker::checkFallbackFunction(ContractDefinition const& _cont if (fallback->visibility() != FunctionDefinition::Visibility::External) m_errorReporter.typeError(fallback->location(), "Fallback function must be defined as \"external\"."); } + +void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _contract) +{ + map<string, vector<pair<Declaration const*, FunctionTypePointer>>> externalDeclarations; + for (ContractDefinition const* contract: _contract.annotation().linearizedBaseContracts) + { + for (FunctionDefinition const* f: contract->definedFunctions()) + if (f->isPartOfExternalInterface()) + { + auto functionType = make_shared<FunctionType>(*f); + // under non error circumstances this should be true + if (functionType->interfaceFunctionType()) + externalDeclarations[functionType->externalSignature()].push_back( + make_pair(f, functionType->asCallableFunction(false)) + ); + } + for (VariableDeclaration const* v: contract->stateVariables()) + if (v->isPartOfExternalInterface()) + { + auto functionType = make_shared<FunctionType>(*v); + // under non error circumstances this should be true + if (functionType->interfaceFunctionType()) + externalDeclarations[functionType->externalSignature()].push_back( + make_pair(v, functionType->asCallableFunction(false)) + ); + } + } + for (auto const& it: externalDeclarations) + for (size_t i = 0; i < it.second.size(); ++i) + for (size_t j = i + 1; j < it.second.size(); ++j) + if (!it.second[i].second->hasEqualParameterTypes(*it.second[j].second)) + m_errorReporter.typeError( + it.second[j].first->location(), + "Function overload clash during conversion to external types for arguments." + ); +} |