-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I find myself wishing that when I inline a method, I could change the visibility of things it refers to that need to be visible for the inline to work.
Two ways this could work:
- An option on the
InlineAttributethat allows you to automatically promote the visibility of things referenced by the method being inlined. Most commonly, I expect to want to promoteprivatetointernal. But sometimes it may be necessary to promote topublic. - A separate attribute that is applied to the thing you want to change the access modifier on. This makes it more explicit.
Why not just make the member more accessible?
- Because I want to enforce with the compiler that nothing should call the member except the method being inlined. For example, I have a private constructor that is called by a number of static factory methods. I don't want anyone to directly call the constructor because the factory methods exist to make it clear which case is being constructed and enforce certain limits. But all the factory methods are short and ought to be inlined. However, doing so requires that the constructor not be private.
Metadata
Metadata
Assignees
Labels
No labels