Add userDefinedFunctionType helper function

This commit is contained in:
wechman
2022-09-28 13:09:30 +02:00
parent 577a5bb7a4
commit 5cf88593fd
5 changed files with 44 additions and 33 deletions
@@ -685,9 +685,7 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
"Only file-level functions and library functions can be bound to a user type operator."
);
FunctionType const* functionType = dynamic_cast<FunctionType const*>(
function->libraryFunction() ? function->typeViaContractName() : function->type()
);
FunctionType const* functionType = _unaryOperation.userDefinedFunctionType();
solAssert(functionType);
functionType = dynamic_cast<FunctionType const&>(*functionType).asBoundFunction();
solAssert(functionType);
@@ -832,9 +830,7 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
"Only file-level functions and library functions can be bound to a user type operator."
);
FunctionType const* functionType = dynamic_cast<FunctionType const*>(
function->libraryFunction() ? function->typeViaContractName() : function->type()
);
FunctionType const* functionType = _binOp.userDefinedFunctionType();
solAssert(functionType);
functionType = dynamic_cast<FunctionType const&>(*functionType).asBoundFunction();
solAssert(functionType);