reflect: fix AssignableTo and Implements methods

They both reversed the direction of the check, in a way that mostly
cancelled each other out. Of course they're still mostly unimplemented,
but it's better if they're not wrong.
Этот коммит содержится в:
Ayke van Laethem 2021-03-23 12:24:45 +01:00 коммит произвёл Ron Evans
родитель 1406453350
коммит e9f9a4b750

Просмотреть файл

@ -609,23 +609,23 @@ func (t rawType) FieldAlign() int {
return t.Align() return t.Align()
} }
// AssignableTo returns whether a value of type u can be assigned to a variable // AssignableTo returns whether a value of type t can be assigned to a variable
// of type t. // of type u.
func (t rawType) AssignableTo(u Type) bool { func (t rawType) AssignableTo(u Type) bool {
if t == u.(rawType) { if t == u.(rawType) {
return true return true
} }
if t.Kind() == Interface { if u.Kind() == Interface {
panic("reflect: unimplemented: assigning to interface of different type") panic("reflect: unimplemented: AssignableTo with interface")
} }
return false return false
} }
func (t rawType) Implements(u Type) bool { func (t rawType) Implements(u Type) bool {
if t.Kind() != Interface { if u.Kind() != Interface {
panic("reflect: non-interface type passed to Type.Implements") panic("reflect: non-interface type passed to Type.Implements")
} }
return u.AssignableTo(t) return t.AssignableTo(u)
} }
// Comparable returns whether values of this type can be compared to each other. // Comparable returns whether values of this type can be compared to each other.