aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-12-30 20:46:53 +0800
committerchriseth <chris@ethereum.org>2018-04-12 19:09:37 +0800
commitf00bb4359375cd03e9ff6373b5efa41a37ce2876 (patch)
treed56546ceb10e7c8447fcad63b53fa77e77d61bd2 /libsolidity
parent17fc0f54b5dbf6b49e0500e3fca7b681316071f6 (diff)
downloaddexon-solidity-f00bb4359375cd03e9ff6373b5efa41a37ce2876.tar
dexon-solidity-f00bb4359375cd03e9ff6373b5efa41a37ce2876.tar.gz
dexon-solidity-f00bb4359375cd03e9ff6373b5efa41a37ce2876.tar.bz2
dexon-solidity-f00bb4359375cd03e9ff6373b5efa41a37ce2876.tar.lz
dexon-solidity-f00bb4359375cd03e9ff6373b5efa41a37ce2876.tar.xz
dexon-solidity-f00bb4359375cd03e9ff6373b5efa41a37ce2876.tar.zst
dexon-solidity-f00bb4359375cd03e9ff6373b5efa41a37ce2876.zip
Allow function overloads involving MagicVariableDeclarations.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp8
-rw-r--r--libsolidity/analysis/NameAndTypeResolver.cpp5
-rw-r--r--libsolidity/analysis/TypeChecker.cpp7
-rw-r--r--libsolidity/ast/AST.h5
4 files changed, 18 insertions, 7 deletions
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp
index c7ba78d6..786272e4 100644
--- a/libsolidity/analysis/DeclarationContainer.cpp
+++ b/libsolidity/analysis/DeclarationContainer.cpp
@@ -45,7 +45,8 @@ Declaration const* DeclarationContainer::conflictingDeclaration(
if (
dynamic_cast<FunctionDefinition const*>(&_declaration) ||
- dynamic_cast<EventDefinition const*>(&_declaration)
+ dynamic_cast<EventDefinition const*>(&_declaration) ||
+ dynamic_cast<MagicVariableDeclaration const*>(&_declaration)
)
{
// check that all other declarations with the same name are functions or a public state variable or events.
@@ -68,6 +69,11 @@ Declaration const* DeclarationContainer::conflictingDeclaration(
!dynamic_cast<EventDefinition const*>(declaration)
)
return declaration;
+ if (
+ dynamic_cast<MagicVariableDeclaration const*>(&_declaration) &&
+ !dynamic_cast<MagicVariableDeclaration const*>(declaration)
+ )
+ return declaration;
// Or, continue.
}
}
diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp
index 2f675135..5f9e0e99 100644
--- a/libsolidity/analysis/NameAndTypeResolver.cpp
+++ b/libsolidity/analysis/NameAndTypeResolver.cpp
@@ -202,8 +202,9 @@ vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations(
solAssert(
dynamic_cast<FunctionDefinition const*>(declaration) ||
dynamic_cast<EventDefinition const*>(declaration) ||
- dynamic_cast<VariableDeclaration const*>(declaration),
- "Found overloading involving something not a function or a variable."
+ dynamic_cast<VariableDeclaration const*>(declaration) ||
+ dynamic_cast<MagicVariableDeclaration const*>(declaration),
+ "Found overloading involving something not a function, event or a (magic) variable."
);
FunctionTypePointer functionType { declaration->functionType(false) };
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 8b57fc15..4b1ef55b 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2124,10 +2124,9 @@ bool TypeChecker::visit(Identifier const& _identifier)
for (Declaration const* declaration: annotation.overloadedDeclarations)
{
- TypePointer function = declaration->type();
- solAssert(!!function, "Requested type not present.");
- auto const* functionType = dynamic_cast<FunctionType const*>(function.get());
- if (functionType && functionType->canTakeArguments(*annotation.argumentTypes))
+ FunctionTypePointer functionType = declaration->functionType(true);
+ solAssert(!!functionType, "Requested type not present.");
+ if (functionType->canTakeArguments(*annotation.argumentTypes))
candidates.push_back(declaration);
}
if (candidates.empty())
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index b648e08b..a53987bf 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -831,6 +831,11 @@ public:
solAssert(false, "MagicVariableDeclaration used inside real AST.");
}
+ virtual FunctionTypePointer functionType(bool) const override
+ {
+ solAssert(m_type->category() == Type::Category::Function, "");
+ return std::dynamic_pointer_cast<FunctionType const>(m_type);
+ }
virtual TypePointer type() const override { return m_type; }
private: