From f5f4751088bd40a8680899eefeb9854c8dbf4b33 Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Thu, 1 Jun 2023 10:41:36 -0700 Subject: compiler,transform: fix for pointer-to-pointer type switches from @aykevl --- testdata/interface.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'testdata/interface.go') 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??") + } +} -- cgit v1.2.3