2024-08-09 14:32:12 -06:00
|
|
|
// Copyright 2024 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.
|
|
|
|
|
|
|
|
//go:build goexperiment.aliastypeparams
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-08-26 16:49:09 -06:00
|
|
|
"fmt"
|
|
|
|
|
2024-08-09 14:32:12 -06:00
|
|
|
"issue68526.dir/a"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
unexported()
|
2024-08-26 16:49:09 -06:00
|
|
|
exported()
|
2024-08-09 14:32:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func unexported() {
|
|
|
|
var want struct{ F int }
|
|
|
|
|
|
|
|
if any(want) != any(a.B{}) || any(want) != any(a.F()) {
|
|
|
|
panic("zero value of alias and concrete type not identical")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-26 16:49:09 -06:00
|
|
|
func exported() {
|
|
|
|
var (
|
|
|
|
astr a.A[string]
|
|
|
|
aint a.A[int]
|
|
|
|
)
|
2024-08-09 14:32:12 -06:00
|
|
|
|
2024-08-26 16:49:09 -06:00
|
|
|
if any(astr) != any(struct{ F string }{}) || any(aint) != any(struct{ F int }{}) {
|
|
|
|
panic("zero value of alias and concrete type not identical")
|
|
|
|
}
|
2024-08-09 14:32:12 -06:00
|
|
|
|
2024-08-26 16:49:09 -06:00
|
|
|
if any(astr) == any(aint) {
|
|
|
|
panic("zero value of struct{ F string } and struct{ F int } are not distinct")
|
|
|
|
}
|
2024-08-09 14:32:12 -06:00
|
|
|
|
2024-08-26 16:49:09 -06:00
|
|
|
if got := fmt.Sprintf("%T", astr); got != "struct { F string }" {
|
|
|
|
panic(got)
|
|
|
|
}
|
|
|
|
}
|