From 2b7bc233cddd49ec8d8dd383e9c87b9676216b2f Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 26 May 2023 10:47:14 -0400 Subject: [PATCH] Fix Java header generation for attributes with nullable list type. --- .../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