diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-03-14 23:56:06 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-03-26 18:37:38 +0800 |
commit | 8bae2dba7c9697d129a43c1dde54690f3e37a84a (patch) | |
tree | 07ce21a7b1ff6d0171e231249f1b7df837734d31 /libsolidity/analysis/TypeChecker.cpp | |
parent | ef3595b0001614c19174c61d29d221844ed83a0e (diff) | |
download | dexon-solidity-8bae2dba7c9697d129a43c1dde54690f3e37a84a.tar dexon-solidity-8bae2dba7c9697d129a43c1dde54690f3e37a84a.tar.gz dexon-solidity-8bae2dba7c9697d129a43c1dde54690f3e37a84a.tar.bz2 dexon-solidity-8bae2dba7c9697d129a43c1dde54690f3e37a84a.tar.lz dexon-solidity-8bae2dba7c9697d129a43c1dde54690f3e37a84a.tar.xz dexon-solidity-8bae2dba7c9697d129a43c1dde54690f3e37a84a.tar.zst dexon-solidity-8bae2dba7c9697d129a43c1dde54690f3e37a84a.zip |
Introduce inContractKind helper on FunctionDefinition
Diffstat (limited to 'libsolidity/analysis/TypeChecker.cpp')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 487959c5..6e287f83 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -366,16 +366,6 @@ void TypeChecker::checkContractIllegalOverrides(ContractDefinition const& _contr } } -namespace { - -bool functionIsInInterface(FunctionDefinition const& _function) -{ - return dynamic_cast<ContractDefinition const*>(_function.scope()) && - dynamic_cast<ContractDefinition const*>(_function.scope())->contractKind() == ContractDefinition::ContractKind::Interface; -} - -} - void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super) { FunctionType functionType(function); @@ -390,7 +380,11 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func if (function.visibility() != super.visibility()) { // visibility is enforced to be external in interfaces, but a contract can override that with public - if (functionIsInInterface(super) && !functionIsInInterface(function) && function.visibility() == FunctionDefinition::Visibility::Public) + if ( + super.inContractKind() == ContractDefinition::ContractKind::Interface && + function.inContractKind() != ContractDefinition::ContractKind::Interface && + function.visibility() == FunctionDefinition::Visibility::Public + ) return; overrideError(function, super, "Overriding function visibility differs."); } |