reflect: implement CanInterface and fix string Index()

This commit fixes two related issues:

 1. CanInterface was unimplemented. It now uses the same check as is
    used in Interface() itself.
    This issue led to https://github.com/tinygo-org/tinygo/issues/3033
 2. Allow making an interface out of a string char element.

Doing this in one commit (instead of two) because they are shown to be
correct with the same tests.
This commit is contained in:
Ayke van Laethem
2022-08-31 22:33:28 +02:00
committed by Ron Evans
parent edaf13f951
commit e955aa1941
3 changed files with 22 additions and 16 deletions
+3
View File
@@ -415,6 +415,9 @@ func showValue(rv reflect.Value, indent string) {
if rv.CanAddr() {
print(" addrable=true")
}
if !rv.CanInterface() {
print(" caninterface=false")
}
if !rt.Comparable() {
print(" comparable=false")
}