aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorFederico Bond <federicobond@gmail.com>2017-07-09 09:42:42 +0800
committerFederico Bond <federicobond@gmail.com>2017-07-13 10:57:53 +0800
commitf20b150f3830d7a014258d92a26aba6a2bbdc8cb (patch)
tree1da74ae9b2a8c7b34f9be6ede23dc8980ec116a3 /libsolidity/ast
parent757c500bda9a32cccc86e1ab24da31a99c0e6eac (diff)
downloaddexon-solidity-f20b150f3830d7a014258d92a26aba6a2bbdc8cb.tar
dexon-solidity-f20b150f3830d7a014258d92a26aba6a2bbdc8cb.tar.gz
dexon-solidity-f20b150f3830d7a014258d92a26aba6a2bbdc8cb.tar.bz2
dexon-solidity-f20b150f3830d7a014258d92a26aba6a2bbdc8cb.tar.lz
dexon-solidity-f20b150f3830d7a014258d92a26aba6a2bbdc8cb.tar.xz
dexon-solidity-f20b150f3830d7a014258d92a26aba6a2bbdc8cb.tar.zst
dexon-solidity-f20b150f3830d7a014258d92a26aba6a2bbdc8cb.zip
Add type error when attempting value transfer to a non-payable contract
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp6
-rw-r--r--libsolidity/ast/Types.h4
2 files changed, 10 insertions, 0 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 6ecf509d..b54407c6 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -1230,6 +1230,12 @@ bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const
_convertTo.category() == Category::Contract;
}
+bool ContractType::isPayable() const
+{
+ auto fallbackFunction = m_contract.fallbackFunction();
+ return fallbackFunction && fallbackFunction->isPayable();
+}
+
TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const
{
return _operator == Token::Delete ? make_shared<TupleType>() : TypePointer();
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 66eb039f..bd5da30a 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -675,6 +675,10 @@ public:
}
bool isSuper() const { return m_super; }
+
+ // @returns true if and only if the contract has a payable fallback function
+ bool isPayable() const;
+
ContractDefinition const& contractDefinition() const { return m_contract; }
/// Returns the function type of the constructor modified to return an object of the contract's type.