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: handle embedding of type parameters correctly #47127

Open
griesemer opened this issue Jul 11, 2021 · 4 comments
Open

go/types, types2: handle embedding of type parameters correctly #47127

griesemer opened this issue Jul 11, 2021 · 4 comments
Assignees
Milestone

Comments

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jul 11, 2021

package p

func _[E1 interface{ m() E1 }, E2 interface{ E1 } ](c1 chan E1, c2 chan E2) {
        x1 := (<-c1).m()
        x2 := (<-c2).m()
        _ = x1
        _ = x2
}

produces

(<-c2).m undefined (type bound for E2 has no method m)

This should either be permitted or embedding of E1 in the E2 constraint should be explicitly forbidden.

cc: @findleyr

@griesemer griesemer added this to the Go1.18 milestone Jul 11, 2021
@griesemer griesemer self-assigned this Jul 11, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 13, 2021

I thought we had agreed to not support embedding of plain type parameters, and to only support embedding of type literals that refer to type parameters. Am I misremembering?

@griesemer griesemer changed the title go/types, types2: implement embedding of type parameters correctly go/types, types2: handle embedding of type parameters correctly Jul 13, 2021
@griesemer
Copy link
Contributor Author

@griesemer griesemer commented Jul 13, 2021

I believe you're correct. Yesterday I filed whatever looked like it needed attention. Clearly this needs attention as in: report an error at the embedding location.

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 13, 2021

Change https://golang.org/cl/334151 mentions this issue: [dev.typeparams] cmd/compile/internal/types2: embedding stand-alone type parameters is not permitted

gopherbot pushed a commit that referenced this issue Jul 14, 2021
…ype parameters is not permitted

For #47127.

Change-Id: Ie979ff56ae7c2dd0e5ce0ff39588f98ae68b5ee9
Reviewed-on: https://go-review.googlesource.com/c/go/+/334151
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@gopherbot
Copy link

@gopherbot gopherbot commented Jul 17, 2021

Change https://golang.org/cl/335082 mentions this issue: [dev.typeparams] go/types: embedding stand-alone type parameters is not permitted

gopherbot pushed a commit that referenced this issue Jul 19, 2021
…ot permitted

This is a port of CL 334151 to go/types.

Fixes #47127

Change-Id: I57d69c498d2649a9e1657559e4c0271333096c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/335082
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants