diff options
author | chriseth <c@ethdev.com> | 2015-11-28 05:24:00 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-11-29 07:16:07 +0800 |
commit | f9e52c9db1ef23000f5721a462aba3fa8d681749 (patch) | |
tree | d1b77769961618d027c794131949efe021fa4b49 /libsolidity/analysis | |
parent | 93b3237c6ae526d3ff5aa0d23d48319cf705baee (diff) | |
download | dexon-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.cpp | 11 |
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) |