Clean up visibility via contract name and fix ICE on calling unimplemented base function.

This commit is contained in:
Daniel Kirchner
2020-01-16 19:13:04 +01:00
parent 0f2ec771b9
commit ee5ff4df4e
26 changed files with 188 additions and 79 deletions
+1 -1
View File
@@ -625,7 +625,6 @@ bool DeclarationRegistrationHelper::visit(FunctionDefinition& _function)
{
registerDeclaration(_function, true);
m_currentFunction = &_function;
_function.annotation().contract = m_currentContract;
return true;
}
@@ -760,6 +759,7 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio
registerDeclaration(*m_scopes[m_currentScope], _declaration, nullptr, nullptr, warnAboutShadowing, inactive, m_errorReporter);
_declaration.annotation().scope = m_currentScope;
_declaration.annotation().contract = m_currentContract;
if (_opensScope)
enterNewSubScope(_declaration);
}
+12 -4
View File
@@ -1695,11 +1695,20 @@ void TypeChecker::typeCheckFunctionCall(
{
m_errorReporter.typeError(
_functionCall.location(),
"Cannot call function via contract name."
"Cannot call function via contract type name."
);
return;
}
if (_functionType->kind() == FunctionType::Kind::Internal && _functionType->hasDeclaration())
if (auto const* functionDefinition = dynamic_cast<FunctionDefinition const*>(&_functionType->declaration()))
// functionDefinition->annotation().contract != m_scope ensures that this is a qualified access,
// e.g. ``A.f();`` instead of a simple function call like ``f();`` (the latter is valid for unimplemented
// functions).
if (functionDefinition->annotation().contract != m_scope && !functionDefinition->isImplemented())
m_errorReporter.typeError(
_functionCall.location(),
"Cannot call unimplemented base function."
);
// Check for unsupported use of bare static call
if (
@@ -2660,8 +2669,7 @@ bool TypeChecker::visit(Identifier const& _identifier)
);
annotation.isLValue = annotation.referencedDeclaration->isLValue();
annotation.type = annotation.referencedDeclaration->type();
if (!annotation.type)
m_errorReporter.fatalTypeError(_identifier.location(), "Declaration referenced before type could be determined.");
solAssert(annotation.type, "Declaration referenced before type could be determined.");
if (auto variableDeclaration = dynamic_cast<VariableDeclaration const*>(annotation.referencedDeclaration))
annotation.isPure = annotation.isConstant = variableDeclaration->isConstant();
else if (dynamic_cast<MagicVariableDeclaration const*>(annotation.referencedDeclaration))