Merge pull request #12461 from ethereum/cleanup-modifier-resolve

[trivial] Remove unnecessary checks in modifier resolve function
This commit is contained in:
chriseth 2021-12-29 14:28:52 +01:00 committed by GitHub
commit 7c4f4ae46c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -511,23 +511,20 @@ ModifierDefinition const& ModifierDefinition::resolveVirtual(
ContractDefinition const* _searchStart
) const
{
// Super is not possible with modifiers
solAssert(_searchStart == nullptr, "Used super in connection with modifiers.");
// If we are not doing super-lookup and the modifier is not virtual, we can stop here.
if (_searchStart == nullptr && !virtualSemantics())
// The modifier is not virtual, we can stop here.
if (!virtualSemantics())
return *this;
solAssert(!dynamic_cast<ContractDefinition const&>(*scope()).isLibrary(), "");
for (ContractDefinition const* c: _mostDerivedContract.annotation().linearizedBaseContracts)
{
if (_searchStart != nullptr && c != _searchStart)
continue;
_searchStart = nullptr;
for (ModifierDefinition const* modifier: c->functionModifiers())
if (modifier->name() == name())
return *modifier;
}
solAssert(false, "Virtual modifier " + name() + " not found.");
return *this; // not reached
}