go/ssa: fix slice to array ptr conversions for named type

When checking for slice to array ptr conversion, we need to check for
pointer elem underlying type, otherwise, for named type, the conversion
will panic.

This is the same as what cmd/compile and go/types do.

Fixes golang/go#48281

Change-Id: I9c35fd9a73ffd8b02917397c6a79629f63bb049b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/348511
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
diff --git a/go/ssa/emit.go b/go/ssa/emit.go
index 02d0e4b..7c8cfdc 100644
--- a/go/ssa/emit.go
+++ b/go/ssa/emit.go
@@ -231,7 +231,7 @@
 	// Conversion from slice to array pointer?
 	if slice, ok := ut_src.(*types.Slice); ok {
 		if ptr, ok := ut_dst.(*types.Pointer); ok {
-			if arr, ok := ptr.Elem().(*types.Array); ok && types.Identical(slice.Elem(), arr.Elem()) {
+			if arr, ok := ptr.Elem().Underlying().(*types.Array); ok && types.Identical(slice.Elem(), arr.Elem()) {
 				c := &SliceToArrayPointer{X: val}
 				c.setType(ut_dst)
 				return f.emit(c)
diff --git a/go/ssa/interp/testdata/slice2arrayptr.go b/go/ssa/interp/testdata/slice2arrayptr.go
index ad37a18..ff2d9b5 100644
--- a/go/ssa/interp/testdata/slice2arrayptr.go
+++ b/go/ssa/interp/testdata/slice2arrayptr.go
@@ -34,6 +34,13 @@
 	)
 }
 
+type arr [2]int
+
+func f() {
+	s := []int{1, 2, 3, 4}
+	_ = *(*arr)(s)
+}
+
 func wantPanic(fn func(), s string) {
 	defer func() {
 		err := recover()