MCPcopy Create free account
hub / github.com/argotorg/solidity / checkExternalTypeClashes

Method checkExternalTypeClashes

libsolidity/analysis/ContractLevelChecker.cpp:466–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464}
465
466void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _contract)
467{
468 std::map<std::string, std::vector<std::pair<Declaration const*, FunctionTypePointer>>> externalDeclarations;
469 for (ContractDefinition const* contract: _contract.annotation().linearizedBaseContracts)
470 {
471 for (FunctionDefinition const* f: contract->definedFunctions())
472 if (f->isPartOfExternalInterface())
473 {
474 auto functionType = TypeProvider::function(*f);
475 // under non error circumstances this should be true
476 if (functionType->interfaceFunctionType())
477 externalDeclarations[functionType->externalSignature()].emplace_back(
478 f, functionType->asExternallyCallableFunction(false)
479 );
480 }
481 for (VariableDeclaration const* v: contract->stateVariables())
482 if (v->isPartOfExternalInterface())
483 {
484 auto functionType = TypeProvider::function(*v);
485 // under non error circumstances this should be true
486 if (functionType->interfaceFunctionType())
487 externalDeclarations[functionType->externalSignature()].emplace_back(
488 v, functionType->asExternallyCallableFunction(false)
489 );
490 }
491 }
492 for (auto const& it: externalDeclarations)
493 for (size_t i = 0; i < it.second.size(); ++i)
494 for (size_t j = i + 1; j < it.second.size(); ++j)
495 if (!it.second[i].second->hasEqualParameterTypes(*it.second[j].second))
496 m_errorReporter.typeError(
497 9914_error,
498 it.second[j].first->location(),
499 "Function overload clash during conversion to external types for arguments."
500 );
501}
502
503void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contract)
504{

Callers

nothing calls this directly

Calls 11

functionFunction · 0.85
definedFunctionsMethod · 0.80
interfaceFunctionTypeMethod · 0.80
typeErrorMethod · 0.80
externalSignatureMethod · 0.45
stateVariablesMethod · 0.45
sizeMethod · 0.45
locationMethod · 0.45

Tested by

no test coverage detected