aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-04-02 21:10:35 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-04-17 21:27:31 +0800
commitd997dc55d154c93af01175d880734b9e737d34ca (patch)
tree3e08f516eb4fdb499223e681b93fd86504558589 /AST.cpp
parent6e5de4832da7a3c2fdbc87b71523ac671083d9c0 (diff)
downloaddexon-solidity-d997dc55d154c93af01175d880734b9e737d34ca.tar
dexon-solidity-d997dc55d154c93af01175d880734b9e737d34ca.tar.gz
dexon-solidity-d997dc55d154c93af01175d880734b9e737d34ca.tar.bz2
dexon-solidity-d997dc55d154c93af01175d880734b9e737d34ca.tar.lz
dexon-solidity-d997dc55d154c93af01175d880734b9e737d34ca.tar.xz
dexon-solidity-d997dc55d154c93af01175d880734b9e737d34ca.tar.zst
dexon-solidity-d997dc55d154c93af01175d880734b9e737d34ca.zip
Allowing abstract contracts constructor to have no args
- If a constructor is part of an abstract contract we can omit its arguments - IF a contract is abstract make sure to not create and/or request Assembly code about it since it's not compiled
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/AST.cpp b/AST.cpp
index 0abdf781..37016646 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -281,7 +281,7 @@ void InheritanceSpecifier::checkTypeRequirements()
ContractDefinition const* base = dynamic_cast<ContractDefinition const*>(m_baseName->getReferencedDeclaration());
solAssert(base, "Base contract not available.");
TypePointers parameterTypes = ContractType(*base).getConstructorType()->getParameterTypes();
- if (parameterTypes.size() != m_arguments.size())
+ if (m_arguments.size() != 0 && parameterTypes.size() != m_arguments.size())
BOOST_THROW_EXCEPTION(createTypeError("Wrong argument count for constructor call."));
for (size_t i = 0; i < m_arguments.size(); ++i)
if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i]))
@@ -348,8 +348,8 @@ void FunctionDefinition::checkTypeRequirements()
}
for (ASTPointer<ModifierInvocation> const& modifier: m_functionModifiers)
modifier->checkTypeRequirements(isConstructor() ?
- dynamic_cast<ContractDefinition const&>(*getScope()).getBaseContracts() :
- vector<ASTPointer<InheritanceSpecifier>>());
+ dynamic_cast<ContractDefinition const&>(*getScope()).getLinearizedBaseContracts() :
+ vector<ContractDefinition const*>());
if (m_body)
m_body->checkTypeRequirements();
}
@@ -426,7 +426,7 @@ void ModifierDefinition::checkTypeRequirements()
m_body->checkTypeRequirements();
}
-void ModifierInvocation::checkTypeRequirements(vector<ASTPointer<InheritanceSpecifier>> const& _bases)
+void ModifierInvocation::checkTypeRequirements(vector<ContractDefinition const*> const& _bases)
{
m_modifierName->checkTypeRequirements();
for (ASTPointer<Expression> const& argument: m_arguments)
@@ -439,10 +439,10 @@ void ModifierInvocation::checkTypeRequirements(vector<ASTPointer<InheritanceSpec
parameters = &modifier->getParameters();
else
// check parameters for Base constructors
- for (auto const& base: _bases)
- if (declaration == base->getName()->getReferencedDeclaration())
+ for (auto const* base: _bases)
+ if (declaration == base)
{
- if (auto referencedConstructor = dynamic_cast<ContractDefinition const&>(*declaration).getConstructor())
+ if (auto referencedConstructor = base->getConstructor())
parameters = &referencedConstructor->getParameters();
else
parameters = &emptyParameterList;