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

View file

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