@@ -1792,29 +1792,71 @@ public interface [tb.nameBuildFinal][type.generics] {
17921792[/if]
17931793 private void mergeInternal(Object object) {
17941794 [dynamicFromModifiableCheck type 'object' 'return;']
1795- [for l in bs.positions.longs]
1796- [atVar type]long bits[emptyIfZero l.index] = 0;
1795+ [if bs.positions.hasMultipleLongs]
1796+ [atVar type]long['[]'] bits = new long['['][bs.positions.longs.size][']'];
1797+ [for s in bs.supertypes if s.attributes]
1798+ if (object instanceof [s.wildcard]) {
1799+ mergeFrom[toSafeIdentifier s.simpleName](bits, ([s.type]) object);
1800+ }
17971801 [/for]
1798- [for s in bs.supertypes if s.attributes]
1802+ [else]
1803+ [atVar type]long bits = 0;
1804+ [for s in bs.supertypes if s.attributes]
17991805 if (object instanceof [s.wildcard]) {
1800- [s.type] instance = ([s.type]) object;
1801- [for v in s.attributes, BitPosition pos = bs.positions v.name]
1802- [if pos]
1803- if ((bits[emptyIfZero pos.index] & [literal.hex pos.mask]) == 0) {
1804- [if v.nullableInSupertype]
1805- [buildFromAttributeNullableSupertype v]
1806- [else]
1807- [buildFromAttribute v]
1808- [/if]
1809- bits[emptyIfZero pos.index] |= [literal.hex pos.mask];
1810- }
1806+ bits = mergeFrom[toSafeIdentifier s.simpleName](bits, ([s.type]) object);
1807+ }
1808+ [/for]
1809+ [/if]
1810+ }
1811+
1812+ [-- Generate specialized merge methods per subtype --]
1813+ [for s in bs.supertypes if s.attributes]
1814+ [if bs.positions.hasMultipleLongs]
1815+ private void mergeFrom[toSafeIdentifier s.simpleName](long['[]'] bits, [s.type] instance) {
1816+ [-- Read array values into named variables --]
1817+ [for l in bs.positions.longs]
1818+ long bitMask[emptyIfZero l.index] = bits['['][l.index][']'];
1819+ [/for]
1820+ [for v in s.attributes, BitPosition pos = bs.positions v.name]
1821+ [if pos]
1822+ if ((bitMask[emptyIfZero pos.index] & [literal.hex pos.mask]) == 0) {
1823+ [if v.nullableInSupertype]
1824+ [buildFromAttributeNullableSupertype v]
18111825 [else]
18121826 [buildFromAttribute v]
18131827 [/if]
1814- [/for]
1828+ bitMask[emptyIfZero pos.index] |= [literal.hex pos.mask];
18151829 }
1816- [/for]
1830+ [else]
1831+ [buildFromAttribute v]
1832+ [/if]
1833+ [/for]
1834+ [-- Write named variables back to array --]
1835+ [for l in bs.positions.longs]
1836+ bits['['][l.index][']'] = bitMask[emptyIfZero l.index];
1837+ [/for]
18171838 }
1839+ [else]
1840+ private long mergeFrom[toSafeIdentifier s.simpleName](long bits, [s.type] instance) {
1841+ [for v in s.attributes, BitPosition pos = bs.positions v.name]
1842+ [if pos]
1843+ if ((bits & [literal.hex pos.mask]) == 0) {
1844+ [if v.nullableInSupertype]
1845+ [buildFromAttributeNullableSupertype v]
1846+ [else]
1847+ [buildFromAttribute v]
1848+ [/if]
1849+ bits |= [literal.hex pos.mask];
1850+ }
1851+ [else]
1852+ [buildFromAttribute v]
1853+ [/if]
1854+ [/for]
1855+ return bits;
1856+ }
1857+ [/if]
1858+
1859+ [/for]
18181860[/for]
18191861 [else]
18201862
0 commit comments