mirror of
https://github.com/golang/go
synced 2024-11-25 21:28:03 -07:00
9e8ea567c8
Enables V2 unified IR bitstreams when GOEXPERIMENT aliastypeparams are enabled. Allows pkgbits.NewPkgEncoder to set the output version. Reenables support for writing V0 streams. Updates #68778 Updates #68526 Change-Id: I590c494d81ab7db148232ceaba52229068d1e986 Reviewed-on: https://go-review.googlesource.com/c/go/+/608595 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
46 lines
885 B
Go
46 lines
885 B
Go
// 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 (
|
|
"fmt"
|
|
|
|
"issue68526.dir/a"
|
|
)
|
|
|
|
func main() {
|
|
unexported()
|
|
exported()
|
|
}
|
|
|
|
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")
|
|
}
|
|
}
|
|
|
|
func exported() {
|
|
var (
|
|
astr a.A[string]
|
|
aint a.A[int]
|
|
)
|
|
|
|
if any(astr) != any(struct{ F string }{}) || any(aint) != any(struct{ F int }{}) {
|
|
panic("zero value of alias and concrete type not identical")
|
|
}
|
|
|
|
if any(astr) == any(aint) {
|
|
panic("zero value of struct{ F string } and struct{ F int } are not distinct")
|
|
}
|
|
|
|
if got := fmt.Sprintf("%T", astr); got != "struct { F string }" {
|
|
panic(got)
|
|
}
|
|
}
|