Mark visibility of initialize(...)
functions as external
#3750
Labels
breaking change
Changes that break backwards compatibility of the public API.
Milestone
This topic has probably been discussed already in the past, and reached agreement. But I believe it is worth discussing again since
4.4.1
release.Background
The
initialize(...)
function of the upgradeable contracts is markedpublic
.Someone asked already in the OpenZeppelin forum why this function was not marked
public
. The initial intention as mentioned by @frangio was:Suggested changes
Since the 4.4.1 release and the introduction of the
onlyInitializing
modifier, it feels like theinitialize(...)
function might fit better with theexternal
visibility. The reasons and my arguments for this would be:initialize(...)
function calls theinternal {...}_init
function, not the parentpublic initialize(...)
function.external
instead ofpublic
would give more the sense of theinitialize(...)
functions to behave like aconstructor
(only called on deployment, so should only be called externally.external
overpublic
(but this is not the main argument).My main argument for changing the
initialize(...)
function toexternal
would be about the issue of overriding function visibility (see screenshots below). With Solidityexternal
topublic
(= "opening it up") ✅public
toexternal
(= "narrow it down"). ❌So people who want to override the function to lock it down cannot currently with the
public
visibility.TLDR;
What are the reasons for keeping the
initialize(...)
function aspublic
overall?Why not marking it as
external
to prevent the issue of visibility overriding showed in the screenshots below?I would be interested to hear your opinions on this suggested change. @Amxx @frangio (anyone else from OZ team)
Screenshots
The text was updated successfully, but these errors were encountered: