mirror of https://github.com/golang/go.git
go/types, types2: coreType/String must consider Alias types
Fixes regression from Go 1.22. For #67547. Change-Id: Idd319b9d2a73c824caa2c821df0e2fcd4f58cb08 Reviewed-on: https://go-review.googlesource.com/c/go/+/587176 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
814e72f2ef
commit
4b778470f8
|
|
@ -22,6 +22,7 @@ func under(t Type) Type {
|
|||
// identical element types), the single underlying type is the restricted
|
||||
// channel type if the restrictions are always the same, or nil otherwise.
|
||||
func coreType(t Type) Type {
|
||||
t = Unalias(t)
|
||||
tpar, _ := t.(*TypeParam)
|
||||
if tpar == nil {
|
||||
return under(t)
|
||||
|
|
@ -51,6 +52,7 @@ func coreType(t Type) Type {
|
|||
// and strings as identical. In this case, if successful and we saw
|
||||
// a string, the result is of type (possibly untyped) string.
|
||||
func coreString(t Type) Type {
|
||||
t = Unalias(t)
|
||||
tpar, _ := t.(*TypeParam)
|
||||
if tpar == nil {
|
||||
return under(t) // string or untyped string
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ func under(t Type) Type {
|
|||
// identical element types), the single underlying type is the restricted
|
||||
// channel type if the restrictions are always the same, or nil otherwise.
|
||||
func coreType(t Type) Type {
|
||||
t = Unalias(t)
|
||||
tpar, _ := t.(*TypeParam)
|
||||
if tpar == nil {
|
||||
return under(t)
|
||||
|
|
@ -54,6 +55,7 @@ func coreType(t Type) Type {
|
|||
// and strings as identical. In this case, if successful and we saw
|
||||
// a string, the result is of type (possibly untyped) string.
|
||||
func coreString(t Type) Type {
|
||||
t = Unalias(t)
|
||||
tpar, _ := t.(*TypeParam)
|
||||
if tpar == nil {
|
||||
return under(t) // string or untyped string
|
||||
|
|
|
|||
|
|
@ -8,3 +8,15 @@ func _[P int]() {
|
|||
type A = P
|
||||
_ = A(0) // don't crash with this conversion
|
||||
}
|
||||
|
||||
func _[P []int]() {
|
||||
type A = P
|
||||
_ = make(A, 10) // don't report an error for A
|
||||
}
|
||||
|
||||
func _[P string]() {
|
||||
var t []byte
|
||||
type A = P
|
||||
var s A
|
||||
copy(t, s) // don't report an error for s
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue