mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make asCallableFunction to never fail and assert abount parameter size if bound instead.
This commit is contained in:
parent
9e964852cc
commit
92ba8a95f6
@ -442,10 +442,11 @@ MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition
|
|||||||
if (!function->isVisibleAsLibraryMember() || seenFunctions.count(function))
|
if (!function->isVisibleAsLibraryMember() || seenFunctions.count(function))
|
||||||
continue;
|
continue;
|
||||||
seenFunctions.insert(function);
|
seenFunctions.insert(function);
|
||||||
FunctionType funType(*function, false);
|
if (function->parameters().empty())
|
||||||
if (auto fun = funType.asCallableFunction(true, true))
|
continue;
|
||||||
if (_type.isImplicitlyConvertibleTo(*fun->selfType()))
|
FunctionTypePointer fun = FunctionType(*function, false).asCallableFunction(true, true);
|
||||||
members.push_back(MemberList::Member(function->name(), fun, function));
|
if (_type.isImplicitlyConvertibleTo(*fun->selfType()))
|
||||||
|
members.push_back(MemberList::Member(function->name(), fun, function));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
@ -3061,8 +3062,8 @@ TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) con
|
|||||||
|
|
||||||
FunctionTypePointer FunctionType::asCallableFunction(bool _inLibrary, bool _bound) const
|
FunctionTypePointer FunctionType::asCallableFunction(bool _inLibrary, bool _bound) const
|
||||||
{
|
{
|
||||||
if (_bound && m_parameterTypes.empty())
|
if (_bound)
|
||||||
return FunctionTypePointer();
|
solAssert(!m_parameterTypes.empty(), "");
|
||||||
|
|
||||||
TypePointers parameterTypes;
|
TypePointers parameterTypes;
|
||||||
for (auto const& t: m_parameterTypes)
|
for (auto const& t: m_parameterTypes)
|
||||||
|
@ -1158,9 +1158,8 @@ public:
|
|||||||
/// from CallData to Memory. This is the type that would be used when the function is
|
/// from CallData to Memory. This is the type that would be used when the function is
|
||||||
/// called, as opposed to the parameter types that are available inside the function body.
|
/// called, as opposed to the parameter types that are available inside the function body.
|
||||||
/// Also supports variants to be used for library or bound calls.
|
/// Also supports variants to be used for library or bound calls.
|
||||||
/// Returns empty shared pointer on a failure. Namely, if a bound function has no parameters.
|
|
||||||
/// @param _inLibrary if true, uses DelegateCall as location.
|
/// @param _inLibrary if true, uses DelegateCall as location.
|
||||||
/// @param _bound if true, the arguments are placed as `arg1.functionName(arg2, ..., argn)`.
|
/// @param _bound if true, the function type is set to be bound.
|
||||||
FunctionTypePointer asCallableFunction(bool _inLibrary, bool _bound = false) const;
|
FunctionTypePointer asCallableFunction(bool _inLibrary, bool _bound = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user