diff --git a/value-fixture/src/org/immutables/fixture/AllParametersDefaultInit.java b/value-fixture/src/org/immutables/fixture/AllParametersDefaultInit.java new file mode 100644 index 000000000..cc9cc50c4 --- /dev/null +++ b/value-fixture/src/org/immutables/fixture/AllParametersDefaultInit.java @@ -0,0 +1,17 @@ +package org.immutables.fixture; + +import org.immutables.value.Value; + +@Value.Immutable +@Value.Style(allParameters = true) +interface AllParametersDefaultInit { + @Value.Default + default String getFoo() { + return ""; + } + + @Value.Default + default boolean isBar() { + return true; + } +} diff --git a/value-fixture/test/org/immutables/fixture/encoding/UseCompactDate.java b/value-fixture/test/org/immutables/fixture/encoding/UseCompactDate.java new file mode 100644 index 000000000..000509d97 --- /dev/null +++ b/value-fixture/test/org/immutables/fixture/encoding/UseCompactDate.java @@ -0,0 +1,40 @@ +/* + Copyright 2018 Immutables Authors and Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +package org.immutables.fixture.encoding; + +import java.util.Date; +import org.immutables.fixture.encoding.defs.CompactDateEnabled; +import org.immutables.value.Value; + +@CompactDateEnabled +public abstract class UseCompactDate { + public abstract static class Base { + @Value.Default + public Date getFirstSeen() { + return new Date(); + } + + @Value.Default + public Date lastSeen() { + return getFirstSeen(); + } + } + + @Value.Immutable + public abstract static class SomeSubclass extends Base { + public abstract String name(); + } +} diff --git a/value-fixture/test/org/immutables/fixture/encoding/UseCompactLocalDateTime.java b/value-fixture/test/org/immutables/fixture/encoding/UseCompactLocalDateTime.java deleted file mode 100644 index a0dbcaac1..000000000 --- a/value-fixture/test/org/immutables/fixture/encoding/UseCompactLocalDateTime.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.immutables.fixture.encoding; - -import java.util.Date; -import org.immutables.fixture.encoding.defs.CompactDateEnabled; -import org.immutables.value.Value; - -@CompactDateEnabled -public abstract class UseCompactLocalDateTime { - public abstract static class Base { - @Value.Default - public Date firstSeen() { - return new Date(); - } - - @Value.Default - public Date lastSeen() { - return firstSeen(); - } - } - - @Value.Immutable - public abstract static class SomeSubclass extends Base { - public abstract String name(); - } -} diff --git a/value-processor/src/org/immutables/value/processor/Immutables.generator b/value-processor/src/org/immutables/value/processor/Immutables.generator index b27038bca..96aad5bb4 100644 --- a/value-processor/src/org/immutables/value/processor/Immutables.generator +++ b/value-processor/src/org/immutables/value/processor/Immutables.generator @@ -2327,12 +2327,12 @@ this.[n] = [valueFromValue v][invokeSuper v].[v.names.get]()[/valueFromValue]; [/if] [/for] [generateConstructorDefaultAttributes type type.constructorOmited] + [generateDerivedConstruction type type.constructorArguments] [else][-- Alternatively a lot simpler implementation] [for v in type.constructorArguments, n = v.name] this.[n] = [valueFromValue v n]; [/for] [/if] - [generateDerivedConstruction type type.constructorArguments] [generateAfterConstruction type false] } [/if] diff --git a/value-processor/src/org/immutables/value/processor/encode/Renderers.generator b/value-processor/src/org/immutables/value/processor/encode/Renderers.generator index 758cfb65e..163456469 100644 --- a/value-processor/src/org/immutables/value/processor/encode/Renderers.generator +++ b/value-processor/src/org/immutables/value/processor/encode/Renderers.generator @@ -220,7 +220,7 @@ private [inst.typer el.type] with_[inst.namer el]([for p in el.params][if not fo private [inst.typer f.type] [inst.namer f] { InitShim shim = this.[shimName]; - return shim != null ? shim.[inst.directField f]() : this.[inst.directField f]; + return shim != null ? shim.[if f.implField][a.names.get][else][inst.directField f][/if]() : this.[inst.directField f]; } [/for] [/if]