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

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

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

griesemer opened this issue Jul 11, 2021 · 4 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@griesemer
Copy link
Contributor

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 NeedsFix The path to resolution is known, but the work has not been done. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Jul 11, 2021
@griesemer griesemer added this to the Go1.18 milestone Jul 11, 2021
@griesemer griesemer self-assigned this Jul 11, 2021
@gopherbot gopherbot removed the NeedsFix The path to resolution is known, but the work has not been done. label Jul 11, 2021
@ianlancetaylor
Copy link
Contributor

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

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

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

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

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants