+ -------------------------------------------------
+ -- Formal packages and partial parametrization --
+ -------------------------------------------------
+
+ -- When compiling a generic, a formal package is a local instantiation. If
+ -- declared with a box, its generic formals are visible in the enclosing
+ -- generic. If declared with a partial list of actuals, those actuals that
+ -- are defaulted (covered by an Others clause, or given an explicit box
+ -- initialization) are also visible in the enclosing generic, while those
+ -- that have a corresponding actual are not.
+
+ -- In our source model of instantiation, the same visibility must be
+ -- present in the spec and body of an instance: the names of the formals
+ -- that are defaulted must be made visible within the instance, and made
+ -- invisible (hidden) after the instantiation is complete, so that they
+ -- are not accessible outside of the instance.
+
+ -- In a generic, a formal package is treated like a special instantiation.
+ -- Our Ada95 compiler handled formals with and without box in different
+ -- ways. With partial parametrization, we use a single model for both.
+ -- We create a package declaration that consists of the specification of
+ -- the generic package, and a set of declarations that map the actuals
+ -- into local renamings, just as we do for bona fide instantiations. For
+ -- defaulted parameters and formals with a box, we copy directly the
+ -- declarations of the formal into this local package. The result is a
+ -- a package whose visible declarations may include generic formals. This
+ -- package is only used for type checking and visibility analysis, and
+ -- never reaches the back-end, so it can freely violate the placement
+ -- rules for generic formal declarations.
+
+ -- The list of declarations (renamings and copies of formals) is built
+ -- by Analyze_Associations, just as for regular instantiations.
+
+ -- At the point of instantiation, conformance checking must be applied only
+ -- to those parameters that were specified in the formal. We perform this
+ -- checking by creating another internal instantiation, this one including
+ -- only the renamings and the formals (the rest of the package spec is not
+ -- relevant to conformance checking). We can then traverse two lists: the
+ -- list of actuals in the instance that corresponds to the formal package,
+ -- and the list of actuals produced for this bogus instantiation. We apply
+ -- the conformance rules to those actuals that are not defaulted (i.e.
+ -- which still appear as generic formals.
+
+ -- When we compile an instance body we must make the right parameters
+ -- visible again. The predicate Is_Generic_Formal indicates which of the
+ -- formals should have its Is_Hidden flag reset.
+