From 0942b32e9aeeaef085f88033aa56a294a01f3a44 Mon Sep 17 00:00:00 2001 From: Jacob Zimmerman Date: Mon, 21 Oct 2024 00:56:02 -0400 Subject: [PATCH] completions/inference: small formatting --- gopls/internal/golang/completion/completion.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gopls/internal/golang/completion/completion.go b/gopls/internal/golang/completion/completion.go index 80682924b9f..7213d1206b2 100644 --- a/gopls/internal/golang/completion/completion.go +++ b/gopls/internal/golang/completion/completion.go @@ -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 }