Prohibit interfaces inheriting from non-interfaces

This commit is contained in:
Jason Cobb 2020-01-02 16:32:35 -05:00
parent 1cc8ce1656
commit 573a054d5d
No known key found for this signature in database
GPG Key ID: 2A3F6A6DCA1E8DED
2 changed files with 8 additions and 0 deletions

View File

@ -237,6 +237,9 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
auto base = dynamic_cast<ContractDefinition const*>(&dereference(_inheritance.name()));
solAssert(base, "Base contract not available.");
if (m_scope->isInterface() && !base->isInterface())
m_errorReporter.typeError(_inheritance.location(), "Interfaces can only inherit from other interfaces.");
if (base->isLibrary())
m_errorReporter.typeError(_inheritance.location(), "Libraries cannot be inherited from.");

View File

@ -0,0 +1,5 @@
contract C {}
interface I is C {}
// ----
// TypeError: (29-30): Interfaces can only inherit from other interfaces.