aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-02-27 19:02:56 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-03-26 18:35:17 +0800
commitef3595b0001614c19174c61d29d221844ed83a0e (patch)
treefe46d4e1ba7ae882c026145086482f9de75608f9 /libsolidity
parentba209fe485ba40ea3926800bc90932bec40cd16f (diff)
downloaddexon-solidity-ef3595b0001614c19174c61d29d221844ed83a0e.tar.gz
dexon-solidity-ef3595b0001614c19174c61d29d221844ed83a0e.tar.zst
dexon-solidity-ef3595b0001614c19174c61d29d221844ed83a0e.zip
Allow overriding external functions in interfaces with public in an implementing contract
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 999a2a97..487959c5 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -366,6 +366,16 @@ 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);
@@ -378,7 +388,12 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func
function.annotation().superFunction = &super;
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)
+ return;
overrideError(function, super, "Overriding function visibility differs.");
+ }
else if (function.stateMutability() != super.stateMutability())
overrideError(