aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-01-10 23:26:13 +0800
committerYoichi Hirai <i@yoichihirai.com>2017-01-12 02:55:50 +0800
commiteda147f47bb5a0dfbed50aa2c2224daebafa76a8 (patch)
tree40d0bff7e542ba57fdaf72996a3255eb22a5159a /libsolidity/analysis
parente254a59bd29b7bf226197eaa836fc163be16ef09 (diff)
downloaddexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar
dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar.gz
dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar.bz2
dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar.lz
dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar.xz
dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar.zst
dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.zip
ast: add Declaration::functionType()
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/NameAndTypeResolver.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp
index 260965ae..47a9df1b 100644
--- a/libsolidity/analysis/NameAndTypeResolver.cpp
+++ b/libsolidity/analysis/NameAndTypeResolver.cpp
@@ -264,22 +264,15 @@ vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations(
solAssert(dynamic_cast<FunctionDefinition const*>(*it) || dynamic_cast<VariableDeclaration const*>(*it),
"Found overloading involving something not a function or a variable");
- unique_ptr<FunctionType const> functionType {};
-
- if (FunctionDefinition const* functionDefinition = dynamic_cast<FunctionDefinition const*>(*it))
- {
- functionType = unique_ptr<FunctionType const>(new FunctionType(*functionDefinition));
- for (auto parameter: functionType->parameterTypes() + functionType->returnParameterTypes())
- if (!parameter)
- reportFatalDeclarationError(_identifier.location(), "Function type can not be used in this context");
- }
- else
- {
- VariableDeclaration const* variableDeclaration = dynamic_cast<VariableDeclaration const*>(*it);
- functionType = unique_ptr<FunctionType const>(new FunctionType(*variableDeclaration));
- }
+ shared_ptr<FunctionType const> functionType { (*it)->functionType(false) };
+ if (!functionType)
+ functionType = (*it)->functionType(true);
solAssert(functionType, "failed to determine the function type of the overloaded");
+ for (auto parameter: functionType->parameterTypes() + functionType->returnParameterTypes())
+ if (!parameter)
+ reportFatalDeclarationError(_identifier.location(), "Function type can not be used in this context");
+
if (uniqueFunctions.end() == find_if(
uniqueFunctions.begin(),
uniqueFunctions.end(),