mirror of
https://github.com/golang/go.git
synced 2025-11-10 13:41:05 +00:00
Using type aliases, it's possible to create structs with embedded
fields that have no corresponding type literal notation. However, we
still need to generate a unique name for these types to use for linker
symbols. This CL introduces a new "struct{ Name = Type }" syntax for
use in LinkString formatting to represent these types.
Reattempt at CL 372914, which was rolled back due to race-y
LocalPkg.Lookup call that isn't safe for concurrency.
Fixes #50190.
Change-Id: I0b7fd81e1b0b3199a6afcffde96ade42495ad8d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/378434
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
31 lines
446 B
Go
31 lines
446 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
|
|
|
|
type Int = int
|
|
|
|
type A = struct{ int }
|
|
type B = struct{ Int }
|
|
|
|
func main() {
|
|
var x, y interface{} = A{}, B{}
|
|
if x == y {
|
|
panic("FAIL")
|
|
}
|
|
|
|
{
|
|
type C = int32
|
|
x = struct{ C }{}
|
|
}
|
|
{
|
|
type C = uint32
|
|
y = struct{ C }{}
|
|
}
|
|
if x == y {
|
|
panic("FAIL")
|
|
}
|
|
}
|