From 25607568d407cc6c31f0558091964c124fac2aeb Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 26 May 2023 15:52:12 -0400 Subject: [PATCH] Fix Java header generation for attributes with nullable list type. (#26880) --- .../matter_idl/generators/java/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py index b420968f76382d..8f376704c4bd3b 100644 --- a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py @@ -166,11 +166,17 @@ def _CppType(field: Field, context: TypeLookupContext) -> str: def DecodableJniType(field: Field, context: TypeLookupContext) -> str: actual = _CppType(field, context) + needsConstRef = False if field.is_list: - return f"const chip::app::DataModel::DecodableList<{actual}> &" + needsConstRef = True + actual = f"chip::app::DataModel::DecodableList<{actual}>" if field.is_nullable: - return f"const chip::app::DataModel::Nullable<{actual}> &" + needsConstRef = True + actual = f"chip::app::DataModel::Nullable<{actual}>" + + if needsConstRef: + actual = f"const {actual} &" return actual