Skip to content

Commit

Permalink
Create custom serialization codec for StarlarkInfoWithSchema and `S…
Browse files Browse the repository at this point in the history
…tarlarkProvider`.

PiperOrigin-RevId: 586048899
Change-Id: Id9c6b92641e9ab4fedc0396ef531d57bc723449d
  • Loading branch information
Googler authored and copybara-github committed Nov 28, 2023
1 parent d35961e commit abd481d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.skyframe.serialization.VisibleForSerialization;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -43,8 +44,8 @@ public class StarlarkInfoWithSchema extends StarlarkInfo {
private final Object[] table;

// `table` elements should already be optimized by caller, see StarlarkProvider#optimizeField
private StarlarkInfoWithSchema(
StarlarkProvider provider, Object[] table, @Nullable Location loc) {
@VisibleForSerialization // private
StarlarkInfoWithSchema(StarlarkProvider provider, Object[] table, @Nullable Location loc) {
super(loc);
this.provider = provider;
this.table = table;
Expand All @@ -55,6 +56,11 @@ public Provider getProvider() {
return provider;
}

@VisibleForSerialization // private
Object[] getTable() {
return table;
}

/**
* Constructs a StarlarkInfo from an array of alternating key/value pairs as provided by
* Starlark.fastcall. Checks that each key is provided at most once, and is defined by the schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ java_test(
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils",
"//third_party:guava",
"//third_party:junit4",
"//third_party:mockito",
"//third_party:truth",
Expand Down

0 comments on commit abd481d

Please sign in to comment.