Local methods: must be private

Hello,
The local methods are not private. I don’t know if their visibility is the same as the outer method or not, but I have a public method whose local method is also public. This is a problem because a user of the assembly sees the local method and can call it…
Marking all of them as private will not hurt because they should be called only from the outside method.

Logged as bugs://E25236.

bugs://E25236 was closed as fixed.

Note that in the case they get moved onto a class, they cannot be private, they become assembly, and for called from inline ones, they stay public.

1 Like

I assume the compiler can still enforce privateness, within the same assembly?

Not on .NET, the runtime enforces assembly vs private, where the last only really works within the same class.

What I mean is: if Oxygene code tries to call a local methods from externally (before it even hits IL), that could/should still fails “no such indentifier”, even if the method is available (much like how “unit” is only enforced by the compiler, and doesn’t exist on IL level?)

Of course. You can’t directly call these methods at all.

1 Like

As the inner method is only called from the outside one, it should have the same visibility as the latter.