var typeWord ir.Node
if toType.IsEmptyInterface() {
- // Implement interface to empty interface conversion.
- // res = itab
+ // Implement interface to empty interface conversion:
+ //
+ // var res *uint8
+ // res = (*uint8)(unsafe.Pointer(itab))
// if res != nil {
// res = res.type
// }
typeWord = typecheck.Temp(types.NewPtr(types.Types[types.TUINT8]))
- init.Append(ir.NewAssignStmt(base.Pos, typeWord, itab))
+ init.Append(ir.NewAssignStmt(base.Pos, typeWord, typecheck.Conv(typecheck.Conv(itab, types.Types[types.TUNSAFEPTR]), typeWord.Type())))
nif := ir.NewIfStmt(base.Pos, typecheck.Expr(ir.NewBinaryExpr(base.Pos, ir.ONE, typeWord, typecheck.NodNil())), nil, nil)
nif.Body = []ir.Node{ir.NewAssignStmt(base.Pos, typeWord, itabType(typeWord))}
init.Append(nif)
--- /dev/null
+// 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 p
+
+type I interface {
+ M()
+}
+
+type slice []any
+
+func f() {
+ ss := struct{ i I }{}
+
+ _ = [...]struct {
+ s slice
+ }{
+ {
+ s: slice{ss.i},
+ },
+ {
+ s: slice{ss.i},
+ },
+ {
+ s: slice{ss.i},
+ },
+ {
+ s: slice{ss.i},
+ },
+ {
+ s: slice{ss.i},
+ },
+ }
+}