[Chapel Merge] Fix bug with allowing limitation clauses to mentio

Branch: refs/heads/main
Revision: c4dccc9
Author: lydia-duncan
Link: Unavailable
Log Message:

Merge pull request #18622 from lydia-duncan/onlyExceptRespectPrivate

Fix bug with allowing limitation clauses to mention symbols behind private uses/imports
[reviewed by @mppf]

Prior to this change, validating except/only lists or import unqualified access
lists was not respecting the privacy of use and import statements, so we would
not error when validating those lists if the symbol could be found down a
private use or import chain. Such symbols shouldn't be reference-able in other
parts of the code either, but the error should be caught sooner.

This change adjusts that validation to avoid looking in such private uses and
imports. The way the module list was created for scope resolution accidentally included
modules used or imported by modules that were privately used or imported. For
instance, in the following use chain, if A were to be used by another module
Main, we would expect only A's contents to be visible to Main:

A
-> private use B
  -> use C

However, we were both including the use of B and including B's use of C, when
the use of B was private. This change makes it so that we stop including a
chain when we see the root of it is private.

Unfortunately, we have to cut off exploration in two places. We have to cut
it in the recursive case of buildBreadthFirstUseImportList, and we have to
recognize when our entry point into building the list would already be violating
that tactic. The former will have a broader impact on scope resolution, the
latter will only matter for validating use and import lists (because if we're
looking at the contents of a use or import list, we know we're starting in the
middle of a chain).

As a result, 17 tests needed an update because they were relying on the
privacy of a use or import statement being violated. In many of these tests,
the solution was to make the use or import in question public to maintain prior
behavior. Also, resolves the future tracking this issue, and adds a version for
except lists and import lists, as well as the more specific "this" case that Bryant
encountered.

Resolves #18267
Resolves #16982

Passed a full paratest with futures.

Modified Files:
A test/visibility/except/errorWhenBehindPrivateImport.chpl

A test/visibility/except/errorWhenBehindPrivateImport.compopts
A test/visibility/except/errorWhenBehindPrivateImport.good
A test/visibility/except/errorWhenBehindPrivateUse.chpl
A test/visibility/except/errorWhenBehindPrivateUse.compopts
A test/visibility/except/errorWhenBehindPrivateUse.good
A test/visibility/import/enablesUnqualified/multipleUnqualified/badName-this.chpl
A test/visibility/import/enablesUnqualified/multipleUnqualified/badName-this.good
A test/visibility/import/enablesUnqualified/multipleUnqualified/errorWhenBehindPrivateImport.chpl
A test/visibility/import/enablesUnqualified/multipleUnqualified/errorWhenBehindPrivateImport.compopts
A test/visibility/import/enablesUnqualified/multipleUnqualified/errorWhenBehindPrivateImport.good
A test/visibility/import/enablesUnqualified/multipleUnqualified/errorWhenBehindPrivateUse.chpl
A test/visibility/import/enablesUnqualified/multipleUnqualified/errorWhenBehindPrivateUse.compopts
A test/visibility/import/enablesUnqualified/multipleUnqualified/errorWhenBehindPrivateUse.good
A test/visibility/only/errorWhenBehindPrivateImport.chpl
A test/visibility/only/errorWhenBehindPrivateImport.compopts
A test/visibility/only/errorWhenBehindPrivateImport.good
R test/visibility/only/errorWhenBehindPrivateUse.bad
R test/visibility/only/errorWhenBehindPrivateUse.future
M compiler/include/ResolveScope.h
M compiler/passes/ResolveScope.cpp
M modules/internal/ChapelAutoAggregation.chpl
M test/modules/deitz/test_module_class_conflict2.chpl
M test/modules/deitz/test_module_use4.chpl
M test/modules/noakes/mod-init-order-works.chpl
M test/visibility/except/forwarding-containerListed.chpl
M test/visibility/except/inheritance-subclassListed.chpl
M test/visibility/except/inheritance-subclassListed2.chpl
M test/visibility/import/enablesUnqualified/forwarding-containerListed2.chpl
M test/visibility/import/enablesUnqualified/inheritance-subclassListed1b.chpl
M test/visibility/import/enablesUnqualified/inheritance-subclassListed2b.chpl
M test/visibility/only/forwarding-containerListed.chpl
M test/visibility/only/inheritance-subclassListed.chpl
M test/visibility/only/inheritance-subclassListed2.chpl
M test/visibility/only/onlyExceptPrevents.chpl
M test/visibility/rename/innerOnly2.chpl
M test/visibility/rename/outerExceptNoNewName.chpl
M test/visibility/rename/outerOnlyNoOldName2.chpl
M test/visibility/rename/renameRecord.chpl

Compare: https://github.com/chapel-lang/chapel/compare/70c72e05007b...c4dccc949aa9