mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add payable and non-payable state mutability to AddressType.
This commit is contained in:
@@ -242,8 +242,14 @@ string ABIFunctions::cleanupFunction(Type const& _type, bool _revertOnFailure)
|
||||
break;
|
||||
}
|
||||
case Type::Category::Contract:
|
||||
templ("body", "cleaned := " + cleanupFunction(AddressType()) + "(value)");
|
||||
{
|
||||
AddressType addressType(dynamic_cast<ContractType const&>(_type).isPayable() ?
|
||||
StateMutability::Payable :
|
||||
StateMutability::NonPayable
|
||||
);
|
||||
templ("body", "cleaned := " + cleanupFunction(addressType) + "(value)");
|
||||
break;
|
||||
}
|
||||
case Type::Category::Enum:
|
||||
{
|
||||
size_t members = dynamic_cast<EnumType const&>(_type).numberOfMembers();
|
||||
|
||||
@@ -1259,7 +1259,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
|
||||
identifier = FunctionType(*function).externalIdentifier();
|
||||
else
|
||||
solAssert(false, "Contract member is neither variable nor function.");
|
||||
utils().convertType(type, AddressType(), true);
|
||||
utils().convertType(type, AddressType(type.isPayable() ? StateMutability::Payable : StateMutability::NonPayable), true);
|
||||
m_context << identifier;
|
||||
}
|
||||
else
|
||||
@@ -1277,15 +1277,24 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
|
||||
{
|
||||
utils().convertType(
|
||||
*_memberAccess.expression().annotation().type,
|
||||
AddressType(),
|
||||
AddressType(StateMutability::NonPayable),
|
||||
true
|
||||
);
|
||||
m_context << Instruction::BALANCE;
|
||||
}
|
||||
else if ((set<string>{"send", "transfer", "call", "callcode", "delegatecall", "staticcall"}).count(member))
|
||||
else if ((set<string>{"send", "transfer"}).count(member))
|
||||
{
|
||||
solAssert(dynamic_cast<AddressType const&>(*_memberAccess.expression().annotation().type).stateMutability() == StateMutability::Payable, "");
|
||||
utils().convertType(
|
||||
*_memberAccess.expression().annotation().type,
|
||||
AddressType(),
|
||||
AddressType(StateMutability::Payable),
|
||||
true
|
||||
);
|
||||
}
|
||||
else if ((set<string>{"call", "callcode", "delegatecall", "staticcall"}).count(member))
|
||||
utils().convertType(
|
||||
*_memberAccess.expression().annotation().type,
|
||||
AddressType(StateMutability::NonPayable),
|
||||
true
|
||||
);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user