solidity-upgrade: added module to remove visibility of constructors

This commit is contained in:
Harikrishnan Mulackal
2020-07-08 18:57:20 +05:30
parent 64b6524bdb
commit 6b435b2192
6 changed files with 81 additions and 30 deletions
+24
View File
@@ -59,3 +59,27 @@ void NowKeyword::endVisit(Identifier const& _identifier)
);
}
}
void ConstructorVisibility::endVisit(ContractDefinition const& _contract)
{
if (!_contract.abstract())
for (FunctionDefinition const* function: _contract.definedFunctions())
if (
function->isConstructor() &&
!function->noVisibilitySpecified() &&
function->visibility() == Visibility::Internal
)
m_changes.emplace_back(
UpgradeChange::Level::Safe,
_contract.location(),
SourceTransform::insertBeforeKeyword(_contract.location(), "contract", "abstract")
);
for (FunctionDefinition const* function: _contract.definedFunctions())
if (function->isConstructor() && !function->noVisibilitySpecified())
m_changes.emplace_back(
UpgradeChange::Level::Safe,
function->location(),
SourceTransform::removeVisibility(function->location())
);
}