Repository: go
Issue: x/tools/gopls: "unexpected file: %q" bug.Report in bestView (reported by telemetry)
Labels: NeedsInvestigation,gopls,Tools,gopls/telemetry-wins

```
#!stacks
"bug.Errorf:+2" && "cache.port.matches.func1:+2"
```

This stack `FC7EOg` was [reported by telemetry](https://storage.googleapis.com/prod-telemetry-merged/2024-05-09.json):

```go
// matches reports whether the port matches a file with the given absolute path
// and content.
...
func (p port) matches(path string, content []byte) bool {
...
	// The only virtualized operation called by MatchFile is OpenFile.
	ctxt.OpenFile = func(p string) (io.ReadCloser, error) {
		if p != path {
			return nil, bug.Errorf("unexpected file %q", p)
		}
		return io.NopCloser(bytes.NewReader(content)), nil
	}
...
```

`gopls/bug`
- [`golang.org/x/tools/gopls/internal/util/bug.report:+35`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/util/bug/bug.go;l=109)
- [`golang.org/x/tools/gopls/internal/util/bug.Errorf:+2`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/util/bug/bug.go;l=61)
- [`golang.org/x/tools/gopls/internal/cache.port.matches.func1:+2`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/port.go;l=149)
- [`go/build.(*Context).openFile:+2`](https://cs.opensource.google/go/go/+/go1.23.0:src/go/build/build.go;l=212)
- [`go/build.(*Context).matchFile:+27`](https://cs.opensource.google/go/go/+/go1.23.0:src/go/build/build.go;l=1488)
- [`go/build.(*Context).MatchFile:=1420`](https://cs.opensource.google/go/go/+/go1.23.0:src/go/build/build.go;l=1420)
- [`golang.org/x/tools/gopls/internal/cache.port.matches:+15`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/port.go;l=156)
- [`golang.org/x/tools/gopls/internal/cache.defineView:+28`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/view.go;l=836)
- [`golang.org/x/tools/gopls/internal/cache.selectViewDefs:+63`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/session.go;l=552)
- [`golang.org/x/tools/gopls/internal/cache.(*Session).DidModifyFiles:+93`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/cache/session.go;l=845)
- [`golang.org/x/tools/gopls/internal/server.(*server).didModifyFiles:+36`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/server/text_synchronization.go;l=256)
- [`golang.org/x/tools/gopls/internal/server.(*server).DidOpen:+20`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/server/text_synchronization.go;l=114)
- [`golang.org/x/tools/gopls/internal/protocol.serverDispatch:+253`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/protocol/tsserver.go;l=421)
- [`golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/protocol/protocol.go;l=160)
- [`golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:gopls/internal/lsprpc/lsprpc.go;l=509)
- [`golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2`](https://cs.opensource.google/go/x/tools/+/gopls/v0.16.1:internal/jsonrpc2/handler.go;l=35)

```
golang.org/x/tools/gopls@v0.16.1 go1.23.0 linux/amd64 other (1)
```
```
golang.org/x/tools/gopls@v0.15.3 go1.22.2 darwin/arm64 neovim (1)
```

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Dups: LJo3VQ qOsYYQ oVfJVw