diff options
author | LaMont Jones <lamontjones@google.com> | 2024-02-26 20:35:19 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-02-26 20:35:19 +0000 |
commit | 34847c828d7a6ba7253a889a062a3844b6fe06a5 (patch) | |
tree | 7dfb9196f54634505e83e32dff32af47145e9771 | |
parent | 2e39a573ce60c8915560163b99ea8f1d166a19e8 (diff) | |
parent | 89e90b4c60ab2d8f9c953bfcdf7876ab7da44545 (diff) | |
download | blueprint-34847c828d7a6ba7253a889a062a3844b6fe06a5.tar.gz |
debugValue: handle Interfaces better. am: 89e90b4c60
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2975295
Change-Id: Iba23845605d8cdeb400f65cc3da34e4e2239b1d6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | context.go | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -5010,8 +5010,10 @@ func debugKey(value reflect.Value) string { // Convert a single value (possibly a map or slice too) in a reflect.Value to a value suitable for outputting to json func debugValue(value reflect.Value) interface{} { + // Remember if we originally received a reflect.Interface. + wasInterface := value.Kind() == reflect.Interface // Dereference pointers down to the real type - for value.Kind() == reflect.Ptr { + for value.Kind() == reflect.Ptr || value.Kind() == reflect.Interface { // If it's nil, return nil if value.IsNil() { return nil @@ -5030,13 +5032,17 @@ func debugValue(value reflect.Value) interface{} { case reflect.Slice: return debugSlice(value) case reflect.Struct: + // If we originally received an interface, and there is a String() method, call that. + // TODO: figure out why Path doesn't work correctly otherwise (in aconfigPropagatingDeclarationsInfo) + if s, ok := value.Interface().(interface{ String() string }); wasInterface && ok { + return s.String() + } return debugStruct(value) case reflect.Map: return debugMap(value) - case reflect.Interface: - // ??? default: - // ??? + // TODO: add cases as we find them. + return fmt.Sprintf("debugValue(Kind=%v, wasInterface=%v)", kind, wasInterface) } return nil |