build: Fix bp2build panic issue
panic in top down mutator "bp2build_conversion_bp2build"
for module "foo".
reflect: call of reflect.Value.NumField on interface Value
Test: go test ./bp2build
Change-Id: I9ee460ca38a37c6a6c1a0787159fa5f38b852b55
diff --git a/android/variable.go b/android/variable.go
index 3832fcf..77888e5 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -848,6 +848,9 @@
// indirections to extract the struct from the reflect.Value.
if v, ok := maybeExtractConfigVarProp(variableStruct); ok {
variableStruct = v
+ } else if !v.IsValid() {
+ // Skip invalid variables which may not used, else leads to panic
+ continue
}
for j := 0; j < variableStruct.NumField(); j++ {