mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
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.
This commit is contained in:
committed by
Ron Evans
parent
1406453350
commit
e9f9a4b750
+6
-6
@@ -609,23 +609,23 @@ func (t rawType) FieldAlign() int {
|
||||
return t.Align()
|
||||
}
|
||||
|
||||
// AssignableTo returns whether a value of type u can be assigned to a variable
|
||||
// of type t.
|
||||
// AssignableTo returns whether a value of type t can be assigned to a variable
|
||||
// of type u.
|
||||
func (t rawType) AssignableTo(u Type) bool {
|
||||
if t == u.(rawType) {
|
||||
return true
|
||||
}
|
||||
if t.Kind() == Interface {
|
||||
panic("reflect: unimplemented: assigning to interface of different type")
|
||||
if u.Kind() == Interface {
|
||||
panic("reflect: unimplemented: AssignableTo with interface")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (t rawType) Implements(u Type) bool {
|
||||
if t.Kind() != Interface {
|
||||
if u.Kind() != Interface {
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user