diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-02 01:00:25 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-02 01:00:25 +0000 |
commit | 720d259420c200bfe72f61c21500f7b653dcf1d8 (patch) | |
tree | 21a4959f8ee9d152740bb5748d0bff61cc3718af | |
parent | fedbcd706dcc98eeaf8396d57de22689ecbb2570 (diff) | |
parent | 1c481010918fe0e5a608b97df0536f2dd65efbde (diff) | |
download | blueprint-sdk-release.tar.gz |
Snap for 11790536 from 1c481010918fe0e5a608b97df0536f2dd65efbde to sdk-releasesdk-release
Change-Id: Iea780108928a4d0c342ee5319790a64410fa0cf9
-rw-r--r-- | proptools/unpack.go | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/proptools/unpack.go b/proptools/unpack.go index dd0f119..1b48a61 100644 --- a/proptools/unpack.go +++ b/proptools/unpack.go @@ -534,20 +534,18 @@ func (ctx *unpackContext) unpackToConfigurable(propertyName string, property *pa } } -func (ctx *unpackContext) reportSelectOnNonConfigurablePropertyError( - property *parser.Property, -) bool { +// If the given property is a select, returns an error saying that you can't assign a select to +// a non-configurable property. Otherwise returns nil. +func selectOnNonConfigurablePropertyError(property *parser.Property) error { if _, ok := property.Value.Eval().(*parser.Select); !ok { - return false + return nil } - ctx.addError(&UnpackError{ + return &UnpackError{ fmt.Errorf("can't assign select statement to non-configurable property %q. This requires a small soong change to enable in most cases, please file a go/soong-bug if you'd like to use a select statement here", property.Name), property.Value.Pos(), - }) - - return true + } } // unpackSlice creates a value of a given slice or pointer to slice type from the property, @@ -574,7 +572,9 @@ func (ctx *unpackContext) unpackToSliceInner( sliceName string, property *parser.Property, sliceType reflect.Type) (reflect.Value, bool) { propValueAsList, ok := property.Value.Eval().(*parser.List) if !ok { - if !ctx.reportSelectOnNonConfigurablePropertyError(property) { + if err := selectOnNonConfigurablePropertyError(property); err != nil { + ctx.addError(err) + } else { ctx.addError(&UnpackError{ fmt.Errorf("can't assign %s value to list property %q", property.Value.Type(), property.Name), @@ -659,10 +659,14 @@ func propertyToValue(typ reflect.Type, property *parser.Property) (reflect.Value case reflect.Bool: b, ok := property.Value.Eval().(*parser.Bool) if !ok { - return value, &UnpackError{ - fmt.Errorf("can't assign %s value to bool property %q", - property.Value.Type(), property.Name), - property.Value.Pos(), + if err := selectOnNonConfigurablePropertyError(property); err != nil { + return value, err + } else { + return value, &UnpackError{ + fmt.Errorf("can't assign %s value to bool property %q", + property.Value.Type(), property.Name), + property.Value.Pos(), + } } } value = reflect.ValueOf(b.Value) @@ -681,10 +685,14 @@ func propertyToValue(typ reflect.Type, property *parser.Property) (reflect.Value case reflect.String: s, ok := property.Value.Eval().(*parser.String) if !ok { - return value, &UnpackError{ - fmt.Errorf("can't assign %s value to string property %q", - property.Value.Type(), property.Name), - property.Value.Pos(), + if err := selectOnNonConfigurablePropertyError(property); err != nil { + return value, err + } else { + return value, &UnpackError{ + fmt.Errorf("can't assign %s value to string property %q", + property.Value.Type(), property.Name), + property.Value.Pos(), + } } } value = reflect.ValueOf(s.Value) |