Repository navigation
Restore set value type checks and per-element setLazy - #1398
Merged
Merged
Conversation
github-actions
Bot
requested review from
SooKim1110,
acktsap,
benelog,
jwChung and
mhyeon-lee
November 19, 2026 07:30
This was referenced Nov 19, 2026
seongahjo
force-pushed
the
fix/restore-set-value-handling
branch
from
November 19, 2026 07:51
ae7b894 to
c690a92
Compare
seongahjo
force-pushed
the
fix/restore-set-value-handling
branch
from
November 19, 2026 08:18
c690a92 to
26f9599
Compare
seongahjo
force-pushed
the
fix/restore-set-value-handling
branch
from
November 19, 2026 08:31
26f9599 to
ac90523
Compare
seongahjo
force-pushed
the
fix/restore-set-value-handling
branch
from
November 19, 2026 08:45
ac90523 to
0c5a85f
Compare
seongahjo
force-pushed
the
fix/restore-set-value-handling
branch
7 times, most recently
from
November 20, 2026 05:46
b4218ae to
23dd108
Compare
- Throw when a set, setLazy or register value is not assignable to the property type - Call a per-element setLazy supplier for each element - Decompose, check and rebuild Optional, Map.Entry and registered setLazy values - Infer the type arguments of Map.Entry and Optional values from their contents - Build Map.Entry nodes for Map.Entry values set into Object properties and containers
seongahjo
force-pushed
the
fix/restore-set-value-handling
branch
from
November 20, 2026 06:12
23dd108 to
72dcafa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1.2.x lost two 1.1.x behaviors around set values. A value that is not assignable to the property type was ignored, and a per-element
setLazycalled its supplier once per sample. This PR restores both.It also handles
Optional,Map.Entryand registeredsetLazyvalues the same way as other set values, so their contents are checked and rebuilt in each sample. This includes values set where the declared type does not say they are anOptionalor aMap.Entry, such as anObjectproperty.This is the third of four stacked PRs, based on #1395:
(Optional): Description
Set value type check (1.1.x behavior restored)
set,setLazyorregisterthat is not assignable to the property type throwsIllegalArgumentExceptiononsample():null, was generated anew, or held elements of the wrong type.DogintoAnimalandIntegerintointstill pass.ValueProjectionAssembler.assembleNode, when a value is fixed on a node. Collections, maps, arrays,Optional,Map.Entryand objects are decomposed, so every element and field is checked against its own declared type at any depth.Values.just(...)values and value generators such asValues.unique(...)are not checked, as in 1.1.x.Consistent decomposition of set values
OptionalorMap.Entryis decomposed like other containers. Its content, key and value are rebuilt on their own nodes, and nested container sizes are kept (ValueAnalyzer,ObjectValueExtractor,ValueDecomposer). Before, the instance was used as is, so its content was neither checked nor rebuilt for each sample.Types.isSingleElementWrapperandTypes.hasFixedChildrendecide which containers have a fixed set of children (single-element wrappers andMap.Entry).ContainerDetector.getContainerSizeAtPathgives the size registered at a path whose content shares it, such as the list inside anOptional.Objectproperty, anObjectcontainer element orOptional<Object>content:Map.EntryorOptionalvalue are inferred from its contents (GenericTypeResolverConverter)OptionalandKeyValueHolder(fromMap.entry(...)) get their type arguments, andMap.Entryvalues are resolved fromObject(ValueAnalyzer)Map.Entryfrom its set value is promoted from the candidateJavaNodeCandidateFactorycreates for that type, the same way as a declaredMap.Entryproperty.JvmNodeCandidateFactory.createaccepts anullname, the same as the candidates it creates.KotlinNodePromoterleavesMap.Entrycandidates toJavaMapEntryNodePromoter, so an entry set into a KotlinAnyproperty is built as an entry tooOptional<Child>staysChildinstead of getting theOptional's type argumentssetLazyvalues of a registered builder are decomposed, checked and rebuilt likesetvalues. A supplier that returnsValues.just(...)keeps the instance, and one that returns anArbitraryis sampled, the same as in the builder being sampled.Per-element
setLazy(1.1.x behavior restored)setLazy("values[*]", supplier)calls the supplier for each element, so numbering works again. Withsize("values", 3)and two samples, the result is[[1, 2, 3], [4, 5, 6]]instead of[[1, 1, 1], [2, 2, 2]].Behavior changes
OptionalorMap.Entry, and an object returned by a registeredsetLazy, is a new instance in each sample instead of the given instance. UseValues.just(...)to keep the instance.setLazycalls the supplier once per element instead of once per sample.Known issue
The contents of
Supplier,Function,IteratorandStreamvalues are not checked, because looking inside would call user code or consume the value. For example,set("value", () -> inner)on aSupplier<Supplier<String>>property, whereinneris() -> "x", putsinneritself into the property, sovalue.get()returns aString. 1.1.x failed here withgiven type is not supported container. Workaround:set("value", Values.just(() -> inner)).How Has This Been Tested?
SetValueAssignabilityTestinfixture-monkey-tests/java-tests(15 tests):Integerinto aStringproperty, aStringinto a POJO property, a lambda into aSupplier<String>property (its"x"result becomes the value), and a wrong-typed element or content in a list, nested list, map,Optional,Map.Entry, and a registeredsetLazylist orOptionalsetLazycontentSetLazyEvaluationTestinfixture-monkey-tests/java-tests(10 tests):sample(),sampleList()and a registered buildersetLazyreturning anArbitraryis sampledSetOptionalAndEntryDecompositionTestinfixture-monkey-tests/java-tests(11 tests):OptionalandMap.EntryAbstractMap.SimpleEntryand a set of entries into anObjectpropertyOptional<Object>SetObjectIsolationTest:Values.justfromsetLazyand from a registeredsetLazykeeps the instance, and anOptionaland a registeredsetLazyobject are new instances in each sampleSetJdkInternalContainerTest:List.of(),Arrays.asList, an unmodifiable list,HashMap.values()and a list with anullelement into anObjectpropertyNavigableSetbecomes aTreeSetwithout a registered implementationList.ofinto anObjectproperty and thensetof an element, andsetLazyofList.ofMap.entry(...)into anObjectpropertysampleListOfEntriestoContainerTypeTest:List<Map.Entry<String, Integer>>is generated with entriescontentOfSetOptionalKeepsItsOwnTypetoJvmNodeTreeTransformerTestsetMapEntryToObjectto the KotlinCustomizationTestobject-farm-api,fixture-monkey,fixture-monkey-kotlin,java-tests,java-17-testsandkotlin-testswith checkstyle, Checker Framework and ktlintIs the Document updated?
No documentation change is needed.