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

go/types, types2: avoid infinitely recursive instantiation through method signatures #48703

findleyr opened this issue Sep 30, 2021 · 1 comment


Copy link

@findleyr findleyr commented Sep 30, 2021

We've recently started instantiating methods on instantiated types, to simplify their API. However, this introduces an infinite recursion in cases like this:

package p
type List[P any] struct{}
func (_ List[P]) m() (_ List[List[P]]) { return }

This is similar to #48098, but will require a different fix; we need to allow these types of methods to be written.

I think there is a straightforward fix: we already have a lazy resolution mechanism for Named types, and can use it to expand methods lazily the first time they are accessed (see also #47910). We just need to allow types to escape the type-checking pass with their methods unexpanded, which is a bit subtle.

CC @griesemer

Copy link

@gopherbot gopherbot commented Oct 7, 2021

Change mentions this issue: go/types: only resolve underlying if

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants