private NewInferenceResult DoSecondPhase()
{
// SPEC: If no unfixed CType parameters exist then CType inference succeeds.
if (AllFixed())
{
return NewInferenceResult.Success;
}
// SPEC: Otherwise, if there exists one or more arguments Ei with
// SPEC: corresponding parameter CType Ti such that:
// SPEC: o the output CType of Ei with CType Ti contains at least one unfixed
// SPEC: CType parameter Xj, and
// SPEC: o none of the input types of Ei with CType Ti contains any unfixed
// SPEC: CType parameter Xj,
// SPEC: then an output CType inference is made from all such Ei to Ti.
MakeOutputTypeInferences();
// SPEC: Whether or not the previous step actually made an inference, we
// SPEC: must now fix at least one CType parameter, as follows:
// SPEC: If there exists one or more CType parameters Xi such that
// SPEC: o Xi is unfixed, and
// SPEC: o Xi has a non-empty set of bounds, and
// SPEC: o Xi does not depend on any Xj
// SPEC: then each such Xi is fixed. If any fixing operation fails then
// SPEC: CType inference fails.
NewInferenceResult res = FixNondependentParameters();
if (res != NewInferenceResult.NoProgress)
{
return res;
}
// SPEC: Otherwise, if there exists one or more CType parameters Xi such that
// SPEC: o Xi is unfixed, and
// SPEC: o Xi has a non-empty set of bounds, and
// SPEC: o there is at least one CType parameter Xj that depends on Xi
// SPEC: then each such Xi is fixed. If any fixing operation fails then
// SPEC: CType inference fails.
res = FixDependentParameters();
if (res != NewInferenceResult.NoProgress)
{
return res;
}
// SPEC: Otherwise, we are unable to make progress and there are
// SPEC: unfixed parameters. CType inference fails.
return NewInferenceResult.InferenceFailed;
}