mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
d3672054fb
This CL is a bit overkill, but it is pretty safe for 1.18. We'll want to revisit for 1.19 so we can avoid the hash collisions between types, e.g. G[int] and G[float64], that will cause some slowdowns (but not incorrect behavior). Thanks Cherry for the simple idea. Fixes #51250 Change-Id: I68130e09ba68e7cc35687bc623f63547bc552867 Reviewed-on: https://go-review.googlesource.com/c/go/+/389474 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
25 lines
397 B
Go
25 lines
397 B
Go
// Copyright 2022 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 b
|
|
|
|
import "./a"
|
|
|
|
type T struct { a int }
|
|
|
|
var I interface{} = a.G[T]{}
|
|
|
|
//go:noinline
|
|
func F(x interface{}) {
|
|
switch x.(type) {
|
|
case a.G[T]:
|
|
case int:
|
|
panic("bad")
|
|
case float64:
|
|
panic("bad")
|
|
default:
|
|
panic("bad")
|
|
}
|
|
}
|