generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: optional handling in the JVM (#2951)
For Kotlin this should exactly match the language semantics. For Java types are not considered Optional unless they are wrapped in a java.util.Optional, or annotated with @nullable. The exception to this are the boxed primitive types, which are always considered nullable. fixes: #2356
- Loading branch information
1 parent
3656949
commit ddc902c
Showing
14 changed files
with
245 additions
and
95 deletions.
There are no files selected for viewing
This file contains 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
20 changes: 20 additions & 0 deletions
20
...me/common/deployment/src/main/java/xyz/block/ftl/deployment/DefaultOptionalBuildItem.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package xyz.block.ftl.deployment; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
/** | ||
* Build item that indicates if a type with no nullability information should default to optional. | ||
* | ||
* This is different between Kotlin and Java | ||
*/ | ||
public final class DefaultOptionalBuildItem extends SimpleBuildItem { | ||
final boolean defaultToOptional; | ||
|
||
public DefaultOptionalBuildItem(boolean defaultToOptional) { | ||
this.defaultToOptional = defaultToOptional; | ||
} | ||
|
||
public boolean isDefaultToOptional() { | ||
return defaultToOptional; | ||
} | ||
} |
This file contains 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
125 changes: 81 additions & 44 deletions
125
...e/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/ModuleBuilder.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
7 changes: 7 additions & 0 deletions
7
...ime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/Nullability.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package xyz.block.ftl.deployment; | ||
|
||
public enum Nullability { | ||
MISSING, | ||
NULLABLE, | ||
NOT_NULL | ||
} |
This file contains 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
This file contains 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
11 changes: 11 additions & 0 deletions
11
...ime/java/deployment/src/main/java/xyz/block/ftl/javalang/deployment/FTLJavaProcessor.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package xyz.block.ftl.javalang.deployment; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import xyz.block.ftl.deployment.DefaultOptionalBuildItem; | ||
|
||
public class FTLJavaProcessor { | ||
@BuildStep | ||
public DefaultOptionalBuildItem defaultOptional() { | ||
return new DefaultOptionalBuildItem(false); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...e/kotlin/deployment/src/main/java/xyz/block/ftl/kotlin/deployment/FTLKotlinProcessor.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package xyz.block.ftl.kotlin.deployment; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import xyz.block.ftl.deployment.DefaultOptionalBuildItem; | ||
|
||
public class FTLKotlinProcessor { | ||
@BuildStep | ||
public DefaultOptionalBuildItem defaultOptional() { | ||
return new DefaultOptionalBuildItem(true); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.