Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics are not supported by analyzers #323

Open
chressie opened this issue May 5, 2022 · 0 comments · May be fixed by #325
Open

Generics are not supported by analyzers #323

chressie opened this issue May 5, 2022 · 0 comments · May be fixed by #325
Labels
bug Something isn't working

Comments

@chressie
Copy link

chressie commented May 5, 2022

Bug report

Describe the bug
Generics are not supported by analyzers or helper functions. Most notably the new *types.TypeParam type is not recognized.

To Reproduce

  1. Upgrade x/tools to a recent version (which supports ssa + generics):
go get golang.org/x/tools@v0.1.11-0.20220504225841-45c8a7131235
go mod download github.com/yuin/goldmark 
go get golang.org/x/tools/internal/gocommand@v0.1.11-0.20220504225841-45c8a7131235
  1. Add a generic type with a method to internal/pkg/sourcetype/testdata/test_stackoverflow.go

E.g.

type G[T any]struct{}

func (G[T]) M(_ T) {
}
  1. Run the sourcetype test in verbose mode:
% go test -v ./internal/pkg/sourcetype
=== RUN   TestSourceTypeDoesNotStackOverflow
unexpected type received: *types.TypeParam T; please report this issue
--- PASS: TestSourceTypeDoesNotStackOverflow (0.02s)
PASS
ok  	github.com/google/go-flow-levee/internal/pkg/sourcetype	0.048s

Note the unexpected type received: *types.TypeParam T; please report this issue in the output.

Additional context
n/a

@chressie chressie added the bug Something isn't working label May 5, 2022
chressie added a commit to chressie/go-flow-levee that referenced this issue May 5, 2022
The analyzers (or helpers that the analyzers use) currently do not
support generics. Use the `usesgenerics` analyzer from the x/tools
repository to detect usage of generics and return a synthesized empty
result in that case.

Updates google/issues/323
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant