mce := m.(*ir.ConvExpr)
// Note: x's argument is still typed as a type parameter.
// m's argument now has an instantiated type.
- if mce.X.Type().HasShape() || m.Type().HasShape() {
+ if mce.X.Type().HasShape() || (m.Type().HasShape() && !m.Type().IsEmptyInterface()) {
m = convertUsingDictionary(info, info.dictParam, m.Pos(), mce.X, m, m.Type())
}
case ir.ODOTTYPE, ir.ODOTTYPE2:
// instantiated node of the CONVIFACE node or XDOT node (for a bound method call) that is causing the
// conversion.
func convertUsingDictionary(info *instInfo, dictParam *ir.Name, pos src.XPos, v ir.Node, in ir.Node, dst *types.Type) ir.Node {
- assert(v.Type().HasShape() || in.Type().HasShape())
+ assert(v.Type().HasShape() || (in.Type().HasShape() && !in.Type().IsEmptyInterface()))
assert(dst.IsInterface())
if v.Type().IsInterface() {
--- /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 main
+
+type Interface[T any] interface {
+}
+
+func F[T any]() Interface[T] {
+ var i int
+ return i
+}
+
+func main() {
+ F[int]()
+}