mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Store super function.
This commit is contained in:
parent
eacee5b25c
commit
342367d5dc
@ -315,6 +315,9 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func
|
||||
if (!functionType.hasEqualArgumentTypes(superType))
|
||||
return;
|
||||
|
||||
if (!function.annotation().superFunction)
|
||||
function.annotation().superFunction = &super;
|
||||
|
||||
if (function.visibility() != super.visibility())
|
||||
overrideError(function, super, "Overriding function visibility differs.");
|
||||
|
||||
|
@ -63,6 +63,7 @@ private:
|
||||
void checkContractDuplicateFunctions(ContractDefinition const& _contract);
|
||||
void checkContractIllegalOverrides(ContractDefinition const& _contract);
|
||||
/// Reports a type error with an appropiate message if overriden function signature differs.
|
||||
/// Also stores the direct super function in the AST annotations.
|
||||
void checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super);
|
||||
void overrideError(FunctionDefinition const& function, FunctionDefinition const& super, std::string message);
|
||||
void checkContractAbstractFunctions(ContractDefinition const& _contract);
|
||||
|
@ -94,6 +94,9 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, DocumentedAnnota
|
||||
|
||||
struct FunctionDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation
|
||||
{
|
||||
/// The function this function overrides, if any. This is always the closest
|
||||
/// in the linearized inheritance hierarchy.
|
||||
FunctionDefinition const* superFunction = nullptr;
|
||||
};
|
||||
|
||||
struct EventDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation
|
||||
|
@ -328,6 +328,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node)
|
||||
make_pair(m_legacy ? "constant" : "isDeclaredConst", _node.stateMutability() <= StateMutability::View),
|
||||
make_pair("payable", _node.isPayable()),
|
||||
make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())),
|
||||
make_pair("superFunction", idOrNull(_node.annotation().superFunction)),
|
||||
make_pair("visibility", Declaration::visibilityToString(_node.visibility())),
|
||||
make_pair("parameters", toJson(_node.parameterList())),
|
||||
make_pair("isConstructor", _node.isConstructor()),
|
||||
|
Loading…
Reference in New Issue
Block a user