mirror of
https://github.com/golang/go
synced 2024-11-22 14:15:05 -07:00
b24ec88bb9
This CL changes the compiler's type import/export logic to create and preserve materialized Alias types when GODEBUG=gotypesaliases=1. In conjunction with CL 574717, it allows the x/tools tests to pass with GODEBUG=gotypesaliases=1. Updates #65294 Updates #64581 Fixes #66550 Change-Id: I70b9279f4e0ae7a1f95ad153c4e6909a878915a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/574737 Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
51 lines
801 B
Go
51 lines
801 B
Go
// run
|
|
|
|
// Copyright 2021 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 main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type E[T any] struct {
|
|
v T
|
|
}
|
|
|
|
type S1 struct {
|
|
E[int]
|
|
v string
|
|
}
|
|
|
|
type Eint = E[int]
|
|
type Ebool = E[bool]
|
|
type Eint2 = Eint
|
|
|
|
type S2 struct {
|
|
Eint
|
|
Ebool
|
|
v string
|
|
}
|
|
|
|
type S3 struct {
|
|
*E[int]
|
|
}
|
|
|
|
func main() {
|
|
s1 := S1{Eint{2}, "foo"}
|
|
if got, want := s1.E.v, 2; got != want {
|
|
panic(fmt.Sprintf("got %d, want %d", got, want))
|
|
}
|
|
s2 := S2{Eint{3}, Ebool{true}, "foo"}
|
|
if got, want := s2.Eint.v, 3; got != want {
|
|
panic(fmt.Sprintf("got %d, want %d", got, want))
|
|
}
|
|
var s3 S3
|
|
s3.E = &Eint{4}
|
|
if got, want := s3.E.v, 4; got != want {
|
|
panic(fmt.Sprintf("got %d, want %d", got, want))
|
|
}
|
|
}
|