w.expr(n.X)
w.typ(n.Type())
+ case ir.ODYNAMICDOTTYPE, ir.ODYNAMICDOTTYPE2:
+ n := n.(*ir.DynamicTypeAssertExpr)
+ w.op(n.Op())
+ w.pos(n.Pos())
+ w.expr(n.X)
+ w.expr(n.T)
+ w.typ(n.Type())
+
case ir.OINDEX, ir.OINDEXMAP:
n := n.(*ir.IndexExpr)
if go117ExportTypes {
}
return n
+ case ir.ODYNAMICDOTTYPE, ir.ODYNAMICDOTTYPE2:
+ n := ir.NewDynamicTypeAssertExpr(r.pos(), op, r.expr(), r.expr())
+ n.SetType(r.typ())
+ return n
+
case ir.OINDEX, ir.OINDEXMAP:
n := ir.NewIndexExpr(r.pos(), r.expr(), r.expr())
if go117ExportTypes {
--- /dev/null
+// Copyright 2021 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 a
+
+func Conv(v interface{}) string {
+ return conv[string](v)
+}
+
+func conv[T any](v interface{}) T {
+ return v.(T)
+}
+
+func Conv2(v interface{}) (string, bool) {
+ return conv2[string](v)
+}
+func conv2[T any](v interface{}) (T, bool) {
+ x, ok := v.(T)
+ return x, ok
+}
--- /dev/null
+// Copyright 2021 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
+
+import (
+ "a"
+ "fmt"
+)
+
+func main() {
+ s := "foo"
+ x := a.Conv(s)
+ if x != s {
+ panic(fmt.Sprintf("got %s wanted %s", x, s))
+ }
+ y, ok := a.Conv2(s)
+ if !ok {
+ panic("conversion failed")
+ }
+ if y != s {
+ panic(fmt.Sprintf("got %s wanted %s", y, s))
+ }
+}
--- /dev/null
+// rundir -G=3
+
+// Copyright 2021 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 ignored