diff options
author | chriseth <chris@ethereum.org> | 2018-11-26 23:50:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-26 23:50:40 +0800 |
commit | f937896727d85dcdbb60783d10f9cea1eaf9f925 (patch) | |
tree | 9d202b2e05908be6d6b01d4813757ac2a5b2751e /libsolidity | |
parent | f6d8810103c762d1f5a41bf1c29d33b771cfed50 (diff) | |
parent | 597174119a5f8ab03286c58581e7bf5ec52c14dc (diff) | |
download | dexon-solidity-f937896727d85dcdbb60783d10f9cea1eaf9f925.tar.gz dexon-solidity-f937896727d85dcdbb60783d10f9cea1eaf9f925.tar.zst dexon-solidity-f937896727d85dcdbb60783d10f9cea1eaf9f925.zip |
Merge pull request #5445 from ethereum/publicExternalOverwrite
Allow overwriting external functions (with ``calldata`` arguments) with public functions (with ``memory`` arguments)
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index d503b9ec..6295e083 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -215,7 +215,9 @@ void TypeChecker::findDuplicateDefinitions(map<string, vector<T>> const& _defini SecondarySourceLocation ssl; for (size_t j = i + 1; j < overloads.size(); ++j) - if (FunctionType(*overloads[i]).hasEqualParameterTypes(FunctionType(*overloads[j]))) + if (FunctionType(*overloads[i]).asCallableFunction(false)->hasEqualParameterTypes( + *FunctionType(*overloads[j]).asCallableFunction(false)) + ) { ssl.append("Other declaration is here:", overloads[j]->location()); reported.insert(j); @@ -250,7 +252,7 @@ void TypeChecker::checkContractAbstractFunctions(ContractDefinition const& _cont if (function->isConstructor()) continue; auto& overloads = functions[function->name()]; - FunctionTypePointer funType = make_shared<FunctionType>(*function); + FunctionTypePointer funType = make_shared<FunctionType>(*function)->asCallableFunction(false); auto it = find_if(overloads.begin(), overloads.end(), [&](FunTypeAndFlag const& _funAndFlag) { return funType->hasEqualParameterTypes(*_funAndFlag.first); @@ -402,10 +404,10 @@ void TypeChecker::checkContractIllegalOverrides(ContractDefinition const& _contr void TypeChecker::checkFunctionOverride(FunctionDefinition const& _function, FunctionDefinition const& _super) { - FunctionType functionType(_function); - FunctionType superType(_super); + FunctionTypePointer functionType = FunctionType(_function).asCallableFunction(false); + FunctionTypePointer superType = FunctionType(_super).asCallableFunction(false); - if (!functionType.hasEqualParameterTypes(superType)) + if (!functionType->hasEqualParameterTypes(*superType)) return; if (!_function.annotation().superFunction) @@ -431,7 +433,7 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& _function, Fun stateMutabilityToString(_function.stateMutability()) + "\"." ); - else if (functionType != superType) + else if (*functionType != *superType) overrideError(_function, _super, "Overriding function return types differ."); } @@ -456,7 +458,7 @@ void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _co // under non error circumstances this should be true if (functionType->interfaceFunctionType()) externalDeclarations[functionType->externalSignature()].push_back( - make_pair(f, functionType) + make_pair(f, functionType->asCallableFunction(false)) ); } for (VariableDeclaration const* v: contract->stateVariables()) @@ -466,7 +468,7 @@ void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _co // under non error circumstances this should be true if (functionType->interfaceFunctionType()) externalDeclarations[functionType->externalSignature()].push_back( - make_pair(v, functionType) + make_pair(v, functionType->asCallableFunction(false)) ); } } |