]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: ensure we have an interface before checking constraints
authorRobert Griesemer <gri@golang.org>
Mon, 7 Feb 2022 19:28:14 +0000 (11:28 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 7 Feb 2022 21:00:02 +0000 (21:00 +0000)
commit7db75b368d4599e02b065f48b6ca8675b658b928
tree57ab87348e91cc786afce56462ae44073263078a
parent49030c87e02c02f9b3ad812e4d447c4f1e39d745
go/types, types2: ensure we have an interface before checking constraints

Due to delayed computation of constraint type sets it is possible that
a type argument is checked against a constraint before that constraint
has been wrapped into an implicit interface (if needed).

When the type checker is about to check whether a type argument
implements a constraint, it's always safe to force wrapping of
a constraint in an implicit interface (if necessary) before doing
the implements check.

Also, use a better position for tracing output related to constraint
type set computation.

Fixes #51048.

Change-Id: I52fecbf57814f09b62762452d7e17c2a230fdd59
Reviewed-on: https://go-review.googlesource.com/c/go/+/383834
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51048.go2 [new file with mode: 0644]
src/cmd/compile/internal/types2/typeparam.go
src/go/types/instantiate.go
src/go/types/testdata/fixedbugs/issue51048.go2 [new file with mode: 0644]
src/go/types/typeparam.go