Store super function.

This commit is contained in:
chriseth 2017-08-29 17:07:32 +02:00
parent eacee5b25c
commit 342367d5dc
4 changed files with 8 additions and 0 deletions

View File

@ -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.");

View File

@ -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);

View File

@ -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

View File

@ -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()),