Skip to content

Commit

Permalink
Convert values to Starlark values when concating string_list_dict
Browse files Browse the repository at this point in the history
type.

This is because Dict checks that all the values put in it are Starlark
valid values. But string_list_dict value is of type List<String>, when
Java's List isn't a Starlark value.

Fixes #23065
  • Loading branch information
lior10r committed Aug 30, 2024
1 parent 39481ad commit 9be44a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,11 @@ public Object copyAndLiftStarlarkValue(

@Override
public Map<KeyT, ValueT> concat(Iterable<Map<KeyT, ValueT>> iterable) {
Dict.Builder<KeyT, ValueT> output = new Dict.Builder<>();
ImmutableMap.Builder<KeyT, ValueT> builder = ImmutableMap.builder();
for (Map<KeyT, ValueT> map : iterable) {
output.putAll(map);
builder.putAll(map);
}
return output.buildImmutable();
return builder.buildKeepingLast();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ public void testStringListDict() throws Exception {
assertThat(converted).isEqualTo(expected);
assertThat(converted).isNotSameInstanceAs(expected);
assertThat(collectLabels(Types.STRING_LIST_DICT, converted)).isEmpty();

assertThat(Types.STRING_LIST_DICT.concat(Arrays.asList(converted)))
.isEqualTo(expected);
}

@Test
Expand Down

0 comments on commit 9be44a8

Please sign in to comment.