aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/interface.go
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/interface.go')
-rw-r--r--testdata/interface.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/testdata/interface.go b/testdata/interface.go
index 7820538a4..72cc76bce 100644
--- a/testdata/interface.go
+++ b/testdata/interface.go
@@ -113,6 +113,9 @@ func main() {
println("slept 1ms")
blockStatic(SleepBlocker(time.Millisecond))
println("slept 1ms")
+
+ // check that pointer-to-pointer type switches work
+ ptrptrswitch()
}
func printItf(val interface{}) {
@@ -312,3 +315,22 @@ func namedptr2() interface{} {
type Test byte
return (*Test)(nil)
}
+
+func ptrptrswitch() {
+ identify(0)
+ identify(new(int))
+ identify(new(*int))
+}
+
+func identify(itf any) {
+ switch itf.(type) {
+ case int:
+ println("type is int")
+ case *int:
+ println("type is *int")
+ case **int:
+ println("type is **int")
+ default:
+ println("other type??")
+ }
+}