Avoid aliasing *Output when possible

This commit is contained in:
joeduffy 2018-06-10 11:54:11 -07:00
parent 48ddf5b3b0
commit f1aec12df2
2 changed files with 5 additions and 5 deletions

View file

@ -157,10 +157,9 @@ func marshalInput(v interface{}) (interface{}, []Resource, error) {
return obj, deps, nil
case reflect.Ptr:
// See if this is an alias for *Output. If so, convert to an *Output, and recurse.
e := rv.Elem()
ot := reflect.TypeOf(Output{})
if e.Type().ConvertibleTo(ot) {
oo := e.Convert(ot)
ot := reflect.TypeOf(&Output{})
if rv.Type().ConvertibleTo(ot) {
oo := rv.Convert(ot)
return marshalInput(oo.Interface())
}
@ -168,7 +167,7 @@ func marshalInput(v interface{}) (interface{}, []Resource, error) {
if rv.IsNil() {
return nil, nil, nil
}
return marshalInput(e.Interface())
return marshalInput(rv.Elem().Interface())
case reflect.String:
return marshalInput(rv.String())
}

View file

@ -73,6 +73,7 @@ func RunErr(body RunFunc) error {
if err != nil {
return err
}
contract.Assertf(ctx.stackR != "", "expected root stack resource to have a non-empty URN")
// Execute the body.
var result error