-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-branch.go1.18] go/types, types2: pointer base types cannot b…
…e type constraints Pointer types may appear in expressions *P and we don't know if we have an indirection (P is a pointer value) or a pointer type (P is a type) until we type-check P. Don't forget to check that a type P must be an ordinary (not a constraint) type in this special case. Fixes #51578. Change-Id: If782cc6dd2a602a498574c78c99e40c3b72274a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/391275 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 3a5e3d8) Reviewed-on: https://go-review.googlesource.com/c/go/+/391357 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
- Loading branch information
Showing
6 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51578.go2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package p | ||
|
||
var _ = (*interface /* ERROR interface contains type constraints */ {int})(nil) | ||
|
||
// abbreviated test case from issue | ||
|
||
type TypeSet interface{ int | string } | ||
|
||
func _() { | ||
f((*TypeSet /* ERROR interface contains type constraints */)(nil)) | ||
} | ||
|
||
func f(any) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package p | ||
|
||
var _ = (*interface /* ERROR interface contains type constraints */ {int})(nil) | ||
|
||
// abbreviated test case from issue | ||
|
||
type TypeSet interface{ int | string } | ||
|
||
func _() { | ||
f((*TypeSet /* ERROR interface contains type constraints */)(nil)) | ||
} | ||
|
||
func f(any) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters