From 96c09fcbcd21ed6b907e055c915d5f13814b87d5 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 17 Mar 2017 17:01:13 +0000 Subject: [PATCH] Simplify interface checks for FunctionDefinition --- libsolidity/analysis/TypeChecker.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 3456958c7..b0551fcb7 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -457,18 +457,17 @@ bool TypeChecker::visit(FunctionDefinition const& _function) dynamic_cast(*_function.scope()).annotation().linearizedBaseContracts : vector() ); - if (_function.isImplemented()) + if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface) { - if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface) + if (_function.isImplemented()) typeError(_function.location(), "Functions in interfaces cannot have an implementation."); - _function.body().accept(*this); - } - if (_function.visibility() < FunctionDefinition::Visibility::Public) - if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface) + if (_function.visibility() < FunctionDefinition::Visibility::Public) typeError(_function.location(), "Functions in interfaces cannot be internal or private."); - if (_function.isConstructor()) - if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface) + if (_function.isConstructor()) typeError(_function.location(), "Constructor cannot be defined in interfaces."); + } + if (_function.isImplemented()) + _function.body().accept(*this); return false; }