[chapel-lang/chapel] getVisibleFunctionsImpl(), or getVisibleFunctions(

Branch: refs/heads/master
Revision: 8ab8127
Author: vasslitvinov
Log Message:

Use only the innermost POI (#16279) by vasslitvinov

getVisibleFunctionsImpl(), or getVisibleFunctions() prior to #16158,
considered POIs (Point of Instantiation) of both the inner and the outer
generic functions at once when a call was lexically nested in both.

With this change, only POI of the inner function is considered directly.
Also, if the innermost enclosing function is concrete and the concrete
function is nested in generic function(s), POI of the innermost of those
generic function(s) will be considered directly.

For example, POI of outer() is no longer considered after gathering visible
candidates in the scope of the call to callme() here:

proc outer(type t) {
proc inner(param p) {
callme(); // this call
}
{
proc callme() { }
inner(1);
}
}
{
proc callme() { } // no longer considered a visible candidate
outer(int);
}

The former behavior does not match the POI rule in the spec:
https://chapel-lang.org/docs/language/spec/generics.html#function-visibility-in-generic-functions
as modified in #15948 / #16158. This rule specifies that only a single POI
be followed per call or per scope.

Also, the former behavior does not reach any scopes/visible functions
that would not be reachable with the new behavior. For example, in the above
snippet POI of inner() - the call inner(1) - is itself inside outer().
So POI of outer() is consulted in due time after POI of inner().
The order of reaching these scopes may now be different, although we have not
observed this difference in practice.

IMPLEMENTATION DETAILS

This change is implemented by replacing the vectors currentScopes and
nextScopes with single pointers visInfo->currStart and visInfo->nextPOI.
If the scope visInfo->currStart is contained in one or more generic function,
POI of the innermost generic function will be queued in visInfo->nextPOI.

While there - I bundled several things passed around in findVisibleFunctions()
and getVisibleFunctions() into a class VisibilityInfo. It may be a wash
right now. However, I will be adding more things to pass around in my upcoming
#16261, so gathering them into one bundle will avoid further increase in
the number of arguments of these functions.

I also made minor aesthetic formatting tweaks.

r: @mppf

Modified Files:
A test/functions/generic/poi/outer-inner.chpl
A test/functions/generic/poi/outer-inner.good
M compiler/include/visibleFunctions.h
M compiler/resolution/functionResolution.cpp
M compiler/resolution/visibleFunctions.cpp

Compare: https://github.com/chapel-lang/chapel/compare/29724b007bf5...8ab81270ba9a