go/types, types2: no need to revert tparam renaming in inference results

This is a follow up to CL 385494. In early patch sets of that CL,
renamed type parameters were substituted in arguments, which meant that
they could leak into the inference results. However, we subsequently
realized that we could instead substitute in the signature parameters.
In this case it is not possible for the substituted type parameters to
appear in the resulting type arguments, so there is no need to
un-substitute.

Change-Id: I4da45b0b8d7ad809d0ddfa7061ae5f6f07895540
Reviewed-on: https://go-review.googlesource.com/c/go/+/385574
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Robert Findley 2022-02-13 20:27:55 -05:00
parent badbc52d82
commit 875a6d4010
2 changed files with 0 additions and 20 deletions

View File

@ -116,16 +116,6 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
tparams = tparams2
params = check.subst(pos, params, renameMap, nil).(*Tuple)
// If we replaced any type parameters, their replacements may occur in
// the resulting inferred type arguments. Make sure we use the original
// type parameters in the result.
defer func() {
unrenameMap := makeRenameMap(tparams2, tparams)
for i, res := range result {
result[i] = check.subst(pos, res, unrenameMap, nil)
}
}()
}
}

View File

@ -115,16 +115,6 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type,
tparams = tparams2
params = check.subst(posn.Pos(), params, renameMap, nil).(*Tuple)
// If we replaced any type parameters, their replacements may occur in
// the resulting inferred type arguments. Make sure we use the original
// type parameters in the result.
defer func() {
unrenameMap := makeRenameMap(tparams2, tparams)
for i, res := range result {
result[i] = check.subst(posn.Pos(), res, unrenameMap, nil)
}
}()
}
}