diff options
author | Wayne Zuo <wdvxdr@golangcn.org> | 2022-07-10 11:11:05 +0800 |
---|---|---|
committer | Heschi Kreinick <heschi@google.com> | 2022-07-13 16:06:45 +0000 |
commit | 923740a8cc82e0bd3cd6098f94130b1967c4b361 (patch) | |
tree | 33d4d356182014f460fd129f591886d5e05661df /test/typeparam | |
parent | bf2ef26be3593d24487311576d85ec601185fbf4 (diff) | |
download | go-923740a8cc82e0bd3cd6098f94130b1967c4b361.tar.gz go-923740a8cc82e0bd3cd6098f94130b1967c4b361.zip |
cmd/compile: fix type assert in dict pass
For type assertions, if src type is empty interface, we should
use normal type assertions rather than dynamic type assertions.
Fixes #53762
Change-Id: I596b2e4ad647fe5e42ad884f7273c78f8f50dac2
Reviewed-on: https://go-review.googlesource.com/c/go/+/416736
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'test/typeparam')
-rw-r--r-- | test/typeparam/issue53762.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/typeparam/issue53762.go b/test/typeparam/issue53762.go new file mode 100644 index 0000000000..4d95988854 --- /dev/null +++ b/test/typeparam/issue53762.go @@ -0,0 +1,18 @@ +// compile + +// 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 main + +type Value[T any] interface { +} + +func use[T any](v Value[T]) { + _, _ = v.(int) +} + +func main() { + use(Value[int](1)) +} |