Skip to content

Commit

Permalink
completions/inference: small formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobzim-stl committed Oct 21, 2024
1 parent 33eefce commit 0942b32
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions gopls/internal/golang/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -2613,18 +2613,14 @@ func (c *completer) resetExpectedType(inf *candidateInference) []types.Type {
func (c *completer) reverseInferExpectedTypeParam(inf candidateInference, expectedConstraint types.Type, typeParamIdx int, sig *types.Signature) candidateInference {
inf.typeName.wantTypeName = true
inf.typeName.isTypeParam = true
inf.objType = expectedConstraint

if typeParamIdx < 0 || typeParamIdx >= sig.TypeParams().Len() {
inf.objType = nil
return inf
}

substs, ok := reverseInferSignature(sig, c.resetExpectedType(&inf))
if ok && len(substs) > 0 && substs[typeParamIdx] != nil {
if substs, _ := reverseInferSignature(sig, c.resetExpectedType(&inf)); len(substs) > 0 && substs[typeParamIdx] != nil {
inf.objType = substs[typeParamIdx]
} else {
// Default to the constraint if no viable substition.
inf.objType = expectedConstraint
}
return inf
}
Expand Down

0 comments on commit 0942b32

Please sign in to comment.