mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow private or internal functions in interfaces
This commit is contained in:
parent
5a71e4f1a7
commit
2067a00f22
@ -463,6 +463,9 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
|
||||
typeError(_function.location(), "Functions in interfaces cannot have an implementation.");
|
||||
_function.body().accept(*this);
|
||||
}
|
||||
if (_function.visibility() < FunctionDefinition::Visibility::Public)
|
||||
if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface)
|
||||
typeError(_function.location(), "Functions in interfaces cannot be internal or private.");
|
||||
if (_function.isConstructor())
|
||||
if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface)
|
||||
typeError(_function.location(), "Constructor cannot be defined in interfaces.");
|
||||
|
@ -5368,6 +5368,26 @@ BOOST_AUTO_TEST_CASE(interface_function_bodies)
|
||||
CHECK_ERROR(text, TypeError, "Functions in interfaces cannot have an implementation");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(interface_function_internal)
|
||||
{
|
||||
char const* text = R"(
|
||||
interface I {
|
||||
function f() internal;
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Functions in interfaces cannot be internal or private.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(interface_function_private)
|
||||
{
|
||||
char const* text = R"(
|
||||
interface I {
|
||||
function f() private;
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Functions in interfaces cannot be internal or private.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(interface_events)
|
||||
{
|
||||
char const* text = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user