Skip to content

Commit

Permalink
remove bounds check on input 'long' values into 'alias: double' (#2421)
Browse files Browse the repository at this point in the history
remove bounds check on input 'long' values into 'alias: double'
  • Loading branch information
carterkozak authored Dec 3, 2024
1 parent 52d48fd commit 4b9f6ce
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2421.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: 'remove bounds check on input ''long'' values into ''alias: double'''
links:
- https://github.com/palantir/conjure-java/pull/2421

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.common.collect.ImmutableList;
import com.palantir.conjure.java.ConjureAnnotations;
import com.palantir.conjure.java.Options;
import com.palantir.conjure.java.lib.SafeLong;
import com.palantir.conjure.java.util.Javadoc;
import com.palantir.conjure.java.util.Packages;
import com.palantir.conjure.java.util.Primitives;
Expand Down Expand Up @@ -148,8 +147,7 @@ public static JavaFile generateAliasType(

if (isAliasOfDouble(typeDef)) {
CodeBlock longCastCodeBlock = CodeBlock.builder()
.addStatement("long safeValue = $T.of(value).longValue()", SafeLong.class)
.addStatement("return new $T((double) safeValue)", thisClass)
.addStatement("return new $T((double) value)", thisClass)
.build();

CodeBlock intCastCodeBlock = CodeBlock.builder()
Expand Down

0 comments on commit 4b9f6ce

Please sign in to comment.