aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-11-28 05:24:00 +0800
committerchriseth <c@ethdev.com>2015-11-29 07:16:07 +0800
commitf9e52c9db1ef23000f5721a462aba3fa8d681749 (patch)
treed1b77769961618d027c794131949efe021fa4b49 /libsolidity/analysis
parent93b3237c6ae526d3ff5aa0d23d48319cf705baee (diff)
downloaddexon-solidity-f9e52c9db1ef23000f5721a462aba3fa8d681749.tar.gz
dexon-solidity-f9e52c9db1ef23000f5721a462aba3fa8d681749.tar.zst
dexon-solidity-f9e52c9db1ef23000f5721a462aba3fa8d681749.zip
Also check the object type for bound functions.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 22fb1e96..851266bd 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1128,7 +1128,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
for (auto it = possibleMembers.begin(); it != possibleMembers.end();)
if (
it->type->category() == Type::Category::Function &&
- !dynamic_cast<FunctionType const&>(*it->type).canTakeArguments(*argumentTypes)
+ !dynamic_cast<FunctionType const&>(*it->type).canTakeArguments(*argumentTypes, exprType)
)
it = possibleMembers.erase(it);
else
@@ -1163,6 +1163,15 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
auto& annotation = _memberAccess.annotation();
annotation.referencedDeclaration = possibleMembers.front().declaration;
annotation.type = possibleMembers.front().type;
+
+ if (auto funType = dynamic_cast<FunctionType const*>(annotation.type.get()))
+ if (funType->bound() && !exprType->isImplicitlyConvertibleTo(*funType->selfType()))
+ typeError(
+ _memberAccess.location(),
+ "Function \"" + memberName + "\" cannot be called on an object of type " +
+ exprType->toString() + " (expected " + funType->selfType()->toString() + ")"
+ );
+
if (exprType->category() == Type::Category::Struct)
annotation.isLValue = true;
else if (exprType->category() == Type::Category::Array)