From 46492009a1e07d14230007dc2887abb11d16b141 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 14 Dec 2024 10:05:26 +0800 Subject: [PATCH] internal/lib/reflect: specialChannelAssignability --- runtime/internal/lib/reflect/type.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/runtime/internal/lib/reflect/type.go b/runtime/internal/lib/reflect/type.go index 4df7b4fb..669d4c15 100644 --- a/runtime/internal/lib/reflect/type.go +++ b/runtime/internal/lib/reflect/type.go @@ -944,14 +944,11 @@ func implements(T, V *abi.Type) bool // https://golang.org/doc/go_spec.html#Assignability // T and V must be both of Chan kind. func specialChannelAssignability(T, V *abi.Type) bool { - /* - // Special case: - // x is a bidirectional channel value, T is a channel type, - // x's type V and T have identical element types, - // and at least one of V or T is not a defined type. - return V.ChanDir() == abi.BothDir && (nameFor(T) == "" || nameFor(V) == "") && haveIdenticalType(T.Elem(), V.Elem(), true) - */ - panic("todo: reflect.specialChannelAssignability") + // Special case: + // x is a bidirectional channel value, T is a channel type, + // x's type V and T have identical element types, + // and at least one of V or T is not a defined type. + return V.ChanDir() == abi.BothDir && (nameFor(T) == "" || nameFor(V) == "") && haveIdenticalType(T.Elem(), V.Elem(), true) } // directlyAssignable reports whether a value x of type V can be directly