[tools] gopls/internal/analysis/ptrtoerror: support type assert and instances

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Jul 16, 2026, 2:28:11 PM (yesterday) Jul 16
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Madeline Kalil, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
gopls/internal/analysis/ptrtoerror: support type assert and instances

The previous CL missed two important cases where syntax implies
an implements relation between E (or *E) and the error interface:

1. Type assertions and type switches
err.(E)
switch err.(type) { case E: }

2. Instantiatio of type parameters
errors.AsType[E](err)

This change augments the 'conversions' iterator to return them too,
and adds tests for the missing cases.

Updates golang/go#61342
Updates golang/go#70638
Updates golang/go#80159
Change-Id: I7612aa0a9e38079ef4dec1b8eabff458e74ea81b
Reviewed-by: Madeline Kalil <mka...@google.com>
Files:
  • M gopls/internal/analysis/ptrtoerror/conv.go
  • M gopls/internal/analysis/ptrtoerror/ptrtoerror_test.go
  • A gopls/internal/analysis/ptrtoerror/testdata/src/c/c.go
  • A gopls/internal/analysis/ptrtoerror/testdata/src/c/c.go.golden
  • A gopls/internal/analysis/ptrtoerror/testdata/src/d/d.go
  • A gopls/internal/analysis/ptrtoerror/testdata/src/errors/errors.go
Change size: M
Delta: 6 files changed, 202 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I7612aa0a9e38079ef4dec1b8eabff458e74ea81b
Gerrit-Change-Number: 801000
Gerrit-PatchSet: 3
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages