lang: types, engine: graph: Support pointer interfaces

If we have rare, but special *interface{} values in resource structs, we
should be able to handle them normally. It's really not recommended that
you use these unless you know exactly why they are useful.
This commit is contained in:
James Shubin
2023-11-18 13:30:05 -05:00
parent 1c9fdc79c0
commit 4b0cdf9123
3 changed files with 41 additions and 15 deletions

View File

@@ -234,16 +234,28 @@ func ValueOf(v reflect.Value) (Value, error) {
// TODO: should this return a variant value?
// TODO: add this into ConfigurableValueOf like ConfigurableTypeOf ?
//case reflect.Interface:
// t, err := TypeOf(value.Type())
// if err != nil {
// return nil, errwrap.Wrapf(err, "can't determine type of %+v", value)
// }
//
// return &VariantValue{
// T: NewType(?),
// V: ?,
// }, nil
case reflect.Interface:
opts := []TypeOfOption{
//StructTagOpt(StructTag),
//StrictStructTagOpt(false),
//SkipBadStructFieldsOpt(false),
AllowInterfaceTypeOpt(true),
}
t, err := ConfigurableTypeOf(value.Type(), opts...)
//t, err := TypeOf(value.Type())
if err != nil {
return nil, errwrap.Wrapf(err, "can't determine type of %+v", value)
}
v, err := ValueOf(value.Elem()) // recurse
if err != nil {
return nil, errwrap.Wrapf(err, "can't determine value of %+v", value)
}
return &VariantValue{
T: t,
V: v,
}, nil
default:
return nil, fmt.Errorf("unable to represent value of %+v which has kind: %v", v, kind)