-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constant fold (almost) all the number conversion methods
Co-authored-by: Eugene Flesselle <[email protected]> Co-authored-by: Martin Kucera <[email protected]>
- Loading branch information
1 parent
ce65296
commit 3a1c0f4
Showing
2 changed files
with
37 additions
and
1 deletion.
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
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,26 @@ | ||
|
||
object Test: | ||
|
||
inline val myInt = 1 << 6 | ||
|
||
// toLong | ||
inline val char2Long: 99L = 'c'.toLong | ||
inline val int2Long: 0L = 0.toLong | ||
inline val long2Long: 0L = 0L.toLong | ||
inline val int2LongPropagated: 64L = myInt.toLong | ||
|
||
// toInt | ||
inline val char2Int: 99 = 'c'.toInt | ||
inline val int2Int: 0 = 0.toInt | ||
inline val long2Int: 0 = 0L.toInt | ||
inline val long2IntWrapped: -2147483648 = 2147483648L.toInt | ||
inline val int2IntPropagated: 64 = myInt.toInt | ||
|
||
// toChar | ||
inline val char2Char: 'c' = 'c'.toChar | ||
inline val int2Char: 'c' = 99.toChar | ||
inline val long2Char: 'c' = 99L.toChar | ||
inline val int2CharPropagated: '@' = myInt.toChar | ||
|
||
// chain everything | ||
inline val wow: 1.0 = 1.toChar.toInt.toLong.toFloat.toDouble |