@@ -615,6 +615,24 @@ type myErrorStringer struct{}
615615func (myErrorStringer ) Error () string { return "err" }
616616func (myErrorStringer ) String () string { return "str" }
617617
618+ // Interface with unexported method (from upstream set_test.go).
619+ type exprLike interface {
620+ Pos () int
621+ End () int
622+ exprNode ()
623+ }
624+
625+ type notAnExpr struct {}
626+
627+ func (notAnExpr ) Pos () int { return 0 }
628+ func (notAnExpr ) End () int { return 0 }
629+ func (notAnExpr ) exprNode () {}
630+
631+ // Named types for assignability tests (from upstream set_test.go).
632+ type IntPtr * int
633+ type IntPtr1 * int
634+ type Ch <- chan interface {}
635+
618636func testImplements () {
619637 readerType := reflect .TypeOf ((* Reader )(nil )).Elem ()
620638 writerType := reflect .TypeOf ((* Writer )(nil )).Elem ()
@@ -710,6 +728,25 @@ func testImplements() {
710728 println ("int → interface{}:" , reflect .TypeOf (0 ).AssignableTo (emptyItf )) // true
711729 println ("Reader → interface{}:" , readerType .AssignableTo (emptyItf )) // true
712730
731+ // --- Upstream set_test.go: unexported method interfaces ---
732+ println ("unexported method interface:" )
733+ exprType := reflect .TypeOf ((* exprLike )(nil )).Elem ()
734+ println ("*notAnExpr → exprLike:" , reflect .TypeOf (new (notAnExpr )).Implements (exprType )) // true
735+ println ("notAnExpr → exprLike:" , reflect .TypeOf (notAnExpr {}).Implements (exprType )) // true
736+ println ("*notAnExpr → exprLike (AssignableTo):" , reflect .TypeOf (new (notAnExpr )).AssignableTo (exprType )) // true
737+
738+ // --- Upstream set_test.go: channel direction assignability ---
739+ println ("channel direction:" )
740+ println ("chan int → <-chan int:" , reflect .TypeOf (make (chan int )).AssignableTo (reflect .TypeOf (make (<- chan int )))) // true
741+ println ("<-chan int → chan int:" , reflect .TypeOf (make (<- chan int )).AssignableTo (reflect .TypeOf (make (chan int )))) // false
742+
743+ // --- Upstream set_test.go: named type assignability ---
744+ println ("named types:" )
745+ println ("*int → IntPtr:" , reflect .TypeOf (new (int )).AssignableTo (reflect .TypeOf (IntPtr (nil )))) // true
746+ println ("IntPtr → *int:" , reflect .TypeOf (IntPtr (nil )).AssignableTo (reflect .TypeOf (new (int )))) // true
747+ println ("IntPtr → IntPtr1:" , reflect .TypeOf (IntPtr (nil )).AssignableTo (reflect .TypeOf (IntPtr1 (nil )))) // false
748+ println ("Ch → <-chan interface{}:" , reflect .TypeOf (Ch (nil )).AssignableTo (reflect .TypeOf (make (<- chan interface {})))) // true
749+
713750 // --- reflect.Value.Set with interface (issue #4277) ---
714751 println ("value set interface:" )
715752 type Node interface { node () }
0 commit comments